Patchwork lib: fwts_framework: handle nested log section endings on ABORT

login
register
mail settings
Submitter Colin King
Date June 1, 2012, 9:46 a.m.
Message ID <1338543991-25680-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/162291/
State Accepted
Headers show

Comments

Colin King - June 1, 2012, 9:46 a.m.
From: Colin Ian King <colin.king@canonical.com>

Ensure we unstack log section endings correctly on a test abort
break from the test loop.  Also, add some comments to indicate the
where the nested log section endings are associated with.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_framework.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
Keng-Yu Lin - June 4, 2012, 9:01 a.m.
On Fri, Jun 1, 2012 at 5:46 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Ensure we unstack log section endings correctly on a test abort
> break from the test loop.  Also, add some comments to indicate the
> where the nested log section endings are associated with.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_framework.c |   16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index a43d31b..f808d8e 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -576,7 +576,7 @@ static int fwts_framework_run_test(fwts_framework *fw, const int num_tests, fwts
>                        fwts_log_info(fw, "Test %d of %d: %s",
>                                fw->current_minor_test_num,
>                                test->ops->total_tests, minor_test->name);
> -                       fwts_log_section_end(fw->results);
> +                       fwts_log_section_end(fw->results);      /* subtest_info */
>                }
>
>                fwts_log_section_begin(fw->results, "subtest_results");
> @@ -588,6 +588,10 @@ static int fwts_framework_run_test(fwts_framework *fw, const int num_tests, fwts
>                if (ret == FWTS_ABORTED)  {
>                        int aborted = test->ops->total_tests - (fw->current_minor_test_num - 1);
>                        fw->current_major_test->results.aborted += aborted;
> +
> +                       fwts_log_section_end(fw->results);      /* subtest_results */
> +                       fwts_log_nl(fw);
> +                       fwts_log_section_end(fw->results);      /* subtest */
>                        break;
>                }
>                fwts_framework_minor_test_progress(fw, 100, "");
> @@ -602,11 +606,11 @@ static int fwts_framework_run_test(fwts_framework *fw, const int num_tests, fwts
>                        fprintf(stderr, "  %-55.55s %s\n", namebuf,
>                                *resbuf ? resbuf : "     ");
>                }
> -               fwts_log_section_end(fw->results);
> +               fwts_log_section_end(fw->results);      /* subtest_results */
>                fwts_log_nl(fw);
> -               fwts_log_section_end(fw->results);
> +               fwts_log_section_end(fw->results);      /* subtest */
>        }
> -       fwts_log_section_end(fw->results);
> +       fwts_log_section_end(fw->results);      /* subtests */
>
>        fwts_framework_summate_results(&fw->total, &fw->current_major_test->results);
>
> @@ -625,10 +629,10 @@ done:
>        if (!(test->flags & FWTS_UTILS)) {
>                fwts_log_section_begin(fw->results, "results");
>                fwts_framework_test_summary(fw);
> -               fwts_log_section_end(fw->results);
> +               fwts_log_section_end(fw->results);      /* results */
>        }
>
> -       fwts_log_section_end(fw->results);
> +       fwts_log_section_end(fw->results);              /* test->name */
>        fwts_log_set_owner(fw->results, "fwts");
>
>        return FWTS_OK;
> --
> 1.7.9.5
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Alex Hung - June 11, 2012, 10:07 a.m.
On 06/01/2012 05:46 PM, Colin King wrote:
> From: Colin Ian King<colin.king@canonical.com>
>
> Ensure we unstack log section endings correctly on a test abort
> break from the test loop.  Also, add some comments to indicate the
> where the nested log section endings are associated with.
>
> Signed-off-by: Colin Ian King<colin.king@canonical.com>
> ---
>   src/lib/src/fwts_framework.c |   16 ++++++++++------
>   1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index a43d31b..f808d8e 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -576,7 +576,7 @@ static int fwts_framework_run_test(fwts_framework *fw, const int num_tests, fwts
>   			fwts_log_info(fw, "Test %d of %d: %s",
>   				fw->current_minor_test_num,
>   				test->ops->total_tests, minor_test->name);
> -			fwts_log_section_end(fw->results);
> +			fwts_log_section_end(fw->results);	/* subtest_info */
>   		}
>
>   		fwts_log_section_begin(fw->results, "subtest_results");
> @@ -588,6 +588,10 @@ static int fwts_framework_run_test(fwts_framework *fw, const int num_tests, fwts
>   		if (ret == FWTS_ABORTED)  {
>   			int aborted = test->ops->total_tests - (fw->current_minor_test_num - 1);
>   			fw->current_major_test->results.aborted += aborted;
> +
> +			fwts_log_section_end(fw->results);	/* subtest_results */
> +			fwts_log_nl(fw);
> +			fwts_log_section_end(fw->results);	/* subtest */
>   			break;
>   		}
>   		fwts_framework_minor_test_progress(fw, 100, "");
> @@ -602,11 +606,11 @@ static int fwts_framework_run_test(fwts_framework *fw, const int num_tests, fwts
>   			fprintf(stderr, "  %-55.55s %s\n", namebuf,
>   				*resbuf ? resbuf : "     ");
>   		}
> -		fwts_log_section_end(fw->results);
> +		fwts_log_section_end(fw->results);	/* subtest_results */
>   		fwts_log_nl(fw);
> -		fwts_log_section_end(fw->results);
> +		fwts_log_section_end(fw->results);	/* subtest */
>   	}
> -	fwts_log_section_end(fw->results);
> +	fwts_log_section_end(fw->results);	/* subtests */
>
>   	fwts_framework_summate_results(&fw->total,&fw->current_major_test->results);
>
> @@ -625,10 +629,10 @@ done:
>   	if (!(test->flags&  FWTS_UTILS)) {
>   		fwts_log_section_begin(fw->results, "results");
>   		fwts_framework_test_summary(fw);
> -		fwts_log_section_end(fw->results);
> +		fwts_log_section_end(fw->results);	/* results */
>   	}
>
> -	fwts_log_section_end(fw->results);
> +	fwts_log_section_end(fw->results);		/* test->name */
>   	fwts_log_set_owner(fw->results, "fwts");
>
>   	return FWTS_OK;
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 a43d31b..f808d8e 100644
--- a/src/lib/src/fwts_framework.c
+++ b/src/lib/src/fwts_framework.c
@@ -576,7 +576,7 @@  static int fwts_framework_run_test(fwts_framework *fw, const int num_tests, fwts
 			fwts_log_info(fw, "Test %d of %d: %s",
 				fw->current_minor_test_num,
 				test->ops->total_tests, minor_test->name);
-			fwts_log_section_end(fw->results);
+			fwts_log_section_end(fw->results);	/* subtest_info */
 		}
 
 		fwts_log_section_begin(fw->results, "subtest_results");
