blob: fd54ba768138642dd3f6d67574a13546ba42e677 [file] [log] [blame]
diff -aruN a/memtester.c b/memtester.c
--- a/memtester.c 2017-04-13 12:13:53.101455795 -0700
+++ b/memtester.c 2017-04-13 12:21:38.423324655 -0700
@@ -100,7 +100,9 @@
/* Function definitions */
void usage(char *me) {
- fprintf(stderr, "\nUsage: %s [-p physaddrbase] <mem>[B|K|M|G] [loops]\n", me);
+ fprintf(stderr, "\nUsage: %s [-e] [-p physaddrbase] <mem>[B|K|M|G] [loops]\n", me);
+ fprintf(stderr, "Arguments:\n");
+ fprintf(stderr, " -e Exit on error.\n");
exit(EXIT_FAIL_NONSTARTER);
}
@@ -113,6 +115,7 @@
void volatile *buf, *aligned;
ulv *bufa, *bufb;
int do_mlock = 1, done_mem = 0;
+ int exit_on_err = 0;
int exit_code = 0;
int memfd, opt, memshift;
size_t maxbytes = -1; /* addressable memory, in bytes */
@@ -127,7 +130,7 @@
pagesizemask = (ptrdiff_t) ~(pagesize - 1);
printf("pagesizemask is 0x%tx\n", pagesizemask);
- while ((opt = getopt(argc, argv, "p:")) != -1) {
+ while ((opt = getopt(argc, argv, "ep:")) != -1) {
switch (opt) {
case 'p':
errno = 0;
@@ -154,6 +157,9 @@
/* okay, got address */
use_phys = 1;
break;
+ case 'e':
+ exit_on_err = 1;
+ break;
default: /* '?' */
usage(argv[0]); /* doesn't return */
}
@@ -322,6 +328,7 @@
if (!test_stuck_address(aligned, bufsize / sizeof(ul))) {
printf("ok\n");
} else {
+ printf("fail\n");
exit_code |= EXIT_FAIL_ADDRESSLINES;
}
for (i=0;;i++) {
@@ -330,12 +337,16 @@
if (!tests[i].fp(bufa, bufb, count)) {
printf("ok\n");
} else {
+ printf("fail\n");
exit_code |= EXIT_FAIL_OTHERTEST;
}
fflush(stdout);
}
printf("\n");
fflush(stdout);
+ if (exit_on_err && (exit_code != 0)) {
+ break;
+ }
}
if (do_mlock) munlock((void *) aligned, bufsize);
printf("Done.\n");