summaryrefslogtreecommitdiff
path: root/runner
diff options
context:
space:
mode:
authorGustavo Sousa <gustavo.sousa@intel.com>2024-08-14 17:47:58 -0300
committerMatt Roper <matthew.d.roper@intel.com>2024-08-21 09:46:00 -0700
commitef3f0c02c6e7f7ae4d4ef293e59c9299d2c8b540 (patch)
tree60d308cc230c2b7564cf4788df154977f0d1eb46 /runner
parentfe4d0a3aa3fb0bbebc23a691449b5f44715e3332 (diff)
runner: Add option --hook
Now that we have support for setting a hook script for test cases, let's also add the option --hook to igt_runner, which forwards it to test executables. Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com> Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com> Link: https://lore.kernel.org/r/20240814204822.95283-4-gustavo.sousa@intel.com Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Diffstat (limited to 'runner')
-rw-r--r--runner/executor.c7
-rw-r--r--runner/runner_tests.c5
-rw-r--r--runner/settings.c25
-rw-r--r--runner/settings.h1
4 files changed, 37 insertions, 1 deletions
diff --git a/runner/executor.c b/runner/executor.c
index a135cd46b..a23cd58c0 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -1564,6 +1564,13 @@ execute_test_process(int outfd, int errfd, int socketfd,
}
}
+ if (settings->hook_str) {
+ arg = strdup("--hook");
+ igt_vec_push(&arg_vec, &arg);
+ arg = strdup(settings->hook_str);
+ igt_vec_push(&arg_vec, &arg);
+ }
+
arg = NULL;
igt_vec_push(&arg_vec, &arg);
diff --git a/runner/runner_tests.c b/runner/runner_tests.c
index 0aa7dd662..7470cc240 100644
--- a/runner/runner_tests.c
+++ b/runner/runner_tests.c
@@ -202,6 +202,7 @@ static void assert_settings_equal(struct settings *one, struct settings *two)
igt_assert_eq(one->piglit_style_dmesg, two->piglit_style_dmesg);
igt_assert_eq(one->dmesg_warn_level, two->dmesg_warn_level);
igt_assert_eq(one->prune_mode, two->prune_mode);
+ igt_assert_eqstr(one->hook_str, two->hook_str);
}
static void assert_job_list_equal(struct job_list *one, struct job_list *two)
@@ -302,6 +303,7 @@ igt_main
igt_assert_eq(settings->overall_timeout, 0);
igt_assert(!settings->use_watchdog);
igt_assert_eq(settings->prune_mode, 0);
+ igt_assert(!settings->hook_str);
igt_assert(strstr(settings->test_root, "test-root-dir") != NULL);
igt_assert(strstr(settings->results_path, "path-to-results") != NULL);
@@ -464,6 +466,7 @@ igt_main
"--collect-code-cov",
"--coverage-per-test",
"--collect-script", "/usr/bin/true",
+ "--hook", "echo hello",
"--prune-mode=keep-subtests",
"test-root-dir",
"path-to-results",
@@ -511,6 +514,7 @@ igt_main
igt_assert_eq(settings->per_test_timeout, 72);
igt_assert_eq(settings->overall_timeout, 360);
igt_assert(settings->use_watchdog);
+ igt_assert_eqstr(settings->hook_str, "echo hello");
igt_assert_eq(settings->prune_mode, PRUNE_KEEP_SUBTESTS);
igt_assert(strstr(settings->test_root, "test-root-dir") != NULL);
igt_assert(strstr(settings->results_path, "path-to-results") != NULL);
@@ -961,6 +965,7 @@ igt_main
"--use-watchdog",
"--piglit-style-dmesg",
"--prune-mode=keep-all",
+ "--hook", "echo hello",
testdatadir,
dirname,
};
diff --git a/runner/settings.c b/runner/settings.c
index 42d8137f1..e554a5c70 100644
--- a/runner/settings.c
+++ b/runner/settings.c
@@ -1,3 +1,4 @@
+#include "igt_hook.h"
#include "settings.h"
#include "version.h"
@@ -28,6 +29,8 @@ enum {
OPT_CODE_COV_SCRIPT,
OPT_ENABLE_CODE_COVERAGE,
OPT_COV_RESULTS_PER_TEST,
+ OPT_HOOK,
+ OPT_HELP_HOOK,
OPT_VERSION,
OPT_PRUNE_MODE,
OPT_HELP = 'h',
@@ -297,6 +300,10 @@ static const char *usage_str =
" Requires --collect-script FILENAME\n"
" --collect-script FILENAME\n"
" Use FILENAME as script to collect code coverage data.\n"
+ " --hook HOOK_STR\n"
+ " Forward HOOK_STR to the --hook option of each test.\n"
+ " --help-hook\n"
+ " Show detailed usage information for --hook.\n"
"\n"
" [test_root] Directory that contains the IGT tests. The environment\n"
" variable IGT_TEST_ROOT will be used if set, overriding\n"
@@ -654,6 +661,8 @@ bool parse_options(int argc, char **argv,
{"collect-code-cov", no_argument, NULL, OPT_ENABLE_CODE_COVERAGE},
{"coverage-per-test", no_argument, NULL, OPT_COV_RESULTS_PER_TEST},
{"collect-script", required_argument, NULL, OPT_CODE_COV_SCRIPT},
+ {"hook", required_argument, NULL, OPT_HOOK},
+ {"help-hook", no_argument, NULL, OPT_HELP_HOOK},
{"multiple-mode", no_argument, NULL, OPT_MULTIPLE},
{"inactivity-timeout", required_argument, NULL, OPT_TIMEOUT},
{"per-test-timeout", required_argument, NULL, OPT_PER_TEST_TIMEOUT},
@@ -741,7 +750,19 @@ bool parse_options(int argc, char **argv,
case OPT_CODE_COV_SCRIPT:
settings->code_coverage_script = bin_path(optarg);
break;
-
+ case OPT_HOOK:
+ /* FIXME: In order to allow line breaks, we should
+ * change the format of settings serialization. Maybe
+ * use JSON instead of our own format? */
+ if (strchr(optarg, '\n')) {
+ fprintf(stderr, "Newlines in --hook are currently unsupported.\n");
+ goto error;
+ }
+ settings->hook_str = optarg;
+ break;
+ case OPT_HELP_HOOK:
+ igt_hook_print_help(stdout, "--hook");
+ goto error;
case OPT_MULTIPLE:
settings->multiple_mode = true;
break;
@@ -1040,6 +1061,7 @@ bool serialize_settings(struct settings *settings)
SERIALIZE_LINE(f, settings, enable_code_coverage, "%d");
SERIALIZE_LINE(f, settings, cov_results_per_test, "%d");
SERIALIZE_LINE(f, settings, code_coverage_script, "%s");
+ SERIALIZE_LINE(f, settings, hook_str, "%s");
if (settings->sync) {
fflush(f);
@@ -1103,6 +1125,7 @@ bool read_settings_from_file(struct settings *settings, FILE *f)
PARSE_LINE(settings, name, val, enable_code_coverage, numval);
PARSE_LINE(settings, name, val, cov_results_per_test, numval);
PARSE_LINE(settings, name, val, code_coverage_script, val ? strdup(val) : NULL);
+ PARSE_LINE(settings, name, val, hook_str, val ? strdup(val) : NULL);
printf("Warning: Unknown field in settings file: %s = %s\n",
name, val);
diff --git a/runner/settings.h b/runner/settings.h
index 819c34602..d3afb56de 100644
--- a/runner/settings.h
+++ b/runner/settings.h
@@ -72,6 +72,7 @@ struct settings {
char *code_coverage_script;
bool enable_code_coverage;
bool cov_results_per_test;
+ char *hook_str;
};
/**