All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] igt/drv_module_reload: Revamp fault-injection
@ 2018-06-06 13:09 Chris Wilson
  2018-06-06 14:18 ` Michał Winiarski
                   ` (4 more replies)
  0 siblings, 5 replies; 19+ messages in thread
From: Chris Wilson @ 2018-06-06 13:09 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev

The current method of checking for a failed module load is flawed, as we
only report the error on probing it is not being reported back by
modprobe. So we have to dig inside the module_parameters while the
module is still loaded to discover the error.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Michał Winiarski <michal.winiarski@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
---
 tests/drv_module_reload.c | 48 +++++++++++++++++++++++++++++++++++----
 1 file changed, 43 insertions(+), 5 deletions(-)

diff --git a/tests/drv_module_reload.c b/tests/drv_module_reload.c
index 092982960..e6bc354b6 100644
--- a/tests/drv_module_reload.c
+++ b/tests/drv_module_reload.c
@@ -234,6 +234,41 @@ reload(const char *opts_i915)
 	return err;
 }
 
+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);
+}
+
+static int
+inject_fault(const char *module_name, const char *opt, int fault)
+{
+	char buf[1024];
+	int dir, err;
+
+	snprintf(buf, sizeof(buf), "%s=%d", opt, fault);
+
+	if (igt_kmod_load(module_name, buf)) {
+		igt_warn("Failed to load module '%s' with options '%s'\n",
+			 module_name, buf);
+		return 1;
+	}
+
+	err = 1;
+	dir = open_parameters(module_name);
+	igt_sysfs_scanf(dir, opt, "%d", &err);
+	close(dir);
+
+	igt_kmod_unload(module_name, 0);
+
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
 static void
 gem_sanitycheck(void)
 {
@@ -323,12 +358,15 @@ igt_main
 		igt_assert_eq(reload("disable_display=1"), 0);
 
 	igt_subtest("basic-reload-inject") {
-		char buf[64];
 		int i = 0;
-		do {
-			snprintf(buf, sizeof(buf),
-				 "inject_load_failure=%d", ++i);
-		} while (reload(buf));
+
+		igt_i915_driver_unload();
+
+		while (inject_fault("i915", "inject_load_failure", ++i) < 0)
+			;
+
+		/* We expect to hit at least one fault! */
+		igt_assert(i > 1);
 	}
 
 	igt_fixture {
-- 
2.17.1

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

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

end of thread, other threads:[~2018-06-07 14:56 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-06 13:09 [PATCH i-g-t] igt/drv_module_reload: Revamp fault-injection Chris Wilson
2018-06-06 14:18 ` Michał Winiarski
2018-06-06 14:30   ` Chris Wilson
2018-06-06 17:42 ` [PATCH i-g-t v2] " Chris Wilson
2018-06-06 17:42   ` [Intel-gfx] " Chris Wilson
2018-06-06 18:00   ` Imre Deak
2018-06-06 18:00     ` [igt-dev] " Imre Deak
2018-06-06 18:04     ` Chris Wilson
2018-06-06 18:04       ` [Intel-gfx] " Chris Wilson
2018-06-06 18:15       ` Imre Deak
2018-06-06 18:15         ` [igt-dev] " Imre Deak
2018-06-06 20:48   ` Antonio Argenziano
2018-06-06 20:48     ` Antonio Argenziano
2018-06-06 20:54     ` Chris Wilson
2018-06-06 20:54       ` Chris Wilson
2018-06-06 18:36 ` [igt-dev] ✗ Fi.CI.BAT: failure for " Patchwork
2018-06-07 10:49 ` Patchwork
2018-06-07 10:56   ` Chris Wilson
2018-06-07 14:56 ` [igt-dev] ✗ Fi.CI.IGT: " Patchwork

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.