[PATCH i-g-t] lib/igt_core: Add helper detecting CI environment
Lukasz Laguna
lukasz.laguna at intel.com
Fri Dec 6 08:28:22 UTC 2024
Helper determines if the code is running in CI environment by checking
the INTEL_CI environment variable. It can be useful for reducing number
of dynamic subtests executed in CI runs. While some subtests should be
defined, because they can be valuable for debugging or platform bring
up, running all of them in CI for every build is not always necessary.
For example, in the case of SR-IOV tests, while the ability to run test
on a specific VF is important, executing it on all possible VFs in CI
for every build might not be required. In many cases, testing on a single
random VF is sufficient and testing on every possible VF would
significantly increase execution time and CI infrastructure load.
Signed-off-by: Lukasz Laguna <lukasz.laguna at intel.com>
---
lib/igt_core.c | 21 +++++++++++++++++++++
lib/igt_core.h | 3 +++
2 files changed, 24 insertions(+)
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 407f7b551..50759c170 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -3060,6 +3060,27 @@ err:
igt_assert_f(0, "failed to install the signal handler\n");
}
+/**
+ * igt_run_in_ci:
+ *
+ * This function can be used to reduce number of dynamic subtests when running
+ * in CI environment. While some subtests should be defined, because they can
+ * be useful during debugging or platform bring-up, executing all of them in CI
+ * for every build is not always necessary. This i-g-t mode is selected by
+ * setting the INTEL_CI environment variable to 1.
+ *
+ * Returns: True when run in CI environment, false otherwise.
+ */
+bool igt_run_in_ci(void)
+{
+ static int ci = -1;
+
+ if (ci == -1)
+ ci = igt_check_boolean_env_var("INTEL_CI", false);
+
+ return ci;
+}
+
/* simulation enviroment support */
/**
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 90f57402f..1c75312f4 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -1221,6 +1221,9 @@ typedef void (*igt_exit_handler_t)(int sig);
/* reliable atexit helpers, also work when killed by a signal (if possible) */
void igt_install_exit_handler(igt_exit_handler_t fn);
+/* helper to automatically reduce number of dynamic subtests when running in CI environment */
+bool igt_run_in_ci(void);
+
/* helpers to automatically reduce test runtime in simulation */
bool igt_run_in_simulation(void);
/**
--
2.40.0
More information about the igt-dev
mailing list