diff mbox

lib: fwts_framework: handle nested log section endings on ABORT

Message ID 1338543991-25680-1-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King June 1, 2012, 9:46 a.m. UTC
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(-)

Comments

Keng-Yu Lin June 4, 2012, 9:01 a.m. UTC | #1
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. UTC | #2
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>
diff mbox

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;