tests/drv_selftest: Allow passing in module options from the command line
PATCH 1/1 tests/drv_selftest: Allow passing in module options from the command line
From: Tvrtko Ursulin <[email protected]>
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.
--- lib/igt_core.c | 9 +++++++++ lib/igt_kmod.h | 2 ++ tests/drv_selftest.c | 24 ++++++++++++++++++------ 3 files changed, 29 insertions(+), 6 deletions(-)
lib/igt_core.c +9 -0
@@ -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 ;
lib/igt_kmod.h +2 -0
@@ -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 );
tests/drv_selftest.c +18 -6
@@ -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); }
Signature · 6 lines
2.19.1 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoting Tvrtko Ursulin (2018-11-20 18:07:57)
Quoted 7 lines
From: Tvrtko Ursulin <[email protected]>
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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoting Chris Wilson (2018-11-20 18:16:53)
Quoted 6 lines
Quoting Tvrtko Ursulin (2018-11-20 18:07:57)
Quoted 5 lines
From: Tvrtko Ursulin <[email protected]>
A new option '--kmod-options' is added which takes a string which will be passed to modprobe when loading the module.
Quoted 8 lines
Quoted 2 lines
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 insideigt_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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoted 11 lines · Chris Wilson
Quoting Tvrtko Ursulin (2018-11-20 18:07:57)
Quoted 7 lines
From: Tvrtko Ursulin <[email protected]>
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.
Quoted 2 lines
Stashing argc/argv in
igt_subtest_init_parse_opts()and then being able to run getopts insideigt_main{}?
Yep, I didn't know we have this already.
Quoted 2 lines
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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev