public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: 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: [PATCH i-g-t v4 3/4] intel-ci/hooks: Add hooks-wrapper and aux scripts/allowlists
Date: Mon, 20 Apr 2026 10:56:57 +0200	[thread overview]
Message-ID: <20260420085653.2587750-9-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20260420085653.2587750-6-zbigniew.kempczynski@intel.com>

CI currently lacks useful GuC logs when some tests are failing. For some
failed executions (not all as copying guc-log is time consuming) using
hook script which will copy it to attachments directory seems to be
simplest solution.

Add copy_guc_log_on_fail.sh script which copies GuC log when test/subtest
is failing. It requires an allowlist to specify for which tests hook
will copy GuC log. It is time consuming process so doing this for all
failed test would extend CI execution time too much.

Apart of this introduce hooks-wrapper.sh which might be main script for
executing hooks. Instead of adding --hook for each script separately it
may be used as a central point of hooks execution. It assumes it will
be executed after test/subtest completion - called hook scripts depends
on the IGT_HOOK_RESULT env var.

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: install hook to datadir/hooks
v3: migrate allowlist from runner to script
v4: adding hooks-wrapper.sh, helpers, etc
---
 tests/intel-ci/hooks/common.helper            | 47 +++++++++++++++++++
 .../hooks/copy_guc_log_on_fail.allowlist      |  2 +
 tests/intel-ci/hooks/copy_guc_log_on_fail.sh  | 24 ++++++++++
 tests/intel-ci/hooks/hook-example.allowlist   |  2 +
 tests/intel-ci/hooks/hook-example.sh          | 17 +++++++
 tests/intel-ci/hooks/hooks-wrapper.sh         | 12 +++++
 tests/intel-ci/meson.build                    | 11 +++++
 7 files changed, 115 insertions(+)
 create mode 100755 tests/intel-ci/hooks/common.helper
 create mode 100644 tests/intel-ci/hooks/copy_guc_log_on_fail.allowlist
 create mode 100755 tests/intel-ci/hooks/copy_guc_log_on_fail.sh
 create mode 100644 tests/intel-ci/hooks/hook-example.allowlist
 create mode 100755 tests/intel-ci/hooks/hook-example.sh
 create mode 100755 tests/intel-ci/hooks/hooks-wrapper.sh

