summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-12-22 18:05:16 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2016-12-22 18:09:48 +0000
commite6d52317724eaa7314f7d8e53b313f5a5676ecdf (patch)
tree74081b44ca2cd39002fbe62651668d99a19abf6d
parentbc000862e8c6f05a2d960a5a300e1e1d6c8c7026 (diff)
lib/selftest: Query module parameter for error code.
"Live" selftesting of i915.ko happens during device probing which eats the error code and does not propagate it back to module loading. Workaround this by writing the error code back to the module parameter and probing it after a "successful" install. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--lib/igt_kmod.c18
-rw-r--r--lib/igt_kmod.h1
-rw-r--r--tests/drm_mm.c2
-rw-r--r--tests/drv_selftest.c4
4 files changed, 20 insertions, 5 deletions
diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index c41367d8..657a0e55 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -359,8 +359,17 @@ static void tests_add(struct test_list *tl, struct igt_list *list)
igt_list_add_tail(&tl->link, &pos->link);
}
+static int open_parameters(const char *module_name)
+{
+ char path[256];
+
+ snprintf(path, sizeof(path), "/sys/module/%s/parameters", module_name);
+ return open(path, O_RDONLY);
+}
+
void igt_kselftests(const char *module_name,
const char *module_options,
+ const char *result,
const char *filter)
{
const char *param_prefix = "igt__";
@@ -432,13 +441,18 @@ void igt_kselftests(const char *module_name,
tl->param, module_options ?: "");
err = modprobe(kmod, options);
- kmod_module_remove_module(kmod, 0);
-
+ if (err == 0 && result) {
+ int dir = open_parameters(module_name);
+ igt_sysfs_scanf(dir, result, "%d", &err);
+ close(dir);
+ }
if (err == -ENOTTY) /* special case */
err = 0;
if (err)
kmsg_dump(kmsg);
+ kmod_module_remove_module(kmod, 0);
+
errno = 0;
igt_assert_f(err == 0,
"kselftest \"%s %s\" failed: %s [%d]\n",
diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
index 3eb6a345..fc0e6fe6 100644
--- a/lib/igt_kmod.h
+++ b/lib/igt_kmod.h
@@ -37,6 +37,7 @@ int igt_i915_driver_unload(void);
void igt_kselftests(const char *module_name,
const char *module_options,
+ const char *result_option,
const char *filter);
#endif /* IGT_KMOD_H */
diff --git a/tests/drm_mm.c b/tests/drm_mm.c
index 9c49990c..2052b115 100644
--- a/tests/drm_mm.c
+++ b/tests/drm_mm.c
@@ -28,5 +28,5 @@ IGT_TEST_DESCRIPTION("Basic sanity check of DRM's range manager (struct drm_mm)"
igt_main
{
- igt_kselftests("test-drm_mm", NULL, NULL);
+ igt_kselftests("test-drm_mm", NULL, NULL, NULL);
}
diff --git a/tests/drv_selftest.c b/tests/drv_selftest.c
index 3d8ce8e0..96dd8bf1 100644
--- a/tests/drv_selftest.c
+++ b/tests/drv_selftest.c
@@ -28,6 +28,6 @@ IGT_TEST_DESCRIPTION("Basic unit tests for i915.ko");
igt_main
{
- igt_kselftests("i915", "mock_selftests=-1", "mock");
- igt_kselftests("i915", "live_selftests=-1", "live");
+ igt_kselftests("i915", "mock_selftests=-1", NULL, "mock");
+ igt_kselftests("i915", "live_selftests=-1", "live_selftests", "live");
}