Patchwork lib: framework: Increase precision of progress, add a spinner progress indicator

login
register
mail settings
Submitter Colin King
Date Jan. 10, 2013, 10:48 a.m.
Message ID <1357814937-21979-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/210974/
State Accepted
Headers show

Comments

Colin King - Jan. 10, 2013, 10:48 a.m.
From: Colin Ian King <colin.king@canonical.com>

Some tests such as the cpufreq and cstates tests take rather a long time so it
makes sense to increase the precision to the % progress output to indicate that
something is actually happening.  Also, add a progress spinner indicator to also
provide some feedback that the test is actually active rather than hung.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_framework.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Keng-Yu Lin - Jan. 29, 2013, 5:34 a.m.
On Thu, Jan 10, 2013 at 6:48 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Some tests such as the cpufreq and cstates tests take rather a long time so it
> makes sense to increase the precision to the % progress output to indicate that
> something is actually happening.  Also, add a progress spinner indicator to also
> provide some feedback that the test is actually active rather than hung.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_framework.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index 7290912..25ccc41 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -380,11 +380,13 @@ void fwts_framework_minor_test_progress(fwts_framework *fw, const int percent, c
>         if (fw->show_progress) {
>                 char buf[1024];
>                 char truncbuf[256];
> +               static int index;
>
>                 snprintf(buf, sizeof(buf), "%s %s",fw->current_minor_test_name, message);
>                 fwts_framework_strtrunc(truncbuf, buf, width-9);
>
> -               fprintf(stderr, "  %-*.*s: %3.0f%%\r", width-9, width-9, truncbuf, progress);
> +               fprintf(stderr, "  %-*.*s: %5.1f%% %c\r",
> +                       width-13, width-13, truncbuf, progress, "/-\\|"[index++ & 3]);
>                 fflush(stderr);
>         }
>
> --
> 1.8.0
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Alex Hung - Jan. 31, 2013, 6:58 a.m.
On 01/10/2013 06:48 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Some tests such as the cpufreq and cstates tests take rather a long time so it
> makes sense to increase the precision to the % progress output to indicate that
> something is actually happening.  Also, add a progress spinner indicator to also
> provide some feedback that the test is actually active rather than hung.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_framework.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index 7290912..25ccc41 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -380,11 +380,13 @@ void fwts_framework_minor_test_progress(fwts_framework *fw, const int percent, c
>   	if (fw->show_progress) {
>   		char buf[1024];
>   		char truncbuf[256];
> +		static int index;
>
>   		snprintf(buf, sizeof(buf), "%s %s",fw->current_minor_test_name, message);
>   		fwts_framework_strtrunc(truncbuf, buf, width-9);
>
> -		fprintf(stderr, "  %-*.*s: %3.0f%%\r", width-9, width-9, truncbuf, progress);
> +		fprintf(stderr, "  %-*.*s: %5.1f%% %c\r",
> +			width-13, width-13, truncbuf, progress, "/-\\|"[index++ & 3]);
>   		fflush(stderr);
>   	}
>
>
Acked-by: Alex Hung <alex.hung@canonical.com>

Patch

diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
index 7290912..25ccc41 100644
--- a/src/lib/src/fwts_framework.c
+++ b/src/lib/src/fwts_framework.c
@@ -380,11 +380,13 @@  void fwts_framework_minor_test_progress(fwts_framework *fw, const int percent, c
 	if (fw->show_progress) {
 		char buf[1024];
 		char truncbuf[256];
+		static int index;
 
 		snprintf(buf, sizeof(buf), "%s %s",fw->current_minor_test_name, message);
 		fwts_framework_strtrunc(truncbuf, buf, width-9);
 
-		fprintf(stderr, "  %-*.*s: %3.0f%%\r", width-9, width-9, truncbuf, progress);
+		fprintf(stderr, "  %-*.*s: %5.1f%% %c\r",
+			width-13, width-13, truncbuf, progress, "/-\\|"[index++ & 3]);
 		fflush(stderr);
 	}