diff --git a/tests/intel-ci/hooks/common.helper b/tests/intel-ci/hooks/common.helper
new file mode 100755
index 0000000000..a3f913f8e8
--- /dev/null
+++ b/tests/intel-ci/hooks/common.helper
@@ -0,0 +1,47 @@
+# Common helper for hooks executed from igt_runner
+#
+# Provide ALLOWLIST="..." as a default, it might be overwritten by --allowlist
+
+for arg in "$@"; do
+    case $arg in
+    --help)
+        echo "Usage: $0 [--help] [--allowlist <name.allowlist>]"
+        echo
+        echo "If name.allowlist is not passed default '${ALLOWLIST}' is used."
+        exit 0
+        ;;
+
+    --allowlist)
+        ALLOWLIST=$2
+        shift 2
+        ;;
+
+        *)
+        shift
+        ;;
+    esac
+done
+
+if [ -z "${IGT_RUNNER_ATTACHMENTS_DIR}" ]; then
+        echo "Missing IGT_RUNNER_ATTACHMENTS_DIR env"
+        exit 0
+fi
+
+# Look for allowlist in following places:
+# 1. Try in IGT_HOOK_ALLOWLIST_DIR if this environment exists
+# 2. Try in <SCRIPTDIR>
+
+if [ ! -z "${IGT_HOOK_ALLOWLIST_DIR}" ]; then
+        ALLOWLIST_PATH="${IGT_HOOK_ALLOWLIST_DIR}/${ALLOWLIST}"
+else
+        ALLOWLIST_PATH="${SCRIPTDIR}/${ALLOWLIST}"
+fi
+
+if [ ! -e "${ALLOWLIST_PATH}" ]; then
+        echo "Missing ${ALLOWLIST_PATH}"
+        exit 0
+fi
+
+if ! echo "${IGT_HOOK_TEST_FULLNAME}" | grep -q -f "$ALLOWLIST_PATH"; then
+        exit 0
+fi
diff --git a/tests/intel-ci/hooks/copy_guc_log_on_fail.allowlist b/tests/intel-ci/hooks/copy_guc_log_on_fail.allowlist
new file mode 100644
index 0000000000..04cb3f8298
--- /dev/null
+++ b/tests/intel-ci/hooks/copy_guc_log_on_fail.allowlist
@@ -0,0 +1,2 @@
+igt@xe_compute@compute-square
+igt@xe_exec_basic@once-basic@ccs0
diff --git a/tests/intel-ci/hooks/copy_guc_log_on_fail.sh b/tests/intel-ci/hooks/copy_guc_log_on_fail.sh
new file mode 100755
index 0000000000..c44c9a5004
--- /dev/null
+++ b/tests/intel-ci/hooks/copy_guc_log_on_fail.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# Hook script for copying guc.log.
+# Suggested usage with:
+# --hook 'post-subtest:tests/intel-ci/hooks/copy_guc_log_on_fail.sh' \
+# --hook 'post-dyn-subtest:tests/intel-ci/hooks/copy_guc_log_on_fail.sh'
+# or within hooks-wrapper.sh
+
+# Copy only for failed subtests as this is time-consuming
+if [ "${IGT_HOOK_RESULT:-FAIL}" != "FAIL" ]; then
+	exit 0
+fi
+
+ALLOWLIST="copy_guc_log_on_fail.allowlist"
+SCRIPTDIR=$(dirname "$(realpath "$0")")
+. "${SCRIPTDIR}/common.helper"
+
+cd "${IGT_RUNNER_ATTACHMENTS_DIR}"
+
+for log in $(find /sys/kernel/debug/dri -iname 'guc_log'); do
+	attout=$(echo ${log:23} | sed -e 's/\//_/g')
+	mkdir -p "${IGT_HOOK_TEST_FULLNAME}"
+	cp "$log" "${IGT_HOOK_TEST_FULLNAME}/${attout}"
+done
diff --git a/tests/intel-ci/hooks/hook-example.allowlist b/tests/intel-ci/hooks/hook-example.allowlist
new file mode 100644
index 0000000000..54cbc0a1d4
--- /dev/null
+++ b/tests/intel-ci/hooks/hook-example.allowlist
@@ -0,0 +1,2 @@
+igt@xe_exec_basic@once-basic@rcs0
+igt@xe_exec_basic@once-basic@ccs0
diff --git a/tests/intel-ci/hooks/hook-example.sh b/tests/intel-ci/hooks/hook-example.sh
new file mode 100755
index 0000000000..512e123567
--- /dev/null
+++ b/tests/intel-ci/hooks/hook-example.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# Hook example, touch <testname>/current-date.txt in attachments dir
+#
+# Suggested usage with:
+# --hook 'post-subtest:tests/intel-ci/hooks/hook-example.sh' \
+# --hook 'post-dyn-subtest:tests/intel-ci/hooks/hook-example.sh'
+# or within hooks-wrapper.sh
+
+ALLOWLIST="hook-example.allowlist"
+SCRIPTDIR=$(dirname "$(realpath "$0")")
+. "${SCRIPTDIR}/common.helper"
+
+cd "${IGT_RUNNER_ATTACHMENTS_DIR}"
+
+mkdir -p "${IGT_HOOK_TEST_FULLNAME}"
+date > "${IGT_HOOK_TEST_FULLNAME}/current-date.txt"
diff --git a/tests/intel-ci/hooks/hooks-wrapper.sh b/tests/intel-ci/hooks/hooks-wrapper.sh
new file mode 100755
index 0000000000..263b81a8b7
--- /dev/null
+++ b/tests/intel-ci/hooks/hooks-wrapper.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# Hooks wrapper
+# Suggested usage with:
+# --hook 'post-subtest:tests/intel-ci/hooks/hooks-wrapper.sh' \
+# --hook 'post-dyn-subtest:tests/intel-ci/hooks/hooks-wrapper.sh'
+
+SCRIPTDIR=$(dirname "$(realpath "$0")")
+
+cd "${SCRIPTDIR}"
+./hook-example.sh
+./copy_guc_log_on_fail.sh
diff --git a/tests/intel-ci/meson.build b/tests/intel-ci/meson.build
index 2b3266bbd9..4a04b6aef8 100644
--- a/tests/intel-ci/meson.build
+++ b/tests/intel-ci/meson.build
@@ -34,8 +34,19 @@ intelci_files = [
   'xe.wcl.core.blocklist.txt',
 ]
 
+hooks_files = [
+  'hooks/common.helper',
+  'hooks/copy_guc_log_on_fail.sh',
+  'hooks/copy_guc_log_on_fail.allowlist',
+  'hooks/hook-example.sh',
+  'hooks/hook-example.allowlist',
+  'hooks/hooks-wrapper.sh',
+]
+
 if meson.version().version_compare('<1.3.0')
   install_data(sources : intelci_files, install_dir : datadir)
+  install_data(sources : hooks_files, install_dir : datadir + '/hooks')
 else
   install_data(sources : intelci_files, install_dir : datadir, follow_symlinks : false)
+  install_data(sources : hooks_files, install_dir : datadir + '/hooks', follow_symlinks : false)
 endif
-- 
2.43.0


  parent reply	other threads:[~2026-04-20  8:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20  8:56 [PATCH i-g-t v4 0/4] RFC: Add attachments support Zbigniew Kempczyński
2026-04-20  8:56 ` [PATCH i-g-t v4 1/4] runner: Rename dirfd to avoid clash with dirfd() Zbigniew Kempczyński
2026-04-20  8:56 ` [PATCH i-g-t v4 2/4] runner: Create attachments directory to use by hooks Zbigniew Kempczyński
2026-04-21  6:57   ` Krzysztof Karas
2026-04-20  8:56 ` Zbigniew Kempczyński [this message]
2026-04-21  8:15   ` [PATCH i-g-t v4 3/4] intel-ci/hooks: Add hooks-wrapper and aux scripts/allowlists Krzysztof Karas
2026-04-21  9:01     ` Zbigniew Kempczyński
2026-04-20  8:56 ` [PATCH i-g-t v4 4/4] runner/resultgen: Insert attachments list into results.json Zbigniew Kempczyński
2026-04-21  8:35   ` Krzysztof Karas

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=20260420085653.2587750-9-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=krzysztof.karas@intel.com \
    --cc=ryszard.knop@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