All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] tests/drv_selftest: Allow passing in module options from the command line
@ 2018-11-20 18:07 ` Tvrtko Ursulin
  0 siblings, 0 replies; 8+ messages in thread
From: Tvrtko Ursulin @ 2018-11-20 18:07 UTC (permalink / raw)
  To: igt-dev; +Cc: Intel-gfx

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

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [igt-dev] [PATCH i-g-t] tests/drv_selftest: Allow passing in module options from the command line
@ 2018-11-20 18:07 ` Tvrtko Ursulin
  0 siblings, 0 replies; 8+ messages in thread
From: Tvrtko Ursulin @ 2018-11-20 18:07 UTC (permalink / raw)
  To: igt-dev; +Cc: Intel-gfx, Tvrtko Ursulin

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH i-g-t] tests/drv_selftest: Allow passing in module options from the command line
  2018-11-20 18:07 ` [igt-dev] " Tvrtko Ursulin
@ 2018-11-20 18:16   ` Chris Wilson
  -1 siblings, 0 replies; 8+ messages in thread
From: Chris Wilson @ 2018-11-20 18:16 UTC (permalink / raw)
  To: Tvrtko Ursulin, igt-dev; +Cc: Intel-gfx

Quoting Tvrtko Ursulin (2018-11-20 18:07:57)
> 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.
 
Anyway we can simply extend the option parsing locally? (Just find it
unsightly to have test specific options in libigt.)

Stashing argc/argv in igt_subtest_init_parse_opts() and then being able
to run getopts inside igt_main {}?

I also had in mind an env for module options, which may be also useful
for the module reloading and autoloading.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [igt-dev] [Intel-gfx] [PATCH i-g-t] tests/drv_selftest: Allow passing in module options from the command line
@ 2018-11-20 18:16   ` Chris Wilson
  0 siblings, 0 replies; 8+ messages in thread
From: Chris Wilson @ 2018-11-20 18:16 UTC (permalink / raw)
  To: Tvrtko Ursulin, igt-dev; +Cc: Intel-gfx

Quoting Tvrtko Ursulin (2018-11-20 18:07:57)
> 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.
 
Anyway we can simply extend the option parsing locally? (Just find it
unsightly to have test specific options in libigt.)

Stashing argc/argv in igt_subtest_init_parse_opts() and then being able
to run getopts inside igt_main {}?

I also had in mind an env for module options, which may be also useful
for the module reloading and autoloading.
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH i-g-t] tests/drv_selftest: Allow passing in module options from the command line
  2018-11-20 18:16   ` [igt-dev] [Intel-gfx] " Chris Wilson
@ 2018-11-20 18:20     ` Chris Wilson
  -1 siblings, 0 replies; 8+ messages in thread
From: Chris Wilson @ 2018-11-20 18:20 UTC (permalink / raw)
  To: Tvrtko Ursulin, igt-dev; +Cc: Intel-gfx

Quoting Chris Wilson (2018-11-20 18:16:53)
> Quoting Tvrtko Ursulin (2018-11-20 18:07:57)
> > 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.
>  
> Anyway we can simply extend the option parsing locally? (Just find it
> unsightly to have test specific options in libigt.)
> 
> Stashing argc/argv in igt_subtest_init_parse_opts() and then being able
> to run getopts inside igt_main {}?

Or perhaps,

#define igt_main_argv \
        static void igt_tokencat(__real_main, __LINE__)(int argc, char **argv); \
        int main(int argc, char **argv) { \
                igt_subtest_init_parse_opts(&argc, argv, NULL, NULL, NULL, \
                                            NULL, NULL); \
                igt_tokencat(__real_main, __LINE__)(argc, char **argv); \
                igt_exit(); \
        } \
        static void igt_tokencat(__real_main, __LINE__)(int argc, char **argv) \
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [igt-dev] [Intel-gfx] [PATCH i-g-t] tests/drv_selftest: Allow passing in module options from the command line
@ 2018-11-20 18:20     ` Chris Wilson
  0 siblings, 0 replies; 8+ messages in thread
From: Chris Wilson @ 2018-11-20 18:20 UTC (permalink / raw)
  To: Tvrtko Ursulin, igt-dev; +Cc: Intel-gfx

