diff mbox

fwts: Better options handling for --dump

Message ID 1437542203-12990-1-git-send-email-anthony.wong@canonical.com
State Accepted
Headers show

Commit Message

Anthony Wong July 22, 2015, 5:16 a.m. UTC
If --dump was given as the first option, it ignored --lspci or
--dumpfile. Correct this so that the order of these options does not
matter.

Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
---
 src/lib/include/fwts_framework.h |  1 +
 src/lib/src/fwts_framework.c     | 12 ++++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

Comments

Colin Ian King July 22, 2015, 9:19 a.m. UTC | #1
On 22/07/15 06:16, Anthony Wong wrote:
> If --dump was given as the first option, it ignored --lspci or
> --dumpfile. Correct this so that the order of these options does not
> matter.
> 
> Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
> ---
>  src/lib/include/fwts_framework.h |  1 +
>  src/lib/src/fwts_framework.c     | 12 ++++++++----
>  2 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/src/lib/include/fwts_framework.h b/src/lib/include/fwts_framework.h
> index 40554a6..cdf9f98 100644
> --- a/src/lib/include/fwts_framework.h
> +++ b/src/lib/include/fwts_framework.h
> @@ -39,6 +39,7 @@ typedef enum {
>  	FWTS_FLAG_SHOW_TESTS			= 0x00000008,
>  	FWTS_FLAG_SHOW_PROGRESS_DIALOG		= 0x00000010,
>  	FWTS_FLAG_ACPICA_DEBUG			= 0x00000020,
> +	FWTS_FLAG_DUMP				= 0x00000040,
>  	FWTS_FLAG_BATCH				= 0x00001000,
>  	FWTS_FLAG_INTERACTIVE			= 0x00002000,
>  	FWTS_FLAG_BATCH_EXPERIMENTAL		= 0x00004000,
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index 92431a9..c3f1dea 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -1146,8 +1146,8 @@ int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
>  			fwts_framework_show_version(stdout, argv[0]);
>  			return FWTS_COMPLETE;
>  		case 16: /* --dump */
> -			fwts_dump_info(fw);
> -			return FWTS_COMPLETE;
> +			fw->flags |= FWTS_FLAG_DUMP;
> +			break;
>  		case 17: /* --table-path */
>  			fwts_framework_strdup(&fw->acpi_table_path, optarg);
>  			break;
> @@ -1241,8 +1241,8 @@ int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
>  		fw->flags |= FWTS_FLAG_BATCH;
>  		break;
>  	case 'd': /* --dump */
> -		fwts_dump_info(fw);
> -		return FWTS_COMPLETE;
> +		fw->flags |= FWTS_FLAG_DUMP;
> +		break;
>  	case 'D': /* --show-progress-dialog */
>  		fw->flags = (fw->flags &
>  				~(FWTS_FLAG_QUIET |
> @@ -1388,6 +1388,10 @@ int fwts_framework_args(const int argc, char **argv)
>  		fwts_framework_show_tests_categories();
>  		goto tidy_close;
>  	}
> +	if (fw->flags & FWTS_FLAG_DUMP) {
> +		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)) {
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
Ivan Hu July 23, 2015, 2:51 a.m. UTC | #2
On 2015年07月22日 13:16, Anthony Wong wrote:
> If --dump was given as the first option, it ignored --lspci or
> --dumpfile. Correct this so that the order of these options does not
> matter.
>
> Signed-off-by: Anthony Wong <anthony.wong@canonical.com>
> ---
>   src/lib/include/fwts_framework.h |  1 +
>   src/lib/src/fwts_framework.c     | 12 ++++++++----
>   2 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/src/lib/include/fwts_framework.h b/src/lib/include/fwts_framework.h
> index 40554a6..cdf9f98 100644
> --- a/src/lib/include/fwts_framework.h
> +++ b/src/lib/include/fwts_framework.h
> @@ -39,6 +39,7 @@ typedef enum {
>   	FWTS_FLAG_SHOW_TESTS			= 0x00000008,
>   	FWTS_FLAG_SHOW_PROGRESS_DIALOG		= 0x00000010,
>   	FWTS_FLAG_ACPICA_DEBUG			= 0x00000020,
> +	FWTS_FLAG_DUMP				= 0x00000040,
>   	FWTS_FLAG_BATCH				= 0x00001000,
>   	FWTS_FLAG_INTERACTIVE			= 0x00002000,
>   	FWTS_FLAG_BATCH_EXPERIMENTAL		= 0x00004000,
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index 92431a9..c3f1dea 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -1146,8 +1146,8 @@ int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
>   			fwts_framework_show_version(stdout, argv[0]);
>   			return FWTS_COMPLETE;
>   		case 16: /* --dump */
> -			fwts_dump_info(fw);
> -			return FWTS_COMPLETE;
> +			fw->flags |= FWTS_FLAG_DUMP;
> +			break;
>   		case 17: /* --table-path */
>   			fwts_framework_strdup(&fw->acpi_table_path, optarg);
>   			break;
> @@ -1241,8 +1241,8 @@ int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
>   		fw->flags |= FWTS_FLAG_BATCH;
>   		break;
>   	case 'd': /* --dump */
> -		fwts_dump_info(fw);
> -		return FWTS_COMPLETE;
> +		fw->flags |= FWTS_FLAG_DUMP;
> +		break;
>   	case 'D': /* --show-progress-dialog */
>   		fw->flags = (fw->flags &
>   				~(FWTS_FLAG_QUIET |
> @@ -1388,6 +1388,10 @@ int fwts_framework_args(const int argc, char **argv)
>   		fwts_framework_show_tests_categories();
>   		goto tidy_close;
>   	}
> +	if (fw->flags & FWTS_FLAG_DUMP) {
> +		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)) {

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

Patch

diff --git a/src/lib/include/fwts_framework.h b/src/lib/include/fwts_framework.h
index 40554a6..cdf9f98 100644
--- a/src/lib/include/fwts_framework.h
+++ b/src/lib/include/fwts_framework.h
@@ -39,6 +39,7 @@  typedef enum {
 	FWTS_FLAG_SHOW_TESTS			= 0x00000008,
 	FWTS_FLAG_SHOW_PROGRESS_DIALOG		= 0x00000010,
 	FWTS_FLAG_ACPICA_DEBUG			= 0x00000020,
+	FWTS_FLAG_DUMP				= 0x00000040,
 	FWTS_FLAG_BATCH				= 0x00001000,
 	FWTS_FLAG_INTERACTIVE			= 0x00002000,
 	FWTS_FLAG_BATCH_EXPERIMENTAL		= 0x00004000,
diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
index 92431a9..c3f1dea 100644
--- a/src/lib/src/fwts_framework.c
+++ b/src/lib/src/fwts_framework.c
@@ -1146,8 +1146,8 @@  int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
 			fwts_framework_show_version(stdout, argv[0]);
 			return FWTS_COMPLETE;
 		case 16: /* --dump */
-			fwts_dump_info(fw);
-			return FWTS_COMPLETE;
+			fw->flags |= FWTS_FLAG_DUMP;
+			break;
 		case 17: /* --table-path */
 			fwts_framework_strdup(&fw->acpi_table_path, optarg);
 			break;
@@ -1241,8 +1241,8 @@  int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
 		fw->flags |= FWTS_FLAG_BATCH;
 		break;
 	case 'd': /* --dump */
-		fwts_dump_info(fw);
-		return FWTS_COMPLETE;
+		fw->flags |= FWTS_FLAG_DUMP;
+		break;
 	case 'D': /* --show-progress-dialog */
 		fw->flags = (fw->flags &
 				~(FWTS_FLAG_QUIET |
@@ -1388,6 +1388,10 @@  int fwts_framework_args(const int argc, char **argv)
 		fwts_framework_show_tests_categories();
 		goto tidy_close;
 	}
+	if (fw->flags & FWTS_FLAG_DUMP) {
+		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)) {