diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-05-29 13:49:41 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-05-29 13:49:41 +0000 |
commit | bf12861370a96216324a6cf87d25d052eeda2273 (patch) | |
tree | eadfcef959557ff3bd3bb3e70bfd4b4f79dc456f /regress | |
parent | 783b6eadc6abc4f73d71dea6067e2047b26e7047 (diff) |
Minor regress test cleanup.
OK sf@
Diffstat (limited to 'regress')
-rw-r--r-- | regress/sys/fileops/Makefile.inc | 12 | ||||
-rw-r--r-- | regress/sys/fileops/fileops.c | 33 |
2 files changed, 21 insertions, 24 deletions
diff --git a/regress/sys/fileops/Makefile.inc b/regress/sys/fileops/Makefile.inc index 74ef34ffc13..410817a63b9 100644 --- a/regress/sys/fileops/Makefile.inc +++ b/regress/sys/fileops/Makefile.inc @@ -1,12 +1,10 @@ -# $OpenBSD: Makefile.inc,v 1.1 2017/05/29 11:01:16 sf Exp $ +# $OpenBSD: Makefile.inc,v 1.2 2017/05/29 13:49:40 bluhm Exp $ TESTS= create read mmap FILEOPS_MNT= /mnt/regress-fileops FILEOPS_PROG= ${.OBJDIR}/../fileops -IMG= ${.OBJDIR}/diskimage -CLEANFILES= ${IMG} stamp-* - +CLEANFILES= diskimage stamp-* .poison !defined (MOUNT) .poison !defined (NEWFS) @@ -14,8 +12,8 @@ CLEANFILES= ${IMG} stamp-* .PHONY: disk mount unconfig clean disk: unconfig - dd if=/dev/urandom of=${IMG} bs=1M count=32 - vnconfig vnd0 ${IMG} + dd if=/dev/urandom of=diskimage bs=1M count=32 + vnconfig vnd0 diskimage ${NEWFS} /dev/rvnd0c mount: disk @@ -26,7 +24,7 @@ unconfig: -umount -f /dev/vnd0c 2>/dev/null || true -rmdir ${FILEOPS_MNT} 2>/dev/null || true -vnconfig -u vnd0 2>/dev/null || true - -rm -f stamp-setup ${IMG} + -rm -f stamp-setup diskimage stamp-setup: @echo '\n======== $@ ========' diff --git a/regress/sys/fileops/fileops.c b/regress/sys/fileops/fileops.c index c552ca451ed..e9970485ac9 100644 --- a/regress/sys/fileops/fileops.c +++ b/regress/sys/fileops/fileops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fileops.c,v 1.1 2017/05/29 11:01:16 sf Exp $ */ +/* $OpenBSD: fileops.c,v 1.2 2017/05/29 13:49:40 bluhm Exp $ */ /* * Copyright (c) 2017 Stefan Fritsch <sf@sfritsch.de> * @@ -28,11 +28,6 @@ #define BUFSIZE (16 * 1024) #define HOLESIZE (16 * BUFSIZE) -#define myerr(rc, fmt, ...) \ - do { err(rc, fmt "\nFAILED", ## __VA_ARGS__); } while (0) -#define myerrx(rc, fmt, ...) \ - do { errx(rc, fmt "\nFAILED", ## __VA_ARGS__); } while (0) - static int debug = 0; static int fd = -1; static off_t curpos = 0; @@ -58,7 +53,8 @@ check_data(const void *buf, size_t size, uint32_t seed) const uint32_t *ibuf = buf; for (size_t i = 0; i < size / 4; i++) { if (ibuf[i] != seed + i) { - myerrx(3, "%s: pos %zd/%zd: expected %#08zx got %#08x\n", __func__, 4 * i, size, seed + i, ibuf[i]); + errx(3, "%s: pos %zd/%zd: expected %#08zx got %#08x", + __func__, 4 * i, size, seed + i, ibuf[i]); } } } @@ -70,7 +66,8 @@ check_zero(const void *buf, size_t size) const uint32_t *ibuf = buf; for (size_t i = 0; i < size / 4; i++) { if (ibuf[i] != 0) { - myerrx(3, "%s: pos %zd/%zd: expected 0 got %#08x\n", __func__, 4 * i, size, ibuf[i]); + errx(3, "%s: pos %zd/%zd: expected 0 got %#08x", + __func__, 4 * i, size, ibuf[i]); } } } @@ -80,9 +77,11 @@ check(const char *what, int64_t have, int64_t want) { if (have != want) { if (have == -1) - myerr(2, "%s returned %lld, expected %lld", what, have, want); + err(2, "%s returned %lld, expected %lld", + what, have, want); else - myerrx(2, "%s returned %lld, expected %lld", what, have, want); + errx(2, "%s returned %lld, expected %lld", + what, have, want); } if (debug) @@ -124,7 +123,7 @@ c_lseek(off_t offset, int whence) curpos += offset; break; default: - myerrx(1, "c_lseek not supported"); + errx(1, "c_lseek not supported"); } check("lseek", ret, curpos); if (debug) @@ -136,7 +135,7 @@ c_mmap(size_t size) { mbuf = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, curpos); if (mbuf == MAP_FAILED) - myerr(2, "mmap %zd pos %lld failed", size, (long long)curpos); + err(2, "mmap %zd pos %lld failed", size, (long long)curpos); curpos += size; if (debug) printf("mmap: %p\n", mbuf); @@ -147,7 +146,7 @@ c_munmap(size_t size) { int ret = munmap(mbuf, size); if (ret != 0) - myerr(2, "munmap"); + err(2, "munmap"); } void @@ -155,7 +154,7 @@ c_open(int flags) { fd = open(fname, flags, S_IRUSR|S_IWUSR); if (fd == -1) - myerr(1, "open"); + err(1, "open"); } void @@ -233,7 +232,7 @@ do_mmap(void) void usage(void) { - myerrx(1, "usage: fileops (create|read|mmap) filename"); + errx(1, "usage: fileops (create|read|mmap) filename"); } int main(int argc, char **argv) @@ -244,7 +243,7 @@ int main(int argc, char **argv) fname = argv[2]; gbuf = malloc(BUFSIZE); if (gbuf == NULL) - myerrx(1, "malloc"); + err(1, "malloc"); if (strcmp(argv[1], "create") == 0) { do_create(); @@ -256,6 +255,6 @@ int main(int argc, char **argv) usage(); } - printf("ok\n"); + printf("pass\n"); return 0; } |