<div dir="ltr">Hi,<br><br>I actually work on a patch series to improve|rewrite the memtest command.<br>This will add a iteration argument, too.<br><br>I will try to find some time this weekend to make it done.<br><div class="gmail_extra">
<br>Regards<br>Alexander Aring<br><br><div class="gmail_quote">2013/1/12 Marc Reilly <span dir="ltr"><<a href="mailto:marc@cpdesign.com.au" target="_blank">marc@cpdesign.com.au</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The number of test iterations can be specified so that the test<br>
does not continue forever without manual intervention.<br>
<br>
This enables better use of mtest via scripts.<br>
<br>
Signed-off-by: Marc Reilly <<a href="mailto:marc@cpdesign.com.au">marc@cpdesign.com.au</a>><br>
---<br>
 commands/memtest.c |   30 +++++++++++++++++++-----------<br>
 1 files changed, 19 insertions(+), 11 deletions(-)<br>
<br>
diff --git a/commands/memtest.c b/commands/memtest.c<br>
index 651a195..f3fe5e5 100644<br>
--- a/commands/memtest.c<br>
+++ b/commands/memtest.c<br>
@@ -34,7 +34,7 @@<br>
  * sub-tests.<br>
  */<br>
 #ifdef CONFIG_CMD_MTEST_ALTERNATIVE<br>
-static int mem_test(ulong _start, ulong _end, ulong pattern_unused)<br>
+static int mem_test(ulong _start, ulong _end, ulong pattern_unused, ulong iter_count)<br>
 {<br>
        vu_long *start = (vu_long *)_start;<br>
        vu_long *end   = (vu_long *)_end;<br>
@@ -68,13 +68,17 @@ static int mem_test(ulong _start, ulong _end, ulong pattern_unused)<br>
        };<br>
<br>
        /* XXX: enforce alignment of start and end? */<br>
-       for (;;) {<br>
+       while (!iter_count || (iterations <= iter_count)) {<br>
                if (ctrlc()) {<br>
                        putchar ('\n');<br>
                        return 1;<br>
                }<br>
<br>
-               printf("Iteration: %6d\r", iterations);<br>
+               printf("Iteration: %6d", iterations);<br>
+               if (iter_count)<br>
+                       printf(" of %6lu", iter_count);<br>
+               printf("\r");<br>
+<br>
                iterations++;<br>
<br>
                /*<br>
@@ -262,9 +266,10 @@ static int mem_test(ulong _start, ulong _end, ulong pattern_unused)<br>
                }<br>
        }<br>
<br>
+       return 0;<br>
 }<br>
 #else<br>
-static int mem_test(ulong _start, ulong _end, ulong pattern)<br>
+static int mem_test(ulong _start, ulong _end, ulong pattern, ulong iter_count)<br>
 {<br>
        vu_long *addr;<br>
        vu_long *start = (vu_long *)_start;<br>
@@ -273,9 +278,10 @@ static int mem_test(ulong _start, ulong _end, ulong pattern)<br>
        ulong   readback;<br>
        ulong   incr;<br>
        int rcode;<br>
+       int iterations = 1;<br>
<br>
        incr = 1;<br>
-       for (;;) {<br>
+       while (!iter_count || (iterations <= iter_count)) {<br>
                if (ctrlc()) {<br>
                        putchar('\n');<br>
                        return 1;<br>
@@ -317,6 +323,8 @@ static int mem_test(ulong _start, ulong _end, ulong pattern)<br>
                        pattern = ~pattern;<br>
                }<br>
                incr = -incr;<br>
+<br>
+               ++iterations;<br>
        }<br>
        return rcode;<br>
 }<br>
@@ -324,7 +332,7 @@ static int mem_test(ulong _start, ulong _end, ulong pattern)<br>
<br>
 static int do_mem_mtest(int argc, char *argv[])<br>
 {<br>
-       ulong start, end, pattern = 0;<br>
+       ulong start, end, pattern = 0, iterations = 0;<br>
<br>
        if (argc < 3)<br>
                return COMMAND_ERROR_USAGE;<br>
@@ -335,16 +343,16 @@ static int do_mem_mtest(int argc, char *argv[])<br>
        if (argc > 3)<br>
                pattern = simple_strtoul(argv[3], NULL, 0);<br>
<br>
+       if (argc > 4)<br>
+               iterations = simple_strtoul(argv[4], NULL, 0);<br>
+<br>
        printf ("Testing 0x%08x ... 0x%08x:\n", (uint)start, (uint)end);<br>
<br>
-       return mem_test(start, end, pattern);<br>
+       return mem_test(start, end, pattern, iterations);<br>
 }<br>
<br>
 static const __maybe_unused char cmd_mtest_help[] =<br>
-"Usage: <start> <end> "<br>
-#ifdef CONFIG_CMD_MTEST_ALTERNATIVE<br>
-"[pattern]"<br>
-#endif<br>
+"Usage: <start> <end> [pattern] [iterations]"<br></blockquote><div><br>What's with [pattern]?<br>It's only available in MTEST_ALTERNATIVE.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

 "\nsimple RAM read/write test\n";<br>
<br>
 BAREBOX_CMD_START(mtest)<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.7<br>
<br>
<br>
_______________________________________________<br>
barebox mailing list<br>
<a href="mailto:barebox@lists.infradead.org">barebox@lists.infradead.org</a><br>
<a href="http://lists.infradead.org/mailman/listinfo/barebox" target="_blank">http://lists.infradead.org/mailman/listinfo/barebox</a><br>
</font></span></blockquote></div><br></div></div>