diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..003cb70 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.o +auto-ccld.sh +compile +extra-libs +find-systype +load +make-compile +make-load +memtester +systype diff --git a/CHANGELOG b/CHANGELOG index 5f1cec1..e2a359e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,18 @@ +Version 4.5.1 +30 May 2021 + -documentation-only update. + -add note to README about build problem with Tru64, with workaround. + Thanks: VĂ­ctor Ostorga. + +Version 4.5.0 +20 September 2020 + -add note to README about problems with HP/UX prior to v.11. Change code + so that buffer still gets aligned even if you comment out the use of mlock() + on such a platform. Thanks: Keith Monahan. + -fix clear-buffer using incorrect param, causing spurious test failures. + Thanks: Debin Dong. + -fix shell-ism in Makefile. Thanks: Fabrice Fontaine. + Version 4.3.0 9 June 2012 -add ability to mmap a device other than /dev/mem, enabling easier testing @@ -14,7 +29,7 @@ Version 4.2.2 mlock; BSDs use this to indicate the lock failed due to being over a system or process limit, much like ENOMEM. - Version 4.2.1 +Version 4.2.1 3 October 2010 -fix offsets/addresses were not being reported correctly in test failure messages. Thanks: Anton Sergeev. diff --git a/Makefile b/Makefile index a271bf5..5756ecd 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # Makefile for memtester by Charles Cazabon. # # Copyright (C) 1999 Simon Kirby. -# Copyright (C) 1999-2009 Charles Cazabon. +# Copyright (C) 1999-2020 Charles Cazabon. # Licensed under the GNU General Public License version 2. See the file # COPYING for details. # @@ -13,7 +13,7 @@ CC = $(shell head -n 1 conf-cc) LD = $(shell head -n 1 conf-ld) -SOURCES = memtester.c tests.c +SOURCES = memtester.c tests.c output.c OBJECTS = $(SOURCES:.c=.o) HEADERS = memtester.h TARGETS = *.o compile load auto-ccld.sh find-systype make-compile make-load systype extra-libs @@ -25,8 +25,9 @@ INSTALLPATH = /usr/local all: memtester install: all - mkdir -m 755 -p $(INSTALLPATH)/{bin,man/man8} + mkdir -m 755 -p $(INSTALLPATH)/bin install -m 755 memtester $(INSTALLPATH)/bin/ + mkdir -m 755 -p $(INSTALLPATH)/man/man8 gzip -c memtester.8 >memtester.8.gz ; install -m 644 memtester.8.gz $(INSTALLPATH)/man/man8/ auto-ccld.sh: \ @@ -75,7 +76,7 @@ clean: memtester: \ $(OBJECTS) memtester.c tests.h tests.c tests.h conf-cc Makefile load extra-libs - ./load memtester tests.o `cat extra-libs` + ./load memtester tests.o output.o `cat extra-libs` memtester.o: memtester.c tests.h conf-cc Makefile compile ./compile memtester.c diff --git a/README b/README index 44003b1..364e808 100644 --- a/README +++ b/README @@ -8,7 +8,7 @@ Version 2 Copyright 1999 Charles Cazabon. Version 3 not publicly released. Version 4 rewrite: - Copyright 2004-2012 Charles Cazabon. + Copyright 2004-2020 Charles Cazabon. Licensed under the terms of the GNU General Public License version 2 (only). See the file COPYING for details. @@ -124,3 +124,25 @@ directed to me at . Read BUGS to report bugs found in memtester. + Platform Compatibility Notes + + As mentioned, memtester v4 was tested with a wide variety of Unix- and + Unix-like systems. However, at least two issues with ancient HP/UX + versions, and one with Tru64, have come up since. + + HP/UX versions prior to v11 do not support mlock() and will fail with an + invalid syscall error at runtime. If you're building on HP/UX v10.20 or + similar, change `int do_mlock = 1` around line 128 of memtester.c to + `int do_mlock = 0` and rebuild. + They also are missing strtoull() from C99. To fix this build error, + add `#define strtoull __strtoull` to the top of memtester.c; this should + at least work with a GCC toolchain. + + Tru64 is missing strtoull() from C99. To fix this build error when using + cc, add `#define strtoull strtoul` to the top of memtester.c; this is + safe because long on Tru64 is 64-bits. This build problem could be dealt + with automatically, but I don't particularly want to invest the necessary + time, because Tru64 went out of support in 2012. In addition, I no longer + have access to a build machine for testing on this platform. + + diff --git a/extra-libs.sh b/extra-libs.sh old mode 100644 new mode 100755 diff --git a/find-systype.sh b/find-systype.sh old mode 100644 new mode 100755 diff --git a/make-compile.sh b/make-compile.sh old mode 100644 new mode 100755 diff --git a/make-load.sh b/make-load.sh old mode 100644 new mode 100755 diff --git a/make-makelib.sh b/make-makelib.sh old mode 100644 new mode 100755 diff --git a/memtester.8 b/memtester.8 index fd80bc7..cf460b8 100644 --- a/memtester.8 +++ b/memtester.8 @@ -1,4 +1,4 @@ -.TH memtester "8" "June 2012" "memtester 4" "Maintenance Commands" +.TH memtester "8" "September 2020" "memtester 4" "Maintenance Commands" .SH NAME memtester \- stress test to find memory subsystem faults. .SH SYNOPSIS @@ -97,7 +97,7 @@ Written by Charles Cazabon. Report bugs to . .PP .SH COPYRIGHT -Copyright \(co 2001-2012 Charles Cazabon +Copyright \(co 2001-2020 Charles Cazabon .br This is free software; see the file COPYING for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/memtester.c b/memtester.c index 3db2ad4..e59b037 100644 --- a/memtester.c +++ b/memtester.c @@ -6,13 +6,13 @@ * Version 2 by Charles Cazabon * Version 3 not publicly released. * Version 4 rewrite: - * Copyright (C) 2004-2012 Charles Cazabon + * Copyright (C) 2004-2020 Charles Cazabon * Licensed under the terms of the GNU General Public License version 2 (only). * See the file COPYING for details. * */ -#define __version__ "4.3.0" +#define __version__ "4.5.1" #include #include @@ -28,6 +28,7 @@ #include "types.h" #include "sizes.h" #include "tests.h" +#include "output.h" #define EXIT_FAIL_NONSTARTER 0x01 #define EXIT_FAIL_ADDRESSLINES 0x02 @@ -49,7 +50,7 @@ struct test tests[] = { { "Bit Flip", test_bitflip_comparison }, { "Walking Ones", test_walkbits1_comparison }, { "Walking Zeroes", test_walkbits0_comparison }, -#ifdef TEST_NARROW_WRITES +#ifdef TEST_NARROW_WRITES { "8-bit Writes", test_8bit_wide_random }, { "16-bit Writes", test_16bit_wide_random }, #endif @@ -102,7 +103,7 @@ off_t physaddrbase = 0; /* Function definitions */ void usage(char *me) { fprintf(stderr, "\n" - "Usage: %s [-p physaddrbase [-d device]] [B|K|M|G] [loops]\n", + "Usage: %s [-p physaddrbase [-d device] [-u]] [B|K|M|G] [loops]\n", me); exit(EXIT_FAIL_NONSTARTER); } @@ -126,16 +127,19 @@ int main(int argc, char **argv) { int device_specified = 0; char *env_testmask = 0; ul testmask = 0; + int o_flags = O_RDWR | O_SYNC; + + out_initialize(); printf("memtester version " __version__ " (%d-bit)\n", UL_LEN); - printf("Copyright (C) 2001-2012 Charles Cazabon.\n"); + printf("Copyright (C) 2001-2020 Charles Cazabon.\n"); printf("Licensed under the GNU General Public License version 2 (only).\n"); printf("\n"); check_posix_system(); pagesize = memtester_pagesize(); pagesizemask = (ptrdiff_t) ~(pagesize - 1); printf("pagesizemask is 0x%tx\n", pagesizemask); - + /* If MEMTESTER_TEST_MASK is set, we use its value as a mask of which tests we run. */ @@ -143,14 +147,14 @@ int main(int argc, char **argv) { errno = 0; testmask = strtoul(env_testmask, 0, 0); if (errno) { - fprintf(stderr, "error parsing MEMTESTER_TEST_MASK %s: %s\n", + fprintf(stderr, "error parsing MEMTESTER_TEST_MASK %s: %s\n", env_testmask, strerror(errno)); usage(argv[0]); /* doesn't return */ } printf("using testmask 0x%lx\n", testmask); } - while ((opt = getopt(argc, argv, "p:d:")) != -1) { + while ((opt = getopt(argc, argv, "p:d:u")) != -1) { switch (opt) { case 'p': errno = 0; @@ -179,12 +183,12 @@ int main(int argc, char **argv) { break; case 'd': if (stat(optarg,&statbuf)) { - fprintf(stderr, "can not use %s as device: %s\n", optarg, + fprintf(stderr, "can not use %s as device: %s\n", optarg, strerror(errno)); usage(argv[0]); /* doesn't return */ } else { if (!S_ISCHR(statbuf.st_mode)) { - fprintf(stderr, "can not mmap non-char device %s\n", + fprintf(stderr, "can not mmap non-char device %s\n", optarg); usage(argv[0]); /* doesn't return */ } else { @@ -192,18 +196,21 @@ int main(int argc, char **argv) { device_specified = 1; } } - break; + break; + case 'u': + o_flags &= ~O_SYNC; + break; default: /* '?' */ usage(argv[0]); /* doesn't return */ } } if (device_specified && !use_phys) { - fprintf(stderr, + fprintf(stderr, "for mem device, physaddrbase (-p) must be specified\n"); usage(argv[0]); /* doesn't return */ } - + if (optind >= argc) { fprintf(stderr, "need memory argument, in MB\n"); usage(argv[0]); /* doesn't return */ @@ -271,7 +278,7 @@ int main(int argc, char **argv) { buf = NULL; if (use_phys) { - memfd = open(device_name, O_RDWR | O_SYNC); + memfd = open(device_name, o_flags); if (memfd == -1) { fprintf(stderr, "failed to open %s for physical memory: %s\n", device_name, strerror(errno)); @@ -359,6 +366,19 @@ int main(int argc, char **argv) { if (!do_mlock) fprintf(stderr, "Continuing with unlocked memory; testing " "will be slower and less reliable.\n"); + /* Do alighnment here as well, as some cases won't trigger above if you + define out the use of mlock() (cough HP/UX 10 cough). */ + if ((size_t) buf % pagesize) { + /* printf("aligning to page -- was 0x%tx\n", buf); */ + aligned = (void volatile *) ((size_t) buf & pagesizemask) + pagesize; + /* printf(" now 0x%tx -- lost %d bytes\n", aligned, + * (size_t) aligned - (size_t) buf); + */ + bufsize -= ((size_t) aligned - (size_t) buf); + } else { + aligned = buf; + } + halflen = bufsize / 2; count = halflen / sizeof(ul); bufa = (ulv *) aligned; @@ -386,12 +406,15 @@ int main(int argc, char **argv) { continue; } printf(" %-20s: ", tests[i].name); + fflush(stdout); if (!tests[i].fp(bufa, bufb, count)) { printf("ok\n"); } else { exit_code |= EXIT_FAIL_OTHERTEST; } fflush(stdout); + /* clear buffer */ + memset((void *) buf, 255, wantbytes); } printf("\n"); fflush(stdout); diff --git a/memtester.h b/memtester.h index 229bca3..688e241 100644 --- a/memtester.h +++ b/memtester.h @@ -4,7 +4,7 @@ * Version 2 by Charles Cazabon * Version 3 not publicly released. * Version 4 rewrite: - * Copyright (C) 2004-2012 Charles Cazabon + * Copyright (C) 2004-2020 Charles Cazabon * Licensed under the terms of the GNU General Public License version 2 (only). * See the file COPYING for details. * @@ -19,4 +19,3 @@ extern int use_phys; extern off_t physaddrbase; - diff --git a/output.c b/output.c new file mode 100644 index 0000000..a55c491 --- /dev/null +++ b/output.c @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2022 Luca Ceresoli + * + * Output routines to conditionally show testing status. + * + * out_initialize() must be called at program startup and disabled status + * output if stdout is not a tty. The other functions print test progress, + * but only if on a tty. + */ + +#include +#include + +#include "output.h" + +static int show_progress = 1; +static int wheel_pos; + +void out_initialize() +{ + show_progress = isatty(STDOUT_FILENO); +} + +void out_test_start() +{ + if (show_progress) { + printf(" "); + fflush(stdout); + } +} + +void out_test_setting(unsigned int j) +{ + if (show_progress) { + printf("\b\b\b\b\b\b\b\b\b\b\b"); + printf("setting %3u", j); + fflush(stdout); + } +} + +void out_test_testing(unsigned int j) +{ + if (show_progress) { + printf("\b\b\b\b\b\b\b\b\b\b\b"); + printf("testing %3u", j); + fflush(stdout); + } +} + +void out_test_end() +{ + if (show_progress) { + printf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b"); + fflush(stdout); + } +} + +void out_wheel_start() +{ + if (show_progress) { + putchar(' '); + fflush(stdout); + wheel_pos = 0; + } +} + +void out_wheel_advance(unsigned int i) +{ + static const unsigned int wheel_often = 2500; + static const unsigned int n_chars = 4; + char wheel_char[4] = {'-', '\\', '|', '/'}; + + if (show_progress) { + if (!(i % wheel_often)) { + putchar('\b'); + putchar(wheel_char[++wheel_pos % n_chars]); + fflush(stdout); + } + } +} + +void out_wheel_end() +{ + if (show_progress) { + printf("\b \b"); + fflush(stdout); + } +} diff --git a/output.h b/output.h new file mode 100644 index 0000000..8648272 --- /dev/null +++ b/output.h @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2022 Luca Ceresoli + * + * Output routines to conditionally show testing status. + */ + +#ifndef _OUTPUT_H_ +#define _OUTPUT_H_ + +void out_initialize(); + +void out_test_start(); +void out_test_setting(); +void out_test_testing(); +void out_test_end(); + +void out_wheel_start(); +void out_wheel_advance(); +void out_wheel_end(); + +#endif // _OUTPUT_H_ diff --git a/sizes.h b/sizes.h index cd1c3ad..4d9d8e4 100644 --- a/sizes.h +++ b/sizes.h @@ -34,5 +34,3 @@ #else #error long on this platform is not 32 or 64 bits #endif - - diff --git a/tests.c b/tests.c index be1b350..735c3d7 100644 --- a/tests.c +++ b/tests.c @@ -4,7 +4,7 @@ * Version 2 by Charles Cazabon * Version 3 not publicly released. * Version 4 rewrite: - * Copyright (C) 2004-2012 Charles Cazabon + * Copyright (C) 2004-2020 Charles Cazabon * Licensed under the terms of the GNU General Public License version 2 (only). * See the file COPYING for details. * @@ -21,12 +21,20 @@ #include "types.h" #include "sizes.h" #include "memtester.h" +#include "output.h" -char progress[] = "-\\|/"; -#define PROGRESSLEN 4 -#define PROGRESSOFTEN 2500 #define ONE 0x00000001L +union { + unsigned char bytes[UL_LEN/8]; + ul val; +} mword8; + +union { + unsigned short u16s[UL_LEN/16]; + ul val; +} mword16; + /* Function definitions. */ int compare_regions(ulv *bufa, ulv *bufb, size_t count) { @@ -40,13 +48,13 @@ int compare_regions(ulv *bufa, ulv *bufb, size_t count) { if (*p1 != *p2) { if (use_phys) { physaddr = physaddrbase + (i * sizeof(ul)); - fprintf(stderr, + fprintf(stderr, "FAILURE: 0x%08lx != 0x%08lx at physical address " - "0x%08lx.\n", + "0x%08lx.\n", (ul) *p1, (ul) *p2, physaddr); } else { - fprintf(stderr, - "FAILURE: 0x%08lx != 0x%08lx at offset 0x%08lx.\n", + fprintf(stderr, + "FAILURE: 0x%08lx != 0x%08lx at offset 0x%08lx.\n", (ul) *p1, (ul) *p2, (ul) (i * sizeof(ul))); } /* printf("Skipping to next test..."); */ @@ -62,33 +70,28 @@ int test_stuck_address(ulv *bufa, size_t count) { size_t i; off_t physaddr; - printf(" "); - fflush(stdout); + out_test_start(); for (j = 0; j < 16; j++) { - printf("\b\b\b\b\b\b\b\b\b\b\b"); p1 = (ulv *) bufa; - printf("setting %3u", j); - fflush(stdout); + out_test_setting(j); for (i = 0; i < count; i++) { *p1 = ((j + i) % 2) == 0 ? (ul) p1 : ~((ul) p1); *p1++; } - printf("\b\b\b\b\b\b\b\b\b\b\b"); - printf("testing %3u", j); - fflush(stdout); + out_test_testing(j); p1 = (ulv *) bufa; for (i = 0; i < count; i++, p1++) { if (*p1 != (((j + i) % 2) == 0 ? (ul) p1 : ~((ul) p1))) { if (use_phys) { physaddr = physaddrbase + (i * sizeof(ul)); - fprintf(stderr, + fprintf(stderr, "FAILURE: possible bad address line at physical " - "address 0x%08lx.\n", + "address 0x%08lx.\n", physaddr); } else { - fprintf(stderr, + fprintf(stderr, "FAILURE: possible bad address line at offset " - "0x%08lx.\n", + "0x%08lx.\n", (ul) (i * sizeof(ul))); } printf("Skipping to next test...\n"); @@ -97,29 +100,21 @@ int test_stuck_address(ulv *bufa, size_t count) { } } } - printf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b"); - fflush(stdout); + out_test_end(); return 0; } int test_random_value(ulv *bufa, ulv *bufb, size_t count) { ulv *p1 = bufa; ulv *p2 = bufb; - ul j = 0; size_t i; - putchar(' '); - fflush(stdout); + out_wheel_start(); for (i = 0; i < count; i++) { *p1++ = *p2++ = rand_ul(); - if (!(i % PROGRESSOFTEN)) { - putchar('\b'); - putchar(progress[++j % PROGRESSLEN]); - fflush(stdout); - } + out_wheel_advance(i); } - printf("\b \b"); - fflush(stdout); + out_wheel_end(); return compare_regions(bufa, bufb, count); } @@ -223,27 +218,21 @@ int test_solidbits_comparison(ulv *bufa, ulv *bufb, size_t count) { ul q; size_t i; - printf(" "); - fflush(stdout); + out_test_start(); for (j = 0; j < 64; j++) { - printf("\b\b\b\b\b\b\b\b\b\b\b"); q = (j % 2) == 0 ? UL_ONEBITS : 0; - printf("setting %3u", j); - fflush(stdout); + out_test_setting(j); p1 = (ulv *) bufa; p2 = (ulv *) bufb; for (i = 0; i < count; i++) { *p1++ = *p2++ = (i % 2) == 0 ? q : ~q; } - printf("\b\b\b\b\b\b\b\b\b\b\b"); - printf("testing %3u", j); - fflush(stdout); + out_test_testing(j); if (compare_regions(bufa, bufb, count)) { return -1; } } - printf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b"); - fflush(stdout); + out_test_end(); return 0; } @@ -254,27 +243,21 @@ int test_checkerboard_comparison(ulv *bufa, ulv *bufb, size_t count) { ul q; size_t i; - printf(" "); - fflush(stdout); + out_test_start(); for (j = 0; j < 64; j++) { - printf("\b\b\b\b\b\b\b\b\b\b\b"); q = (j % 2) == 0 ? CHECKERBOARD1 : CHECKERBOARD2; - printf("setting %3u", j); - fflush(stdout); + out_test_setting(j); p1 = (ulv *) bufa; p2 = (ulv *) bufb; for (i = 0; i < count; i++) { *p1++ = *p2++ = (i % 2) == 0 ? q : ~q; } - printf("\b\b\b\b\b\b\b\b\b\b\b"); - printf("testing %3u", j); - fflush(stdout); + out_test_testing(j); if (compare_regions(bufa, bufb, count)) { return -1; } } - printf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b"); - fflush(stdout); + out_test_end(); return 0; } @@ -284,26 +267,20 @@ int test_blockseq_comparison(ulv *bufa, ulv *bufb, size_t count) { unsigned int j; size_t i; - printf(" "); - fflush(stdout); + out_test_start(); for (j = 0; j < 256; j++) { - printf("\b\b\b\b\b\b\b\b\b\b\b"); p1 = (ulv *) bufa; p2 = (ulv *) bufb; - printf("setting %3u", j); - fflush(stdout); + out_test_setting(j); for (i = 0; i < count; i++) { *p1++ = *p2++ = (ul) UL_BYTE(j); } - printf("\b\b\b\b\b\b\b\b\b\b\b"); - printf("testing %3u", j); - fflush(stdout); + out_test_testing(j); if (compare_regions(bufa, bufb, count)) { return -1; } } - printf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b"); - fflush(stdout); + out_test_end(); return 0; } @@ -313,14 +290,11 @@ int test_walkbits0_comparison(ulv *bufa, ulv *bufb, size_t count) { unsigned int j; size_t i; - printf(" "); - fflush(stdout); + out_test_start(); for (j = 0; j < UL_LEN * 2; j++) { - printf("\b\b\b\b\b\b\b\b\b\b\b"); p1 = (ulv *) bufa; p2 = (ulv *) bufb; - printf("setting %3u", j); - fflush(stdout); + out_test_setting(j); for (i = 0; i < count; i++) { if (j < UL_LEN) { /* Walk it up. */ *p1++ = *p2++ = ONE << j; @@ -328,15 +302,12 @@ int test_walkbits0_comparison(ulv *bufa, ulv *bufb, size_t count) { *p1++ = *p2++ = ONE << (UL_LEN * 2 - j - 1); } } - printf("\b\b\b\b\b\b\b\b\b\b\b"); - printf("testing %3u", j); - fflush(stdout); + out_test_testing(j); if (compare_regions(bufa, bufb, count)) { return -1; } } - printf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b"); - fflush(stdout); + out_test_end(); return 0; } @@ -346,14 +317,11 @@ int test_walkbits1_comparison(ulv *bufa, ulv *bufb, size_t count) { unsigned int j; size_t i; - printf(" "); - fflush(stdout); + out_test_start(); for (j = 0; j < UL_LEN * 2; j++) { - printf("\b\b\b\b\b\b\b\b\b\b\b"); p1 = (ulv *) bufa; p2 = (ulv *) bufb; - printf("setting %3u", j); - fflush(stdout); + out_test_setting(j); for (i = 0; i < count; i++) { if (j < UL_LEN) { /* Walk it up. */ *p1++ = *p2++ = UL_ONEBITS ^ (ONE << j); @@ -361,15 +329,12 @@ int test_walkbits1_comparison(ulv *bufa, ulv *bufb, size_t count) { *p1++ = *p2++ = UL_ONEBITS ^ (ONE << (UL_LEN * 2 - j - 1)); } } - printf("\b\b\b\b\b\b\b\b\b\b\b"); - printf("testing %3u", j); - fflush(stdout); + out_test_testing(j); if (compare_regions(bufa, bufb, count)) { return -1; } } - printf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b"); - fflush(stdout); + out_test_end(); return 0; } @@ -379,14 +344,11 @@ int test_bitspread_comparison(ulv *bufa, ulv *bufb, size_t count) { unsigned int j; size_t i; - printf(" "); - fflush(stdout); + out_test_start(); for (j = 0; j < UL_LEN * 2; j++) { - printf("\b\b\b\b\b\b\b\b\b\b\b"); p1 = (ulv *) bufa; p2 = (ulv *) bufb; - printf("setting %3u", j); - fflush(stdout); + out_test_setting(j); for (i = 0; i < count; i++) { if (j < UL_LEN) { /* Walk it up. */ *p1++ = *p2++ = (i % 2 == 0) @@ -400,15 +362,12 @@ int test_bitspread_comparison(ulv *bufa, ulv *bufb, size_t count) { | (ONE << (UL_LEN * 2 + 1 - j))); } } - printf("\b\b\b\b\b\b\b\b\b\b\b"); - printf("testing %3u", j); - fflush(stdout); + out_test_testing(j); if (compare_regions(bufa, bufb, count)) { return -1; } } - printf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b"); - fflush(stdout); + out_test_end(); return 0; } @@ -419,43 +378,37 @@ int test_bitflip_comparison(ulv *bufa, ulv *bufb, size_t count) { ul q; size_t i; - printf(" "); - fflush(stdout); + out_test_start(); for (k = 0; k < UL_LEN; k++) { q = ONE << k; for (j = 0; j < 8; j++) { - printf("\b\b\b\b\b\b\b\b\b\b\b"); q = ~q; - printf("setting %3u", k * 8 + j); - fflush(stdout); + out_test_setting(k * 8 + j); p1 = (ulv *) bufa; p2 = (ulv *) bufb; for (i = 0; i < count; i++) { *p1++ = *p2++ = (i % 2) == 0 ? q : ~q; } - printf("\b\b\b\b\b\b\b\b\b\b\b"); - printf("testing %3u", k * 8 + j); + out_test_testing(k * 8 + j); fflush(stdout); if (compare_regions(bufa, bufb, count)) { return -1; } } } - printf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b"); - fflush(stdout); + out_test_end(); return 0; } -#ifdef TEST_NARROW_WRITES +#ifdef TEST_NARROW_WRITES int test_8bit_wide_random(ulv* bufa, ulv* bufb, size_t count) { u8v *p1, *t; ulv *p2; int attempt; - unsigned int b, j = 0; + unsigned int b; size_t i; - putchar(' '); - fflush(stdout); + out_wheel_start(); for (attempt = 0; attempt < 2; attempt++) { if (attempt & 1) { p1 = (u8v *) bufa; @@ -470,18 +423,13 @@ int test_8bit_wide_random(ulv* bufa, ulv* bufb, size_t count) { for (b=0; b < UL_LEN/8; b++) { *p1++ = *t++; } - if (!(i % PROGRESSOFTEN)) { - putchar('\b'); - putchar(progress[++j % PROGRESSLEN]); - fflush(stdout); - } + out_wheel_advance(i); } if (compare_regions(bufa, bufb, count)) { return -1; } } - printf("\b \b"); - fflush(stdout); + out_wheel_end(); return 0; } @@ -489,11 +437,10 @@ int test_16bit_wide_random(ulv* bufa, ulv* bufb, size_t count) { u16v *p1, *t; ulv *p2; int attempt; - unsigned int b, j = 0; + unsigned int b; size_t i; - putchar( ' ' ); - fflush( stdout ); + out_wheel_start(); for (attempt = 0; attempt < 2; attempt++) { if (attempt & 1) { p1 = (u16v *) bufa; @@ -508,18 +455,13 @@ int test_16bit_wide_random(ulv* bufa, ulv* bufb, size_t count) { for (b = 0; b < UL_LEN/16; b++) { *p1++ = *t++; } - if (!(i % PROGRESSOFTEN)) { - putchar('\b'); - putchar(progress[++j % PROGRESSLEN]); - fflush(stdout); - } + out_wheel_advance(i); } if (compare_regions(bufa, bufb, count)) { return -1; } } - printf("\b \b"); - fflush(stdout); + out_wheel_end(); return 0; } #endif diff --git a/tests.h b/tests.h index eccd47c..67c7b29 100644 --- a/tests.h +++ b/tests.h @@ -4,12 +4,12 @@ * Version 2 by Charles Cazabon * Version 3 not publicly released. * Version 4 rewrite: - * Copyright (C) 2004-2012 Charles Cazabon + * Copyright (C) 2004-2020 Charles Cazabon * Licensed under the terms of the GNU General Public License version 2 (only). * See the file COPYING for details. * * This file contains the declarations for the functions for the actual tests, - * called from the main routine in memtester.c. See other comments in that + * called from the main routine in memtester.c. See other comments in that * file. * */ @@ -32,8 +32,7 @@ int test_walkbits0_comparison(unsigned long volatile *bufa, unsigned long volati int test_walkbits1_comparison(unsigned long volatile *bufa, unsigned long volatile *bufb, size_t count); int test_bitspread_comparison(unsigned long volatile *bufa, unsigned long volatile *bufb, size_t count); int test_bitflip_comparison(unsigned long volatile *bufa, unsigned long volatile *bufb, size_t count); -#ifdef TEST_NARROW_WRITES +#ifdef TEST_NARROW_WRITES int test_8bit_wide_random(unsigned long volatile *bufa, unsigned long volatile *bufb, size_t count); int test_16bit_wide_random(unsigned long volatile *bufa, unsigned long volatile *bufb, size_t count); #endif - diff --git a/types.h b/types.h index ad7ce73..4cb41c3 100644 --- a/types.h +++ b/types.h @@ -4,7 +4,7 @@ * Version 2 by Charles Cazabon * Version 3 not publicly released. * Version 4 rewrite: - * Copyright (C) 2004-2010 Charles Cazabon + * Copyright (C) 2004-2020 Charles Cazabon * Licensed under the terms of the GNU General Public License version 2 (only). * See the file COPYING for details. * @@ -24,13 +24,3 @@ struct test { char *name; int (*fp)(); }; - -union { - unsigned char bytes[UL_LEN/8]; - ul val; -} mword8; - -union { - unsigned short u16s[UL_LEN/16]; - ul val; -} mword16; diff --git a/warn-auto.sh b/warn-auto.sh old mode 100644 new mode 100755