1a6d24dfbd
git-svn-id: svn://svn.openwrt.org/openwrt/packages@17829 3c298f89-4303-0410-b956-a3cf2f4a3e73
332 lines
10 KiB
Diff
332 lines
10 KiB
Diff
--- a/memtester.c
|
|
+++ b/memtester.c
|
|
@@ -123,7 +123,7 @@ int main(int argc, char **argv) {
|
|
pagesizemask = (ptrdiff_t) ~(pagesize - 1);
|
|
printf("pagesizemask is 0x%tx\n", pagesizemask);
|
|
|
|
- while ((opt = getopt(argc, argv, "p:")) != -1) {
|
|
+ while ((opt = getopt(argc, argv, "qp:")) != -1) {
|
|
switch (opt) {
|
|
case 'p':
|
|
errno = 0;
|
|
@@ -150,6 +150,9 @@ int main(int argc, char **argv) {
|
|
/* okay, got address */
|
|
use_phys = 1;
|
|
break;
|
|
+ case 'q':
|
|
+ quiet = 1;
|
|
+ break;
|
|
default: /* '?' */
|
|
usage(argv[0]); /* doesn't return */
|
|
}
|
|
--- a/tests.c
|
|
+++ b/tests.c
|
|
@@ -17,12 +17,23 @@
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <limits.h>
|
|
+#include <stdarg.h>
|
|
|
|
#include "types.h"
|
|
#include "sizes.h"
|
|
#include "memtester.h"
|
|
|
|
+int quiet = 0;
|
|
char progress[] = "-\\|/";
|
|
+
|
|
+void inline dprintf(const char *format, ...) {
|
|
+ if(!quiet) {
|
|
+ va_list ap;
|
|
+ va_start(ap, format);
|
|
+ vprintf(format, ap);
|
|
+ }
|
|
+}
|
|
+
|
|
#define PROGRESSLEN 4
|
|
#define PROGRESSOFTEN 2500
|
|
|
|
@@ -64,16 +75,16 @@ int test_stuck_address(ulv *bufa, size_t
|
|
printf(" ");
|
|
fflush(stdout);
|
|
for (j = 0; j < 16; j++) {
|
|
- printf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
p1 = (ulv *) bufa;
|
|
- printf("setting %3u", j);
|
|
+ dprintf("setting %3u", j);
|
|
fflush(stdout);
|
|
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);
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("testing %3u", j);
|
|
fflush(stdout);
|
|
p1 = (ulv *) bufa;
|
|
for (i = 0; i < count; i++, p1++) {
|
|
@@ -96,7 +107,7 @@ int test_stuck_address(ulv *bufa, size_t
|
|
}
|
|
}
|
|
}
|
|
- printf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b");
|
|
fflush(stdout);
|
|
return 0;
|
|
}
|
|
@@ -111,13 +122,13 @@ int test_random_value(ulv *bufa, ulv *bu
|
|
fflush(stdout);
|
|
for (i = 0; i < count; i++) {
|
|
*p1++ = *p2++ = rand_ul();
|
|
- if (!(i % PROGRESSOFTEN)) {
|
|
+ if (!quiet && !(i % PROGRESSOFTEN)) {
|
|
putchar('\b');
|
|
putchar(progress[++j % PROGRESSLEN]);
|
|
fflush(stdout);
|
|
}
|
|
}
|
|
- printf("\b \b");
|
|
+ dprintf("\b \b");
|
|
fflush(stdout);
|
|
return compare_regions(bufa, bufb, count);
|
|
}
|
|
@@ -225,23 +236,23 @@ int test_solidbits_comparison(ulv *bufa,
|
|
printf(" ");
|
|
fflush(stdout);
|
|
for (j = 0; j < 64; j++) {
|
|
- printf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
q = (j % 2) == 0 ? UL_ONEBITS : 0;
|
|
- printf("setting %3u", j);
|
|
+ dprintf("setting %3u", j);
|
|
fflush(stdout);
|
|
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);
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("testing %3u", 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");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b");
|
|
fflush(stdout);
|
|
return 0;
|
|
}
|
|
@@ -256,23 +267,23 @@ int test_checkerboard_comparison(ulv *bu
|
|
printf(" ");
|
|
fflush(stdout);
|
|
for (j = 0; j < 64; j++) {
|
|
- printf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
q = (j % 2) == 0 ? CHECKERBOARD1 : CHECKERBOARD2;
|
|
- printf("setting %3u", j);
|
|
+ dprintf("setting %3u", j);
|
|
fflush(stdout);
|
|
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);
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("testing %3u", 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");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b");
|
|
fflush(stdout);
|
|
return 0;
|
|
}
|
|
@@ -283,25 +294,25 @@ int test_blockseq_comparison(ulv *bufa,
|
|
unsigned int j;
|
|
size_t i;
|
|
|
|
- printf(" ");
|
|
+ dprintf(" ");
|
|
fflush(stdout);
|
|
for (j = 0; j < 256; j++) {
|
|
- printf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
p1 = (ulv *) bufa;
|
|
p2 = (ulv *) bufb;
|
|
- printf("setting %3u", j);
|
|
+ dprintf("setting %3u", j);
|
|
fflush(stdout);
|
|
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);
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("testing %3u", 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");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b");
|
|
fflush(stdout);
|
|
return 0;
|
|
}
|
|
@@ -315,10 +326,10 @@ int test_walkbits0_comparison(ulv *bufa,
|
|
printf(" ");
|
|
fflush(stdout);
|
|
for (j = 0; j < UL_LEN * 2; j++) {
|
|
- printf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
p1 = (ulv *) bufa;
|
|
p2 = (ulv *) bufb;
|
|
- printf("setting %3u", j);
|
|
+ dprintf("setting %3u", j);
|
|
fflush(stdout);
|
|
for (i = 0; i < count; i++) {
|
|
if (j < UL_LEN) { /* Walk it up. */
|
|
@@ -327,14 +338,14 @@ int test_walkbits0_comparison(ulv *bufa,
|
|
*p1++ = *p2++ = 0x00000001 << (UL_LEN * 2 - j - 1);
|
|
}
|
|
}
|
|
- printf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
- printf("testing %3u", j);
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("testing %3u", 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");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b");
|
|
fflush(stdout);
|
|
return 0;
|
|
}
|
|
@@ -345,13 +356,13 @@ int test_walkbits1_comparison(ulv *bufa,
|
|
unsigned int j;
|
|
size_t i;
|
|
|
|
- printf(" ");
|
|
+ dprintf(" ");
|
|
fflush(stdout);
|
|
for (j = 0; j < UL_LEN * 2; j++) {
|
|
- printf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
p1 = (ulv *) bufa;
|
|
p2 = (ulv *) bufb;
|
|
- printf("setting %3u", j);
|
|
+ dprintf("setting %3u", j);
|
|
fflush(stdout);
|
|
for (i = 0; i < count; i++) {
|
|
if (j < UL_LEN) { /* Walk it up. */
|
|
@@ -360,14 +371,14 @@ int test_walkbits1_comparison(ulv *bufa,
|
|
*p1++ = *p2++ = UL_ONEBITS ^ (0x00000001 << (UL_LEN * 2 - j - 1));
|
|
}
|
|
}
|
|
- printf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
- printf("testing %3u", j);
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("testing %3u", 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");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b");
|
|
fflush(stdout);
|
|
return 0;
|
|
}
|
|
@@ -378,13 +389,13 @@ int test_bitspread_comparison(ulv *bufa,
|
|
unsigned int j;
|
|
size_t i;
|
|
|
|
- printf(" ");
|
|
+ dprintf(" ");
|
|
fflush(stdout);
|
|
for (j = 0; j < UL_LEN * 2; j++) {
|
|
- printf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
p1 = (ulv *) bufa;
|
|
p2 = (ulv *) bufb;
|
|
- printf("setting %3u", j);
|
|
+ dprintf("setting %3u", j);
|
|
fflush(stdout);
|
|
for (i = 0; i < count; i++) {
|
|
if (j < UL_LEN) { /* Walk it up. */
|
|
@@ -399,14 +410,14 @@ int test_bitspread_comparison(ulv *bufa,
|
|
| (0x00000001 << (UL_LEN * 2 + 1 - j)));
|
|
}
|
|
}
|
|
- printf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
- printf("testing %3u", j);
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("testing %3u", 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");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b");
|
|
fflush(stdout);
|
|
return 0;
|
|
}
|
|
@@ -418,29 +429,29 @@ int test_bitflip_comparison(ulv *bufa, u
|
|
ul q;
|
|
size_t i;
|
|
|
|
- printf(" ");
|
|
+ dprintf(" ");
|
|
fflush(stdout);
|
|
for (k = 0; k < UL_LEN; k++) {
|
|
q = 0x00000001 << k;
|
|
for (j = 0; j < 8; j++) {
|
|
- printf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
q = ~q;
|
|
- printf("setting %3u", k * 8 + j);
|
|
+ dprintf("setting %3u", k * 8 + j);
|
|
fflush(stdout);
|
|
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);
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b");
|
|
+ dprintf("testing %3u", 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");
|
|
+ dprintf("\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b");
|
|
fflush(stdout);
|
|
return 0;
|
|
}
|
|
--- a/tests.h
|
|
+++ b/tests.h
|
|
@@ -14,6 +14,8 @@
|
|
*
|
|
*/
|
|
|
|
+extern int quiet;
|
|
+
|
|
/* Function declaration. */
|
|
|
|
int test_stuck_address(unsigned long volatile *bufa, size_t count);
|