lib: framework: log the fwts command line for reference.

Submitted by Colin King on Dec. 31, 2012, 10:39 p.m.

Details

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

Commit Message

Colin King Dec. 31, 2012, 10:39 p.m.
From: Colin Ian King <colin.king@canonical.com>

Since CERT may be running fwts with options that may be silently
ignoring some fwts errors it makes sense to also log the command
line options being used so we can see how fwts is being invoked
for reference purposes.

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

Comments

Alex Hung Jan. 2, 2013, 12:50 a.m.
On 01/01/2013 06:39 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Since CERT may be running fwts with options that may be silently
> ignoring some fwts errors it makes sense to also log the command
> line options being used so we can see how fwts is being invoked
> for reference purposes.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_framework.c | 24 +++++++++++++++++++++---
>   1 file changed, 21 insertions(+), 3 deletions(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index a04215d..7290912 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -811,13 +811,18 @@ static void fwts_framework_syntax(char * const *argv)
>    * fwts_framework_heading_info()
>    *	log basic system info so we can track the tests
>    */
> -static void fwts_framework_heading_info(fwts_framework *fw, fwts_list *tests_to_run)
> +static void fwts_framework_heading_info(
> +	fwts_framework *fw,
> +	fwts_list *tests_to_run,
> +	const int argc,
> +	char * const *argv)
>   {
>   	struct tm tm;
>   	time_t now;
>   	struct utsname buf;
>   	char *tests = NULL;
> -	size_t len = 1;
> +	char *args = NULL;
> +	size_t len;
>   	int i;
>   	fwts_list_link *item;
>
> @@ -838,6 +843,19 @@ static void fwts_framework_heading_info(fwts_framework *fw, fwts_list *tests_to_
>   		buf.sysname, buf.nodename, buf.release, buf.version, buf.machine);
>   	fwts_log_nl(fw);
>
> +	for (len = 1, i = 1; i < argc; i++)
> +		len += strlen(argv[i]) + 1;
> +
> +	if ((args = calloc(len, 1)) != NULL) {
> +		for (len = 1, i = 1; i < argc; i++) {
> +			strcat(args, " ");
> +			strcat(args, argv[i]);
> +		}
> +		fwts_log_info(fw, "Command: \"fwts %s\".", args);
> +		free(args);
> +	}
> +
> +	len = 1;
>   	fwts_list_foreach(item, tests_to_run) {
>   		fwts_framework_test *test = fwts_list_data(fwts_framework_test *, item);
>   		len += strlen(test->name) + 1;
> @@ -1304,7 +1322,7 @@ int fwts_framework_args(const int argc, char **argv)
>   	}
>
>   	fwts_log_section_begin(fw->results, "heading");
> -	fwts_framework_heading_info(fw, &tests_to_run);
> +	fwts_framework_heading_info(fw, &tests_to_run, argc, argv);
>   	fwts_log_section_end(fw->results);
>
>   	fwts_log_section_begin(fw->results, "tests");
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin Jan. 14, 2013, 6:24 a.m.
On Tue, Jan 1, 2013 at 6:39 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Since CERT may be running fwts with options that may be silently
> ignoring some fwts errors it makes sense to also log the command
> line options being used so we can see how fwts is being invoked
> for reference purposes.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_framework.c | 24 +++++++++++++++++++++---
>  1 file changed, 21 insertions(+), 3 deletions(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index a04215d..7290912 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -811,13 +811,18 @@ static void fwts_framework_syntax(char * const *argv)
>   * fwts_framework_heading_info()
>   *     log basic system info so we can track the tests
>   */
> -static void fwts_framework_heading_info(fwts_framework *fw, fwts_list *tests_to_run)
> +static void fwts_framework_heading_info(
> +       fwts_framework *fw,
> +       fwts_list *tests_to_run,
> +       const int argc,
> +       char * const *argv)
>  {
>         struct tm tm;
>         time_t now;
>         struct utsname buf;
>         char *tests = NULL;
> -       size_t len = 1;
> +       char *args = NULL;
> +       size_t len;
>         int i;
>         fwts_list_link *item;
>
> @@ -838,6 +843,19 @@ static void fwts_framework_heading_info(fwts_framework *fw, fwts_list *tests_to_
>                 buf.sysname, buf.nodename, buf.release, buf.version, buf.machine);
>         fwts_log_nl(fw);
>
> +       for (len = 1, i = 1; i < argc; i++)
> +               len += strlen(argv[i]) + 1;
> +
> +       if ((args = calloc(len, 1)) != NULL) {
> +               for (len = 1, i = 1; i < argc; i++) {
> +                       strcat(args, " ");
> +                       strcat(args, argv[i]);
> +               }
> +               fwts_log_info(fw, "Command: \"fwts %s\".", args);
> +               free(args);
> +       }
> +
> +       len = 1;
>         fwts_list_foreach(item, tests_to_run) {
>                 fwts_framework_test *test = fwts_list_data(fwts_framework_test *, item);
>                 len += strlen(test->name) + 1;
> @@ -1304,7 +1322,7 @@ int fwts_framework_args(const int argc, char **argv)
>         }
>
>         fwts_log_section_begin(fw->results, "heading");
> -       fwts_framework_heading_info(fw, &tests_to_run);
> +       fwts_framework_heading_info(fw, &tests_to_run, argc, argv);
>         fwts_log_section_end(fw->results);
>
>         fwts_log_section_begin(fw->results, "tests");
> --
> 1.8.0
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch hide | download patch | download mbox

diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
index a04215d..7290912 100644
--- a/src/lib/src/fwts_framework.c
+++ b/src/lib/src/fwts_framework.c
@@ -811,13 +811,18 @@  static void fwts_framework_syntax(char * const *argv)
  * fwts_framework_heading_info()
  *	log basic system info so we can track the tests
  */
-static void fwts_framework_heading_info(fwts_framework *fw, fwts_list *tests_to_run)
+static void fwts_framework_heading_info(
+	fwts_framework *fw,
+	fwts_list *tests_to_run,
+	const int argc,
+	char * const *argv)
 {
 	struct tm tm;
 	time_t now;
 	struct utsname buf;
 	char *tests = NULL;
-	size_t len = 1;
+	char *args = NULL;
+	size_t len;
 	int i;
 	fwts_list_link *item;
 
@@ -838,6 +843,19 @@  static void fwts_framework_heading_info(fwts_framework *fw, fwts_list *tests_to_
 		buf.sysname, buf.nodename, buf.release, buf.version, buf.machine);
 	fwts_log_nl(fw);
 
+	for (len = 1, i = 1; i < argc; i++)
+		len += strlen(argv[i]) + 1;
+
+	if ((args = calloc(len, 1)) != NULL) {
+		for (len = 1, i = 1; i < argc; i++) {
+			strcat(args, " ");
+			strcat(args, argv[i]);
+		}
+		fwts_log_info(fw, "Command: \"fwts %s\".", args);
+		free(args);
+	}
+
+	len = 1;
 	fwts_list_foreach(item, tests_to_run) {
 		fwts_framework_test *test = fwts_list_data(fwts_framework_test *, item);
 		len += strlen(test->name) + 1;
@@ -1304,7 +1322,7 @@  int fwts_framework_args(const int argc, char **argv)
 	}
 
 	fwts_log_section_begin(fw->results, "heading");
-	fwts_framework_heading_info(fw, &tests_to_run);
+	fwts_framework_heading_info(fw, &tests_to_run, argc, argv);
 	fwts_log_section_end(fw->results);
 
 	fwts_log_section_begin(fw->results, "tests");