Quoting Chris Wilson (2018-11-20 18:16:53)
> Quoting Tvrtko Ursulin (2018-11-20 18:07:57)
> > 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.
>  
> Anyway we can simply extend the option parsing locally? (Just find it
> unsightly to have test specific options in libigt.)
> 
> Stashing argc/argv in igt_subtest_init_parse_opts() and then being able
> to run getopts inside igt_main {}?

Or perhaps,

#define igt_main_argv \
        static void igt_tokencat(__real_main, __LINE__)(int argc, char **argv); \
        int main(int argc, char **argv) { \
                igt_subtest_init_parse_opts(&argc, argv, NULL, NULL, NULL, \
                                            NULL, NULL); \
                igt_tokencat(__real_main, __LINE__)(argc, char **argv); \
                igt_exit(); \
        } \
        static void igt_tokencat(__real_main, __LINE__)(int argc, char **argv) \
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH i-g-t] tests/drv_selftest: Allow passing in module options from the command line
  2018-11-20 18:16   ` [igt-dev] [Intel-gfx] " Chris Wilson
@ 2018-11-20 18:27     ` Tvrtko Ursulin
  -1 siblings, 0 replies; 8+ messages in thread
From: Tvrtko Ursulin @ 2018-11-20 18:27 UTC (permalink / raw)
  To: Chris Wilson, igt-dev; +Cc: Intel-gfx, Lucas De Marchi


On 20/11/2018 18:16, Chris Wilson wrote:
> Quoting Tvrtko Ursulin (2018-11-20 18:07:57)
>> 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.
>   
> Anyway we can simply extend the option parsing locally? (Just find it
> unsightly to have test specific options in libigt.)

Well.. it is not test specific but kmod specific but point still stands.

> Stashing argc/argv in igt_subtest_init_parse_opts() and then being able
> to run getopts inside igt_main {}?

Yep, I didn't know we have this already.

> I also had in mind an env for module options, which may be also useful
> for the module reloading and autoloading.

In that case, since modprobe(8) supports MODPROBE_OPTIONS, we could 
perhaps emulate that in igt_kmod? Or add support directly to libkmod? 
With either we wouldn't even need the command line pass through. Adding 
Lucas for an opinion since kmod seems to be his baby.

Regards,

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [igt-dev] [Intel-gfx] [PATCH i-g-t] tests/drv_selftest: Allow passing in module options from the command line
@ 2018-11-20 18:27     ` Tvrtko Ursulin
  0 siblings, 0 replies; 8+ messages in thread
From: Tvrtko Ursulin @ 2018-11-20 18:27 UTC (permalink / raw)
  To: Chris Wilson, igt-dev; +Cc: Intel-gfx, Lucas De Marchi


On 20/11/2018 18:16, Chris Wilson wrote:
> Quoting Tvrtko Ursulin (2018-11-20 18:07:57)
>> 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.
>   
> Anyway we can simply extend the option parsing locally? (Just find it
> unsightly to have test specific options in libigt.)

Well.. it is not test specific but kmod specific but point still stands.

> Stashing argc/argv in igt_subtest_init_parse_opts() and then being able
> to run getopts inside igt_main {}?

Yep, I didn't know we have this already.

> I also had in mind an env for module options, which may be also useful
> for the module reloading and autoloading.

In that case, since modprobe(8) supports MODPROBE_OPTIONS, we could 
perhaps emulate that in igt_kmod? Or add support directly to libkmod? 
With either we wouldn't even need the command line pass through. Adding 
Lucas for an opinion since kmod seems to be his baby.

Regards,

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-11-20 18:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-20 18:07 [PATCH i-g-t] tests/drv_selftest: Allow passing in module options from the command line Tvrtko Ursulin
2018-11-20 18:07 ` [igt-dev] " Tvrtko Ursulin
2018-11-20 18:16 ` Chris Wilson
2018-11-20 18:16   ` [igt-dev] [Intel-gfx] " Chris Wilson
2018-11-20 18:20   ` Chris Wilson
2018-11-20 18:20     ` [igt-dev] [Intel-gfx] " Chris Wilson
2018-11-20 18:27   ` Tvrtko Ursulin
2018-11-20 18:27     ` [igt-dev] [Intel-gfx] " Tvrtko Ursulin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.