commands: mtest: add iteration count parameter for mtest command
PATCH 1/1 commands: mtest: add iteration count parameter for mtest command
The number of test iterations can be specified so that the test does not continue forever without manual intervention.
This enables better use of mtest via scripts.
--- commands/memtest.c | 30 +++++++++++++++++++----------- 1 files changed, 19 insertions(+), 11 deletions(-)
commands/memtest.c +19 -11
@@ -34,7 +34,7 @@* sub-tests. */ #ifdef CONFIG_CMD_MTEST_ALTERNATIVE -static int mem_test (ulong _start,ulong _end,ulong pattern_unused) +static int mem_test (ulong _start,ulong _end,ulong pattern_unused,ulong iter_count) {vu_long *start = (vu_long *)_start;vu_long *end = (vu_long *)_end;
@@ -68,13 +68,17 @@ static int mem_test(ulong _start, ulong _end, ulong pattern_unused) };/* XXX: enforce alignment of start and end? */ -for (;;) { +while (!iter_count || (iterations <= iter_count)) {if (ctrlc ()) {putchar ('\n' );return 1 ; } -printf ("Iteration: %6d\r" , iterations); +printf ("Iteration: %6d" , iterations); +if (iter_count) +printf (" of %6lu" , iter_count); +printf ("\r" ); + iterations++;/*
@@ -262,9 +266,10 @@ static int mem_test(ulong _start, ulong _end, ulong pattern_unused) } } +return 0 ; }#else -static int mem_test (ulong _start,ulong _end,ulong pattern) +static int mem_test (ulong _start,ulong _end,ulong pattern,ulong iter_count) {vu_long *addr;vu_long *start = (vu_long *)_start;
@@ -273,9 +278,10 @@ static int mem_test(ulong _start, ulong _end, ulong pattern)ulong readback;ulong incr;int rcode; +int iterations =1 ; incr =1 ; -for (;;) { +while (!iter_count || (iterations <= iter_count)) {if (ctrlc ()) {putchar ('\n' );return 1 ;
@@ -317,6 +323,8 @@ static int mem_test(ulong _start, ulong _end, ulong pattern) pattern = ~pattern; } incr = -incr; + + ++iterations; }return rcode; }
@@ -324,7 +332,7 @@ static int mem_test(ulong _start, ulong _end, ulong pattern)static int do_mem_mtest (int argc,char *argv[]) { -ulong start, end, pattern =0 ; +ulong start, end, pattern =0 , iterations =0 ;if (argc <3 )return COMMAND_ERROR_USAGE ;
@@ -335,16 +343,16 @@ static int do_mem_mtest(int argc, char *argv[])if (argc >3 ) pattern =simple_strtoul (argv[3 ],NULL ,0 ); +if (argc >4 ) + iterations =simple_strtoul (argv[4 ],NULL ,0 ); +printf ("Testing 0x%08x ... 0x%08x:\n" , (uint )start, (uint )end); -return mem_test (start, end, pattern); +return mem_test (start, end, pattern, iterations); }static const __maybe_unused char cmd_mtest_help[] = -"Usage: <start> <end> " -#ifdef CONFIG_CMD_MTEST_ALTERNATIVE -"[pattern]" -#endif +"Usage: <start> <end> [pattern] [iterations]" "\nsimple RAM read/write test\n" ;BAREBOX_CMD_START (mtest)
Signature · 7 lines
1.7.7 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi,
I actually work on a patch series to improve|rewrite the memtest command. This will add a iteration argument, too.
I will try to find some time this weekend to make it done.
Regards
Alexander Aring
2013/1/12 Marc Reilly <[email protected]>
Quoted 102 lines
The number of test iterations can be specified so that the test does not continue forever without manual intervention.
This enables better use of mtest via scripts.
Signed-off-by Marc Reilly <[email protected]>--- commands/memtest.c | 30 +++++++++++++++++++----------- 1 files changed, 19 insertions(+), 11 deletions(-)commands/memtest.c +1
-1@@ -34,7 +34,7 @@* sub-tests. */ #ifdef CONFIG_CMD_MTEST_ALTERNATIVE -static int mem_test (ulong _start,ulong _end,ulong pattern_unused) +static int mem_test (ulong _start,ulong _end,ulong pattern_unused,ulong iter_count) {vu_long *start = (vu_long *)_start;vu_long *end = (vu_long *)_end;commands/memtest.c +6
-2@@ -68,13 +68,17 @@ static int mem_test(ulong _start, ulong _end, ulong pattern_unused) };/* XXX: enforce alignment of start and end? */ -for (;;) { +while (!iter_count || (iterations <= iter_count)) {if (ctrlc ()) {putchar ('\n' );return 1 ; } -printf ("Iteration: %6d\r" , iterations); +printf ("Iteration: %6d" , iterations); +if (iter_count) +printf (" of %6lu" , iter_count); +printf ("\r" ); + iterations++;/*commands/memtest.c +2
-1@@ -262,9 +266,10 @@ static int mem_test(ulong _start, ulong _end, ulong pattern_unused) } } +return 0 ; }#else -static int mem_test (ulong _start,ulong _end,ulong pattern) +static int mem_test (ulong _start,ulong _end,ulong pattern,ulong iter_count) {vu_long *addr; vu_long *start = (vu_long *)_start;commands/memtest.c +2
-1@@ -273,9 +278,10 @@ static int mem_test(ulong _start, ulong _end, ulong pattern) ulong readback;ulong incr;int rcode; +int iterations =1 ; incr =1 ; -for (;;) { +while (!iter_count || (iterations <= iter_count)) {if (ctrlc ()) {putchar ('\n' );return 1;commands/memtest.c +2
-0@@ -317,6 +323,8 @@ static int mem_test(ulong _start, ulong _end, ulong pattern) pattern = ~pattern; } incr = -incr; + + ++iterations; }return rcode;}
commands/memtest.c +1
-1@@ -324,7 +332,7 @@ static int mem_test(ulong _start, ulong _end, ulong pattern) static int do_mem_mtest(int argc, char *argv[]) { -ulong start, end, pattern =0 ; +ulong start, end, pattern =0 , iterations =0 ;if (argc <3 )return COMMAND_ERROR_USAGE;commands/memtest.c +3
-1@@ -335,16 +343,16 @@ static int do_mem_mtest(int argc, char *argv[])if (argc >3 ) pattern =simple_strtoul (argv[3 ],NULL ,0 ); +if (argc >4 ) + iterations =simple_strtoul (argv[4 ],NULL ,0 ); +printf ("Testing 0x%08x ... 0x%08x:\n" , (uint )start, (uint )end); -return mem_test (start, end, pattern);
commands/memtest.c static int do_mem_mtest(int argc, char *argv[]) · line 356
Quoted 10 lines
commands/memtest.c +2
-4+return mem_test (start, end, pattern, iterations); }static const __maybe_unused char cmd_mtest_help[] = -"Usage: <start> <end> " -#ifdef CONFIG_CMD_MTEST_ALTERNATIVE -"[pattern]" -#endif +"Usage: <start> <end> [pattern] [iterations]"
What's with [pattern]?
It's only available in MTEST_ALTERNATIVE.
Quoted 7 lines
commands/memtest.c +0
-0"\nsimple RAM read/write test\n" ;
BAREBOX_CMD_START(mtest)
--
1.7.7
Quoted 5 lines
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox