diff mbox

lib: framework: allow mixed tests and test category options

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

Commit Message

Colin Ian King Dec. 9, 2015, 10:16 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Allow for the user to specify tests and test categories, and
default to --batch if nothing is specified, e.g.

1) Nothing specified, will run --batch tests
2) tests specified, just run these tests, e.g.
   fwts klog method
3) categories specied, just run these, e.g.
   fwts --uefitests
4) mixed:
   fwts klog method --uefitests

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_framework.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

Comments

Alex Hung Dec. 10, 2015, 2:54 a.m. UTC | #1
On 12/09/2015 06:16 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Allow for the user to specify tests and test categories, and
> default to --batch if nothing is specified, e.g.
>
> 1) Nothing specified, will run --batch tests
> 2) tests specified, just run these tests, e.g.
>     fwts klog method
> 3) categories specied, just run these, e.g.
>     fwts --uefitests
> 4) mixed:
>     fwts klog method --uefitests
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_framework.c | 23 ++++++++++++-----------
>   1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index 3c2cef8..1d44263 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -1330,6 +1330,7 @@ int fwts_framework_args(const int argc, char **argv)
>
>   	fwts_list tests_to_run;
>   	fwts_framework *fw;
> +	fwts_list_link *item;
>
>   	if ((fw = (fwts_framework *)calloc(1, sizeof(fwts_framework))) == NULL)
>   		return FWTS_ERROR;
> @@ -1397,8 +1398,6 @@ int fwts_framework_args(const int argc, char **argv)
>   		fwts_dump_info(fw);
>   		goto tidy_close;
>   	}
> -	if ((fw->flags & FWTS_FLAG_RUN_ALL) == 0)
> -		fw->flags |= FWTS_FLAG_BATCH;
>   	if ((fw->lspci == NULL) || (fw->results_logname == NULL)) {
>   		ret = FWTS_ERROR;
>   		fprintf(stderr, "%s: Memory allocation failure.", argv[0]);
> @@ -1453,15 +1452,17 @@ int fwts_framework_args(const int argc, char **argv)
>   			fwts_list_append(&tests_to_run, test);
>   	}
>
> -	if (fwts_list_len(&tests_to_run) == 0) {
> -		/* Find tests that are eligible for running */
> -		fwts_list_link *item;
> -		fwts_list_foreach(item, &fwts_framework_test_list) {
> -			fwts_framework_test *test = fwts_list_data(fwts_framework_test*, item);

> -			if (fw->flags & test->flags & FWTS_FLAG_RUN_ALL)
> -				if (fwts_framework_skip_test(&tests_to_skip, test) == NULL)
> -					fwts_list_append(&tests_to_run, test);
> -		}
> +	/* No options given and no tests, so default to run batch tests */
> +	if (!(FWTS_FLAG_RUN_ALL & fw->flags) &&
> +	    (fwts_list_len(&tests_to_run) == 0))
> +		fw->flags |= FWTS_FLAG_BATCH;
> +
> +	/* Find tests that are eligible for running */
> +	fwts_list_foreach(item, &fwts_framework_test_list) {
> +		fwts_framework_test *test = fwts_list_data(fwts_framework_test*, item);
> +		if (fw->flags & test->flags & FWTS_FLAG_RUN_ALL)
> +			if (fwts_framework_skip_test(&tests_to_skip, test) == NULL)
> +				fwts_list_append(&tests_to_run, test);
>   	}
>
>   	if (!(fw->flags & FWTS_FLAG_QUIET)) {
>

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu Dec. 10, 2015, 3:03 a.m. UTC | #2
On 2015年12月09日 18:16, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Allow for the user to specify tests and test categories, and
> default to --batch if nothing is specified, e.g.
>
> 1) Nothing specified, will run --batch tests
> 2) tests specified, just run these tests, e.g.
>     fwts klog method
> 3) categories specied, just run these, e.g.
>     fwts --uefitests
> 4) mixed:
>     fwts klog method --uefitests
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_framework.c | 23 ++++++++++++-----------
>   1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index 3c2cef8..1d44263 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -1330,6 +1330,7 @@ int fwts_framework_args(const int argc, char **argv)
>
>   	fwts_list tests_to_run;
>   	fwts_framework *fw;
> +	fwts_list_link *item;
>
>   	if ((fw = (fwts_framework *)calloc(1, sizeof(fwts_framework))) == NULL)
>   		return FWTS_ERROR;
> @@ -1397,8 +1398,6 @@ int fwts_framework_args(const int argc, char **argv)
>   		fwts_dump_info(fw);
>   		goto tidy_close;
>   	}
> -	if ((fw->flags & FWTS_FLAG_RUN_ALL) == 0)
> -		fw->flags |= FWTS_FLAG_BATCH;
>   	if ((fw->lspci == NULL) || (fw->results_logname == NULL)) {
>   		ret = FWTS_ERROR;
>   		fprintf(stderr, "%s: Memory allocation failure.", argv[0]);
> @@ -1453,15 +1452,17 @@ int fwts_framework_args(const int argc, char **argv)
>   			fwts_list_append(&tests_to_run, test);
>   	}
>
> -	if (fwts_list_len(&tests_to_run) == 0) {
> -		/* Find tests that are eligible for running */
> -		fwts_list_link *item;
> -		fwts_list_foreach(item, &fwts_framework_test_list) {
> -			fwts_framework_test *test = fwts_list_data(fwts_framework_test*, item);
> -			if (fw->flags & test->flags & FWTS_FLAG_RUN_ALL)
> -				if (fwts_framework_skip_test(&tests_to_skip, test) == NULL)
> -					fwts_list_append(&tests_to_run, test);
> -		}
> +	/* No options given and no tests, so default to run batch tests */
> +	if (!(FWTS_FLAG_RUN_ALL & fw->flags) &&
> +	    (fwts_list_len(&tests_to_run) == 0))
> +		fw->flags |= FWTS_FLAG_BATCH;
> +
> +	/* Find tests that are eligible for running */
> +	fwts_list_foreach(item, &fwts_framework_test_list) {
> +		fwts_framework_test *test = fwts_list_data(fwts_framework_test*, item);
> +		if (fw->flags & test->flags & FWTS_FLAG_RUN_ALL)
> +			if (fwts_framework_skip_test(&tests_to_skip, test) == NULL)
> +				fwts_list_append(&tests_to_run, test);
>   	}
>
>   	if (!(fw->flags & FWTS_FLAG_QUIET)) {
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
Ivan Hu Dec. 10, 2015, 3:05 a.m. UTC | #3
On 2015年12月09日 18:16, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Allow for the user to specify tests and test categories, and
> default to --batch if nothing is specified, e.g.
>
> 1) Nothing specified, will run --batch tests
> 2) tests specified, just run these tests, e.g.
>     fwts klog method
> 3) categories specied, just run these, e.g.
>     fwts --uefitests
> 4) mixed:
>     fwts klog method --uefitests
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_framework.c | 23 ++++++++++++-----------
>   1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index 3c2cef8..1d44263 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -1330,6 +1330,7 @@ int fwts_framework_args(const int argc, char **argv)
>
>   	fwts_list tests_to_run;
>   	fwts_framework *fw;
> +	fwts_list_link *item;
>
>   	if ((fw = (fwts_framework *)calloc(1, sizeof(fwts_framework))) == NULL)
>   		return FWTS_ERROR;
> @@ -1397,8 +1398,6 @@ int fwts_framework_args(const int argc, char **argv)
>   		fwts_dump_info(fw);
>   		goto tidy_close;
>   	}
> -	if ((fw->flags & FWTS_FLAG_RUN_ALL) == 0)
> -		fw->flags |= FWTS_FLAG_BATCH;
>   	if ((fw->lspci == NULL) || (fw->results_logname == NULL)) {
>   		ret = FWTS_ERROR;
>   		fprintf(stderr, "%s: Memory allocation failure.", argv[0]);
> @@ -1453,15 +1452,17 @@ int fwts_framework_args(const int argc, char **argv)
>   			fwts_list_append(&tests_to_run, test);
>   	}
>
> -	if (fwts_list_len(&tests_to_run) == 0) {
> -		/* Find tests that are eligible for running */
> -		fwts_list_link *item;
> -		fwts_list_foreach(item, &fwts_framework_test_list) {
> -			fwts_framework_test *test = fwts_list_data(fwts_framework_test*, item);
> -			if (fw->flags & test->flags & FWTS_FLAG_RUN_ALL)
> -				if (fwts_framework_skip_test(&tests_to_skip, test) == NULL)
> -					fwts_list_append(&tests_to_run, test);
> -		}
> +	/* No options given and no tests, so default to run batch tests */
> +	if (!(FWTS_FLAG_RUN_ALL & fw->flags) &&
> +	    (fwts_list_len(&tests_to_run) == 0))
> +		fw->flags |= FWTS_FLAG_BATCH;
> +
> +	/* Find tests that are eligible for running */
> +	fwts_list_foreach(item, &fwts_framework_test_list) {
> +		fwts_framework_test *test = fwts_list_data(fwts_framework_test*, item);
> +		if (fw->flags & test->flags & FWTS_FLAG_RUN_ALL)
> +			if (fwts_framework_skip_test(&tests_to_skip, test) == NULL)
> +				fwts_list_append(&tests_to_run, test);
>   	}
>
>   	if (!(fw->flags & FWTS_FLAG_QUIET)) {
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox

Patch

diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
index 3c2cef8..1d44263 100644
--- a/src/lib/src/fwts_framework.c
+++ b/src/lib/src/fwts_framework.c
@@ -1330,6 +1330,7 @@  int fwts_framework_args(const int argc, char **argv)
 
 	fwts_list tests_to_run;
 	fwts_framework *fw;
+	fwts_list_link *item;
 
 	if ((fw = (fwts_framework *)calloc(1, sizeof(fwts_framework))) == NULL)
 		return FWTS_ERROR;
@@ -1397,8 +1398,6 @@  int fwts_framework_args(const int argc, char **argv)
 		fwts_dump_info(fw);
 		goto tidy_close;
 	}
-	if ((fw->flags & FWTS_FLAG_RUN_ALL) == 0)
-		fw->flags |= FWTS_FLAG_BATCH;
 	if ((fw->lspci == NULL) || (fw->results_logname == NULL)) {
 		ret = FWTS_ERROR;
 		fprintf(stderr, "%s: Memory allocation failure.", argv[0]);
@@ -1453,15 +1452,17 @@  int fwts_framework_args(const int argc, char **argv)
 			fwts_list_append(&tests_to_run, test);
 	}
 
-	if (fwts_list_len(&tests_to_run) == 0) {
-		/* Find tests that are eligible for running */
-		fwts_list_link *item;
-		fwts_list_foreach(item, &fwts_framework_test_list) {
-			fwts_framework_test *test = fwts_list_data(fwts_framework_test*, item);
-			if (fw->flags & test->flags & FWTS_FLAG_RUN_ALL)
-				if (fwts_framework_skip_test(&tests_to_skip, test) == NULL)
-					fwts_list_append(&tests_to_run, test);
-		}
+	/* No options given and no tests, so default to run batch tests */
+	if (!(FWTS_FLAG_RUN_ALL & fw->flags) &&
+	    (fwts_list_len(&tests_to_run) == 0))
+		fw->flags |= FWTS_FLAG_BATCH;
+
+	/* Find tests that are eligible for running */
+	fwts_list_foreach(item, &fwts_framework_test_list) {
+		fwts_framework_test *test = fwts_list_data(fwts_framework_test*, item);
+		if (fw->flags & test->flags & FWTS_FLAG_RUN_ALL)
+			if (fwts_framework_skip_test(&tests_to_skip, test) == NULL)
+				fwts_list_append(&tests_to_run, test);
 	}
 
 	if (!(fw->flags & FWTS_FLAG_QUIET)) {