From: Gustavo Sousa <gustavo.sousa@intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>,
<igt-dev@lists.freedesktop.org>
Cc: Peter Senna Tschudin <peter.senna@linux.intel.com>,
Kamil Konieczny <kamil.konieczny@linux.intel.com>,
Petri Latvala <adrinael@adrinael.net>,
Lucas De Marchi <lucas.demarchi@intel.com>
Subject: Re: [PATCH i-g-t v3 09/10] runner/settings: Serialize command line
Date: Fri, 7 Feb 2025 17:36:44 -0300 [thread overview]
Message-ID: <173896060422.1963.16792492690522172141@intel.com> (raw)
In-Reply-To: <20250130172149.3657144-10-lucas.demarchi@intel.com>
Quoting Lucas De Marchi (2025-01-30 14:21:48-03:00)
>Serialize the command line to metadata.txt. The expected format in the
>metadata.txt is like below:
>
> cmdline.argc : 6
> cmdline.argv[0] : ./build/runner/igt_runner
> cmdline.argv[1] : -o
> cmdline.argv[2] : --test-list
> cmdline.argv[3] : /tmp/testlist.txt
> cmdline.argv[4] : build/tests/
> cmdline.argv[5] : /tmp/results
>
>Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
>---
> runner/settings.c | 21 +++++++++++++++++++++
> runner/settings.h | 4 ++++
> 2 files changed, 25 insertions(+)
>
>diff --git a/runner/settings.c b/runner/settings.c
>index 62afd3534..84d8c85e9 100644
>--- a/runner/settings.c
>+++ b/runner/settings.c
>@@ -529,6 +529,14 @@ static void free_hook_strs(struct igt_vec *hook_strs)
> igt_vec_fini(hook_strs);
> }
>
>+static void free_array_deep(void **arr, size_t n)
>+{
We need to make sure that arr is not NULL before going into the for-loop
below. That would be the case if "settings->cmdline.argv = calloc(argc,
sizeof(*settings->cmdline.argv))" failed.
With that fixed,
Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>
>+ for (size_t i = 0; i < n; i++)
>+ free(arr[i]);
>+
>+ free(arr);
>+}
>+
> static bool file_exists_at(int dirfd, const char *filename)
> {
> return faccessat(dirfd, filename, F_OK, 0) == 0;
>@@ -646,6 +654,7 @@ void clear_settings(struct settings *settings)
> free_regexes(&settings->exclude_regexes);
> free_env_vars(&settings->env_vars);
> free_hook_strs(&settings->hook_strs);
>+ free_array_deep((void **)settings->cmdline.argv, settings->cmdline.argc);
>
> init_settings(settings);
> }
>@@ -875,6 +884,16 @@ bool parse_options(int argc, char **argv,
> goto error;
> }
>
>+ settings->cmdline.argv = calloc(argc, sizeof(*settings->cmdline.argv));
>+ if (!settings->cmdline.argv)
>+ goto error;
>+
>+ settings->cmdline.argc = argc;
>+ for (int i = 0; i < argc; i++) {
>+ settings->cmdline.argv[i] = strdup(argv[i]);
>+ if (!settings->cmdline.argv[i])
>+ goto error;
>+ }
>
> return true;
>
>@@ -1202,6 +1221,7 @@ bool serialize_settings(struct settings *settings)
> SERIALIZE_INT(f, settings, enable_code_coverage);
> SERIALIZE_INT(f, settings, cov_results_per_test);
> SERIALIZE_STR(f, settings, code_coverage_script);
>+ SERIALIZE_STR_ARRAY(f, settings, cmdline.argv, cmdline.argc);
>
> if (settings->sync) {
> fflush(f);
>@@ -1315,6 +1335,7 @@ bool read_settings_from_file(struct settings *settings, FILE *f)
> PARSE_INT(settings, name, val, enable_code_coverage);
> PARSE_INT(settings, name, val, cov_results_per_test);
> PARSE_STR(settings, name, val, code_coverage_script);
>+ PARSE_STR_ARRAY(settings, name, val, cmdline.argv, cmdline.argc);
>
> printf("Warning: Unknown field in settings file: %s = %s\n",
> name, val);
>diff --git a/runner/settings.h b/runner/settings.h
>index f69f09778..2266118a7 100644
>--- a/runner/settings.h
>+++ b/runner/settings.h
>@@ -75,6 +75,10 @@ struct settings {
> char *code_coverage_script;
> bool enable_code_coverage;
> bool cov_results_per_test;
>+ struct {
>+ int argc;
>+ char **argv;
>+ } cmdline;
> };
>
> /**
>--
>2.48.0
>
next prev parent reply other threads:[~2025-02-07 20:36 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-30 17:21 [PATCH i-g-t v3 00/10] Add igt_runner's cmdline to results Lucas De Marchi
2025-01-30 17:21 ` [PATCH i-g-t v3 01/10] runner/settings: Fix code_coverage_script leak Lucas De Marchi
2025-01-30 17:21 ` [PATCH i-g-t v3 02/10] runner: Free settings at the end Lucas De Marchi
2025-01-30 17:21 ` [PATCH i-g-t v3 03/10] runner/settings: Deduplicate cleanup Lucas De Marchi
2025-01-30 17:21 ` [PATCH i-g-t v3 04/10] runner/settings: Use wrapper macros for each type Lucas De Marchi
2025-02-07 18:34 ` Gustavo Sousa
2025-01-30 17:21 ` [PATCH i-g-t v3 05/10] runner/settings: Match serialization to parse Lucas De Marchi
2025-02-07 19:13 ` Gustavo Sousa
2025-01-30 17:21 ` [PATCH i-g-t v3 06/10] runner/settings: Drop extra strdup Lucas De Marchi
2025-01-30 17:21 ` [PATCH i-g-t v3 07/10] runner: Fix use of newline on arguments Lucas De Marchi
2025-01-31 9:21 ` Peter Senna Tschudin
2025-01-31 15:58 ` Lucas De Marchi
2025-02-03 18:09 ` Lucas De Marchi
2025-02-07 20:15 ` Gustavo Sousa
2025-01-30 17:21 ` [PATCH i-g-t v3 08/10] runner/settings: Add helpers to serialize/parse array Lucas De Marchi
2025-02-07 20:26 ` Gustavo Sousa
2025-01-30 17:21 ` [PATCH i-g-t v3 09/10] runner/settings: Serialize command line Lucas De Marchi
2025-02-07 20:36 ` Gustavo Sousa [this message]
2025-02-07 20:41 ` Gustavo Sousa
2025-01-30 17:21 ` [PATCH i-g-t v3 10/10] runner/resultgen: Add cmdline to results.json Lucas De Marchi
2025-01-30 19:00 ` Kamil Konieczny
2025-01-30 19:17 ` Lucas De Marchi
2025-01-31 9:31 ` Peter Senna Tschudin
2025-01-31 12:16 ` Kamil Konieczny
2025-01-31 15:39 ` Lucas De Marchi
2025-01-30 19:12 ` ✓ Xe.CI.BAT: success for Add igt_runner's cmdline to results (rev3) Patchwork
2025-01-30 19:12 ` ✓ i915.CI.BAT: " Patchwork
2025-01-30 21:21 ` ✗ i915.CI.Full: failure " Patchwork
2025-01-30 22:06 ` ✓ Xe.CI.Full: success " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=173896060422.1963.16792492690522172141@intel.com \
--to=gustavo.sousa@intel.com \
--cc=adrinael@adrinael.net \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
--cc=lucas.demarchi@intel.com \
--cc=peter.senna@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox