[PATCH i-g-t] tests/i915_module_load: Use new name of fault injection module parameter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Janusz Krzysztofik <janusz.krzysztofik@xxxxxxxxxxxxxxx>

Name of the i915 module parameter providing fault injection function is
changing for consistency with a new convention of naming i915 driver
internal functions called from the driver PCI .probe entry point.  Adjust
the test to use the new name.

[ickle: keep the old parameter name around for stable testing]

Suggested-by: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@xxxxxxxxxxxxxxx>
Cc: Michał Wajdeczko <michal.wajdeczko@xxxxxxxxx>
Cc: Michał Winiarski <michal.winiarski@xxxxxxxxx>
Cc: Piotr Piórkowski <piotr.piorkowski@xxxxxxxxx>
Cc: Tomasz Lis <tomasz.lis@xxxxxxxxx>
Cc: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>
Reviewed-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
---
 lib/igt_kmod.c                | 40 +++++++++++++++++++++++++++++++++++
 lib/igt_kmod.h                |  2 ++
 tests/i915/i915_module_load.c |  8 ++++++-
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index c3da46678..f43da9f42 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -153,6 +153,46 @@ static int modprobe(struct kmod_module *kmod, const char *options)
 					       NULL, NULL, NULL);
 }
 
+/**
+ * igt_kmod_has_param:
+ * @mod_name: The name of the module
+ * @param: The name of the parameter
+ *
+ * Returns: true if the module has the parameter, false otherwise.
+ */
+bool igt_kmod_has_param(const char *module_name, const char *param)
+{
+	struct kmod_module *kmod;
+	struct kmod_list *d, *pre;
+	bool result = false;
+
+	if (kmod_module_new_from_name(kmod_ctx(), module_name, &kmod))
+		return false;
+
+	pre = NULL;
+	if (!kmod_module_get_info(kmod, &pre))
+		goto out;
+
+	kmod_list_foreach(d, pre) {
+		const char *key, *val;
+
+		key = kmod_module_info_get_key(d);
+		if (strcmp(key, "parmtype"))
+			continue;
+
+		val = kmod_module_info_get_value(d);
+		if (val && strcmp(val, param) == 0) {
+			result = true;
+			break;
+		}
+	}
+	kmod_module_info_free_list(pre);
+
+out:
+	kmod_module_unref(kmod);
+	return result;
+}
+
 /**
  * igt_kmod_load:
  * @mod_name: The name of the module
diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
index 87d36d400..e47ff2df6 100644
--- a/lib/igt_kmod.h
+++ b/lib/igt_kmod.h
@@ -31,6 +31,8 @@
 bool igt_kmod_is_loaded(const char *mod_name);
 void igt_kmod_list_loaded(void);
 
+bool igt_kmod_has_param(const char *mod_name, const char *param);
+
 int igt_kmod_load(const char *mod_name, const char *opts);
 int igt_kmod_unload(const char *mod_name, unsigned int flags);
 
diff --git a/tests/i915/i915_module_load.c b/tests/i915/i915_module_load.c
index f42083f53..7d9a5cfd2 100644
--- a/tests/i915/i915_module_load.c
+++ b/tests/i915/i915_module_load.c
@@ -350,11 +350,17 @@ igt_main
 	}
 
 	igt_subtest("reload-with-fault-injection") {
+		const char *param;
 		int i = 0;
 
 		igt_i915_driver_unload();
 
-		while (inject_fault("i915", "inject_load_failure", ++i) == 0)
+		param = "inject_probe_failure";
+		if (!igt_kmod_has_param("i915", param))
+			param = "inject_load_failure";
+		igt_require(igt_kmod_has_param("i915", param));
+
+		while (inject_fault("i915", param, ++i) == 0)
 			;
 
 		/* We expect to hit at least one fault! */
-- 
2.24.0.rc1

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




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux