[PATCH i-g-t] tests/drv_selftest: Allow passing in module options from the command line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>

A new option '--kmod-options' is added which takes a string which will be
passed to modprobe when loading the module.

This for instance allows easy override of things like the random seed when
trying to reproduce failures.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
---
 lib/igt_core.c       |  9 +++++++++
 lib/igt_kmod.h       |  2 ++
 tests/drv_selftest.c | 24 ++++++++++++++++++------
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index e0989f538aa9..8076d636afa3 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -282,6 +282,7 @@ bool test_child;
 enum {
  OPT_LIST_SUBTESTS,
  OPT_RUN_SUBTEST,
+ OPT_KMOD_OPTIONS,
  OPT_DESCRIPTION,
  OPT_DEBUG,
  OPT_INTERACTIVE_DEBUG,
@@ -302,6 +303,8 @@ GKeyFile *igt_key_file;
 
 char *igt_frame_dump_path;
 
+char *igt_kmod_options;
+
 static bool stderr_needs_sentinel = false;
 
 const char *igt_test_name(void)
@@ -552,6 +555,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
 		   "  --run-subtest <pattern>\n"
 		   "  --debug[=log-domain]\n"
 		   "  --interactive-debug[=domain]\n"
+		   "  --kmod-options=<options-string>\n"
 		   "  --help-description\n"
 		   "  --help\n");
 	if (help_str)
@@ -660,6 +664,7 @@ static int common_init(int *argc, char **argv,
 	static struct option long_options[] = {
 		{"list-subtests", 0, 0, OPT_LIST_SUBTESTS},
 		{"run-subtest", 1, 0, OPT_RUN_SUBTEST},
+		{"kmod-options", 1, 0, OPT_KMOD_OPTIONS},
 		{"help-description", 0, 0, OPT_DESCRIPTION},
 		{"debug", optional_argument, 0, OPT_DEBUG},
 		{"interactive-debug", optional_argument, 0, OPT_INTERACTIVE_DEBUG},
@@ -757,6 +762,10 @@ static int common_init(int *argc, char **argv,
 			if (!list_subtests)
 				run_single_subtest = strdup(optarg);
 			break;
+		case OPT_KMOD_OPTIONS:
+			if (!list_subtests)
+				igt_kmod_options = strdup(optarg);
+			break;
 		case OPT_DESCRIPTION:
 			print_test_description();
 			ret = -1;
diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
index 87d36d400184..e1d286a2e2c1 100644
--- a/lib/igt_kmod.h
+++ b/lib/igt_kmod.h
@@ -28,6 +28,8 @@
 
 #include "igt_list.h"
 
+extern char *igt_kmod_options;
+
 bool igt_kmod_is_loaded(const char *mod_name);
 void igt_kmod_list_loaded(void);
 
diff --git a/tests/drv_selftest.c b/tests/drv_selftest.c
index 80e515c6123b..c67535bf573f 100644
--- a/tests/drv_selftest.c
+++ b/tests/drv_selftest.c
@@ -28,10 +28,22 @@ IGT_TEST_DESCRIPTION("Basic unit tests for i915.ko");
 
 igt_main
 {
-	igt_kselftests("i915",
-		       "mock_selftests=-1 disable_display=1",
-		       NULL, "mock");
-	igt_kselftests("i915",
-		       "live_selftests=-1 disable_display=1",
-		       "live_selftests", "live");
+	const char *live_opts = "live_selftests=-1 disable_display=1";
+	const char *mock_opts = "mock_selftests=-1 disable_display=1";
+	char *opts;
+	int ret;
+
+	/* Mock selftests */
+
+	ret = asprintf(&opts, "%s %s", mock_opts, igt_kmod_options ?: "");
+	igt_assert(ret > 0);
+	igt_kselftests("i915", opts, NULL, "mock");
+	free(opts);
+
+	/* Live selftests */
+
+	ret = asprintf(&opts, "%s %s", live_opts, igt_kmod_options ?: "");
+	igt_assert(ret > 0);
+	igt_kselftests("i915", opts, "live_selftests", "live");
+	free(opts);
 }
-- 
2.19.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux