From: Gustavo Sousa <gustavo.sousa@intel.com>
To: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>,
igt-dev@lists.freedesktop.org
Cc: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>,
"Kamil Konieczny" <kamil.konieczny@linux.intel.com>,
"Ryszard Knop" <ryszard.knop@intel.com>,
"Krzysztof Karas" <krzysztof.karas@intel.com>
Subject: Re: [PATCH i-g-t v2 2/6] runner: Create attachments directory to use by hooks
Date: Mon, 30 Mar 2026 11:20:46 -0300 [thread overview]
Message-ID: <87mrzpxutd.fsf@intel.com> (raw)
In-Reply-To: <20260324131235.712916-10-zbigniew.kempczynski@intel.com>
Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> writes:
> Results parsing is currently limited to few predefined files.
>
> Create "attachments" directory and export full path of created directory
> to be used within hooks. From now on environment variable
> IGT_RUNNER_ATTACHMENTS_DIR become visible when igt_runner is used
> to execute tests. This env contains directory where subtests/dynsubtests
> may write auxiliary files which finally be included in results.json.
>
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
> Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
> Cc: Ryszard Knop <ryszard.knop@intel.com>
> Cc: Krzysztof Karas <krzysztof.karas@intel.com>
> ---
> v2: simplify attachment dirname concatenation (Kamil)
> remove files in attachments dir when overwrite is set (Kamil)
> ---
> lib/igt_hook.c | 4 ++++
> runner/executor.c | 44 +++++++++++++++++++++++++++++++++++++++++---
> runner/executor.h | 2 ++
> 3 files changed, 47 insertions(+), 3 deletions(-)
>
> diff --git a/lib/igt_hook.c b/lib/igt_hook.c
> index f86ed56f72..57817bdc12 100644
> --- a/lib/igt_hook.c
> +++ b/lib/igt_hook.c
> @@ -518,5 +518,9 @@ available to the command:\n\
> \n\
> Note that %s can be passed multiple times. Each descriptor is evaluated in turn\n\
> when matching events and running hook commands.\n\
> +\n\
> +When executed by the igt_runner environment IGT_RUNNER_ATTACHMENTS_DIR\n\
Nitpick: s/igt_runner environment/igt_runner, environment/
> +is passed additionally to the hook script. It contains directory where\n\
> +script may write additional attachments like guc logs, etc.\n\
Looking at how this is implemented, the attachments directory is not a
hook-specific thing, so I believe documentation for it would be better
placed in igt_runner's help/docs.
> ", option_name);
> }
> diff --git a/runner/executor.c b/runner/executor.c
> index 1485b59d1f..bc421f7dbb 100644
> --- a/runner/executor.c
> +++ b/runner/executor.c
> @@ -1779,17 +1779,22 @@ static int execute_next_entry(struct execute_state *state,
> int errpipe[2] = { -1, -1 };
> int socket[2] = { -1, -1 };
> int outfd, errfd, socketfd;
> - char name[32];
> + char name[32], attname[32];
> + char attdirname[PATH_MAX];
> pid_t child;
> int result;
> size_t idx = state->next;
>
> snprintf(name, sizeof(name), "%zd", idx);
> + snprintf(attname, sizeof(attname), "%zd/%s", idx, DIR_ATTACHMENTS);
> mkdirat(resdirfd, name, 0777);
> + mkdirat(resdirfd, attname, 0777);
> if ((idirfd = openat(resdirfd, name, O_DIRECTORY | O_RDONLY | O_CLOEXEC)) < 0) {
> errf("Error accessing individual test result directory\n");
> return -1;
> }
> + snprintf(attdirname, sizeof(attdirname), "%s/%s",
> + settings->results_path, attname);
>
> if (!open_output_files(idirfd, outputs, true)) {
> errf("Error opening output files\n");
> @@ -1870,6 +1875,7 @@ static int execute_next_entry(struct execute_state *state,
> setenv("IGT_RUNNER_SOCKET_FD", envstring, 1);
> }
> setenv("IGT_SENTINEL_ON_STDERR", "1", 1);
> + setenv("IGT_RUNNER_ATTACHMENTS_DIR", attdirname, 1);
>
> execute_test_process(outfd, errfd, socketfd, settings, entry);
> /* unreachable */
> @@ -1950,7 +1956,10 @@ static int remove_file(int dirfd, const char *name)
>
> static bool clear_test_result_directory(int dirfd)
> {
> - int i;
> + DIR *dir;
> + struct dirent *entry;
> + int i, adirfd;
> + int ret = false;
>
> for (i = 0; i < _F_LAST; i++) {
> if (remove_file(dirfd, filenames[i])) {
> @@ -1960,7 +1969,33 @@ static bool clear_test_result_directory(int dirfd)
> }
> }
>
> - return true;
> + if ((adirfd = openat(dirfd, DIR_ATTACHMENTS, O_DIRECTORY | O_RDONLY | O_CLOEXEC)) < 0) {
> + errf("Cannot open attachments directory\n");
> + return false;
> + }
> +
> + if ((dir = fdopendir(adirfd)) == NULL) {
> + errf("Cannot fdopen attachments directory\n");
> + goto out1;
> + }
> +
> + while ((entry = readdir(dir)) != NULL) {
> + if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))
> + continue;
> +
> + if (unlinkat(adirfd, entry->d_name, 0)) {
> + errf("Error removing %s\n", entry->d_name);
> + goto out2;
> + }
> + }
Since we can't predict that the attachments directory will remain flat,
I think it would be safer to do a recursive cleanup here. I guess we
could use nftw() in a post-order fashion here?
--
Gustavo Sousa
> +
> + ret = true;
> +out2:
> + closedir(dir);
> +out1:
> + close(adirfd);
> +
> + return ret;
> }
>
> static bool clear_old_results(char *path)
> @@ -2002,6 +2037,9 @@ static bool clear_old_results(char *path)
> close(dirfd);
> return false;
> }
> + if (unlinkat(resdirfd, DIR_ATTACHMENTS, AT_REMOVEDIR))
> + errf("Warning: Cannot remove attachments directory\n");
> +
> close(resdirfd);
> if (unlinkat(dirfd, name, AT_REMOVEDIR)) {
> errf("Warning: Result directory %s contains extra files\n",
> diff --git a/runner/executor.h b/runner/executor.h
> index 3b1cabcf55..bc6ac80dc4 100644
> --- a/runner/executor.h
> +++ b/runner/executor.h
> @@ -25,6 +25,8 @@ enum {
> _F_LAST,
> };
>
> +#define DIR_ATTACHMENTS "attachments"
> +
> bool open_output_files(int dirfd, int *fds, bool write);
> bool open_output_files_rdonly(int dirfd, int *fds);
> void close_outputs(int *fds);
> --
> 2.43.0
next prev parent reply other threads:[~2026-03-30 14:21 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 13:12 [PATCH i-g-t v2 0/6] RFC: Add attachments support Zbigniew Kempczyński
2026-03-24 13:12 ` [PATCH i-g-t v2 1/6] runner: Rename dirfd to avoid clash with dirfd() Zbigniew Kempczyński
2026-03-24 13:12 ` [PATCH i-g-t v2 2/6] runner: Create attachments directory to use by hooks Zbigniew Kempczyński
2026-03-30 6:48 ` Krzysztof Karas
2026-04-03 5:18 ` Zbigniew Kempczyński
2026-03-30 14:20 ` Gustavo Sousa [this message]
2026-03-31 16:05 ` Zbigniew Kempczyński
2026-03-31 16:47 ` Gustavo Sousa
2026-03-24 13:12 ` [PATCH i-g-t v2 3/6] runner: Add attachments directory content in subtests results Zbigniew Kempczyński
2026-03-30 7:17 ` Krzysztof Karas
2026-03-30 15:36 ` Gustavo Sousa
2026-03-24 13:12 ` [PATCH i-g-t v2 4/6] scripts/hooks: Example guc log copy script to attachments dir Zbigniew Kempczyński
2026-03-30 7:24 ` Krzysztof Karas
2026-03-24 13:12 ` [PATCH i-g-t v2 5/6] runner: Rename parsing function Zbigniew Kempczyński
2026-03-30 8:07 ` Krzysztof Karas
2026-04-03 5:40 ` Zbigniew Kempczyński
2026-03-24 13:12 ` [PATCH i-g-t v2 6/6] runner: Add hook-exec-allowlist to execute hooks selectively Zbigniew Kempczyński
2026-03-30 8:28 ` Krzysztof Karas
2026-03-30 17:19 ` Gustavo Sousa
2026-04-03 5:55 ` Zbigniew Kempczyński
2026-03-24 19:48 ` ✓ Xe.CI.BAT: success for RFC: Add attachments support (rev2) Patchwork
2026-03-24 21:10 ` ✓ i915.CI.BAT: " Patchwork
2026-03-25 7:25 ` ✗ i915.CI.Full: failure " Patchwork
2026-03-25 10:09 ` ✓ Xe.CI.FULL: success " Patchwork
2026-03-30 9:01 ` [PATCH i-g-t v2 0/6] RFC: Add attachments support Knop, Ryszard
2026-03-30 13:17 ` Kamil Konieczny
2026-03-30 13:52 ` Knop, Ryszard
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=87mrzpxutd.fsf@intel.com \
--to=gustavo.sousa@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
--cc=krzysztof.karas@intel.com \
--cc=ryszard.knop@intel.com \
--cc=zbigniew.kempczynski@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