mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] commands: mtest: add iteration count parameter for mtest command
@ 2013-01-12  7:45 Marc Reilly
  2013-01-12  9:06 ` Alexander Aring
  0 siblings, 1 reply; 2+ messages in thread
From: Marc Reilly @ 2013-01-12  7:45 UTC (permalink / raw)
  To: barebox

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 <marc@cpdesign.com.au>
---
 commands/memtest.c |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/commands/memtest.c b/commands/memtest.c
index 651a195..f3fe5e5 100644
--- a/commands/memtest.c
+++ b/commands/memtest.c
@@ -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)
-- 
1.7.7


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] commands: mtest: add iteration count parameter for mtest command
  2013-01-12  7:45 [PATCH] commands: mtest: add iteration count parameter for mtest command Marc Reilly
@ 2013-01-12  9:06 ` Alexander Aring
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Aring @ 2013-01-12  9:06 UTC (permalink / raw)
  To: Marc Reilly; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 4074 bytes --]

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 <marc@cpdesign.com.au>

> 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 <marc@cpdesign.com.au>
> ---
>  commands/memtest.c |   30 +++++++++++++++++++-----------
>  1 files changed, 19 insertions(+), 11 deletions(-)
>
> diff --git a/commands/memtest.c b/commands/memtest.c
> index 651a195..f3fe5e5 100644
> --- a/commands/memtest.c
> +++ b/commands/memtest.c
> @@ -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]"
>

What's with [pattern]?
It's only available in MTEST_ALTERNATIVE.


>  "\nsimple RAM read/write test\n";
>
>  BAREBOX_CMD_START(mtest)
> --
> 1.7.7
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>

[-- Attachment #1.2: Type: text/html, Size: 5584 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-12  9:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-12  7:45 [PATCH] commands: mtest: add iteration count parameter for mtest command Marc Reilly
2013-01-12  9:06 ` Alexander Aring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox