public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Intel-gfx@lists.freedesktop.org,
	Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Subject: [igt-dev] [PATCH i-g-t] tests/drv_selftest: Allow passing in module options from the command line
Date: Tue, 20 Nov 2018 18:07:57 +0000	[thread overview]
Message-ID: <20181120180757.25494-1-tvrtko.ursulin@linux.intel.com> (raw)

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

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@intel.com>
---
 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

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

             reply	other threads:[~2018-11-20 18:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-20 18:07 Tvrtko Ursulin [this message]
2018-11-20 18:16 ` [igt-dev] [Intel-gfx] [PATCH i-g-t] tests/drv_selftest: Allow passing in module options from the command line Chris Wilson
2018-11-20 18:20   ` Chris Wilson
2018-11-20 18:27   ` Tvrtko Ursulin

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=20181120180757.25494-1-tvrtko.ursulin@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=tvrtko.ursulin@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