diff options
author | anton <anton@cvs.openbsd.org> | 2019-01-20 10:02:39 +0000 |
---|---|---|
committer | anton <anton@cvs.openbsd.org> | 2019-01-20 10:02:39 +0000 |
commit | b02ddfe874b80eec0252800582723e648e33bc1c (patch) | |
tree | 6eb9a3228ab231b840484668999844fd332fad4a /regress/sys | |
parent | a9e6ee043cb1aaaa34286857dc960d0a954de1a8 (diff) |
run all tests for each supported trace mode
Diffstat (limited to 'regress/sys')
-rw-r--r-- | regress/sys/dev/kcov/Makefile | 3 | ||||
-rw-r--r-- | regress/sys/dev/kcov/kcov.c | 32 |
2 files changed, 33 insertions, 2 deletions
diff --git a/regress/sys/dev/kcov/Makefile b/regress/sys/dev/kcov/Makefile index ddbf9025a9d..6e2583b715b 100644 --- a/regress/sys/dev/kcov/Makefile +++ b/regress/sys/dev/kcov/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.8 2019/01/19 17:25:17 anton Exp $ +# $OpenBSD: Makefile,v 1.9 2019/01/20 10:02:38 anton Exp $ PROG= kcov WARNINGS= yes @@ -7,6 +7,7 @@ LDADD+= -lpthread DPADD+= ${LIBPTHREAD} MODES+= pc +MODES+= cmp TESTS+= close TESTS+= coverage diff --git a/regress/sys/dev/kcov/kcov.c b/regress/sys/dev/kcov/kcov.c index 04f3895ef02..ad5ef10704f 100644 --- a/regress/sys/dev/kcov/kcov.c +++ b/regress/sys/dev/kcov/kcov.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kcov.c,v 1.8 2019/01/19 17:25:17 anton Exp $ */ +/* $OpenBSD: kcov.c,v 1.9 2019/01/20 10:02:38 anton Exp $ */ /* * Copyright (c) 2018 Anton Lindqvist <anton@openbsd.org> @@ -84,6 +84,8 @@ main(int argc, char *argv[]) case 'm': if (strcmp(optarg, "pc") == 0) mode = KCOV_MODE_TRACE_PC; + else if (strcmp(optarg, "cmp") == 0) + mode = KCOV_MODE_TRACE_CMP; else errx(1, "unknown mode %s", optarg); break; @@ -157,6 +159,7 @@ static int check_coverage(const unsigned long *cover, int mode, unsigned long maxsize, int nonzero) { + unsigned long arg1, arg2, exp, i, pc, type; int error = 0; if (nonzero && cover[0] == 0) { @@ -170,6 +173,30 @@ check_coverage(const unsigned long *cover, int mode, unsigned long maxsize, return 1; } + if (mode == KCOV_MODE_TRACE_CMP) { + if (*cover * 4 >= maxsize) { + warnx("coverage cmp overflow (count=%lu, max=%lu)\n", + *cover * 4, maxsize); + return 1; + } + + for (i = 0; i < cover[0]; i++) { + type = cover[i * 4 + 1]; + arg1 = cover[i * 4 + 2]; + arg2 = cover[i * 4 + 3]; + pc = cover[i * 4 + 4]; + + exp = type >> 1; + if (exp <= 3) + continue; + + warnx("coverage cmp invalid size (i=%lu, exp=%lx, " + "const=%ld, arg1=%lu, arg2=%lu, pc=%p)\n", + i, exp, type & 0x1, arg1, arg2, (void *)pc); + error = 1; + } + } + return error; } @@ -179,6 +206,9 @@ dump(const unsigned long *cover, int mode) unsigned long i; int stride = 1; + if (mode == KCOV_MODE_TRACE_CMP) + stride = 4; + for (i = 0; i < cover[0]; i++) printf("%p\n", (void *)cover[i * stride + 1]); } |