diff options
author | anton <anton@cvs.openbsd.org> | 2018-12-16 15:56:04 +0000 |
---|---|---|
committer | anton <anton@cvs.openbsd.org> | 2018-12-16 15:56:04 +0000 |
commit | 56f0ae1047380a08582f53f3e2d385c7f2d1b3f7 (patch) | |
tree | 404df4c953c38fe0ea16fc10c1f805cec5f3be5d | |
parent | 6349377508a614d46d9e5bbe44f432a042383d6a (diff) |
split tests into multiple make targets
-rw-r--r-- | regress/sys/dev/kcov/Makefile | 17 | ||||
-rw-r--r-- | regress/sys/dev/kcov/kcov.c | 44 |
2 files changed, 36 insertions, 25 deletions
diff --git a/regress/sys/dev/kcov/Makefile b/regress/sys/dev/kcov/Makefile index 2760219143c..fd236cf226b 100644 --- a/regress/sys/dev/kcov/Makefile +++ b/regress/sys/dev/kcov/Makefile @@ -1,13 +1,24 @@ -# $OpenBSD: Makefile,v 1.1 2018/08/26 08:12:09 anton Exp $ +# $OpenBSD: Makefile,v 1.2 2018/12/16 15:56:03 anton Exp $ PROG= kcov WARNINGS= yes -run-regress-${PROG}: ${PROG} +TESTS+= coverage +TESTS+= fork +TESTS+= exec +TESTS+= mode +TESTS+= open +TESTS+= close + +.for t in ${TESTS} +$t: + @echo "\n======== ${@} ========" if ${SUDO} ./${PROG} -p; then \ - ${SUDO} ./${PROG} ${KCOVFLAGS}; \ + ${SUDO} ./${PROG} ${KCOVFLAGS} $t; \ else \ echo "SKIPPED"; \ fi +REGRESS_TARGETS+= $t +.endfor .include <bsd.regress.mk> diff --git a/regress/sys/dev/kcov/kcov.c b/regress/sys/dev/kcov/kcov.c index c6b52124091..dd8a2c360a6 100644 --- a/regress/sys/dev/kcov/kcov.c +++ b/regress/sys/dev/kcov/kcov.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kcov.c,v 1.1 2018/08/26 08:12:09 anton Exp $ */ +/* $OpenBSD: kcov.c,v 1.2 2018/12/16 15:56:03 anton Exp $ */ /* * Copyright (c) 2018 Anton Lindqvist <anton@openbsd.org> @@ -26,6 +26,7 @@ #include <fcntl.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <unistd.h> static int test_close(int); @@ -63,7 +64,7 @@ main(int argc, char *argv[]) }; unsigned long *cover; int c, fd, i; - int nfail = 0; + int error = 0; int prereq = 0; int reexec = 0; int verbose = 0; @@ -86,8 +87,6 @@ main(int argc, char *argv[]) } argc -= optind; argv += optind; - if (argc > 0) - usage(); if (prereq) { fd = kcov_open(); @@ -100,6 +99,14 @@ main(int argc, char *argv[]) return 0; } + if (argc != 1) + usage(); + for (i = 0; tests[i].name != NULL; i++) + if (strcmp(argv[0], tests[i].name) == 0) + break; + if (tests[i].name == NULL) + errx(1, "%s: no such test", argv[0]); + fd = kcov_open(); if (ioctl(fd, KIOSETBUFSIZE, &bufsize) == -1) err(1, "ioctl: KIOSETBUFSIZE"); @@ -108,30 +115,23 @@ main(int argc, char *argv[]) if (cover == MAP_FAILED) err(1, "mmap"); - for (i = 0; tests[i].name != NULL; i++) { - printf("===> %s\n", tests[i].name); - *cover = 0; - nfail += tests[i].fn(fd); - if (verbose) - dump(cover); - if (tests[i].coverage && *cover == 0) { - warnx("coverage empty (count=%lu, fd=%d)\n", - *cover, fd); - nfail++; - } else if (!tests[i].coverage && *cover != 0) { - warnx("coverage is not empty (count=%lu, fd=%d)\n", - *cover, fd); - nfail++; - } + *cover = 0; + error = tests[i].fn(fd); + if (verbose) + dump(cover); + if (tests[i].coverage && *cover == 0) { + warnx("coverage empty (count=%lu, fd=%d)\n", *cover, fd); + error = 1; + } else if (!tests[i].coverage && *cover != 0) { + warnx("coverage is not empty (count=%lu, fd=%d)\n", *cover, fd); + error = 1; } if (munmap(cover, bufsize * sizeof(unsigned long)) == -1) err(1, "munmap"); close(fd); - if (nfail > 0) - return 1; - return 0; + return error; } static __dead void |