@@ -588,6 +588,10 @@  static int fwts_framework_run_test(fwts_framework *fw, const int num_tests, fwts
 		if (ret == FWTS_ABORTED)  {
 			int aborted = test->ops->total_tests - (fw->current_minor_test_num - 1);
 			fw->current_major_test->results.aborted += aborted;
+
+			fwts_log_section_end(fw->results);	/* subtest_results */
+			fwts_log_nl(fw);
+			fwts_log_section_end(fw->results);	/* subtest */
 			break;
 		}
 		fwts_framework_minor_test_progress(fw, 100, "");
@@ -602,11 +606,11 @@  static int fwts_framework_run_test(fwts_framework *fw, const int num_tests, fwts
 			fprintf(stderr, "  %-55.55s %s\n", namebuf,
 				*resbuf ? resbuf : "     ");
 		}
-		fwts_log_section_end(fw->results);
+		fwts_log_section_end(fw->results);	/* subtest_results */
 		fwts_log_nl(fw);
-		fwts_log_section_end(fw->results);
+		fwts_log_section_end(fw->results);	/* subtest */
 	}
-	fwts_log_section_end(fw->results);
+	fwts_log_section_end(fw->results);	/* subtests */
 
 	fwts_framework_summate_results(&fw->total, &fw->current_major_test->results);
 
@@ -625,10 +629,10 @@  done:
 	if (!(test->flags & FWTS_UTILS)) {
 		fwts_log_section_begin(fw->results, "results");
 		fwts_framework_test_summary(fw);
-		fwts_log_section_end(fw->results);
+		fwts_log_section_end(fw->results);	/* results */
 	}
 
-	fwts_log_section_end(fw->results);
+	fwts_log_section_end(fw->results);		/* test->name */
 	fwts_log_set_owner(fw->results, "fwts");
 
 	return FWTS_OK;