[igt-dev] [PATCH i-g-t 16/29] lib/igt_kmod: add null implementation

D Scott Phillips d.scott.phillips at intel.com
Wed Dec 11 00:52:22 UTC 2019


igt_kmod depends on libkmod, which is only available on Linux. Add
a do-nothing implementation of the same API for inclusion on other
platforms.

Signed-off-by: D Scott Phillips <d.scott.phillips at intel.com>
---
 lib/igt_kmod.h      |  2 ++
 lib/igt_kmod_null.c | 84 +++++++++++++++++++++++++++++++++++++++++++++
 lib/meson.build     |  3 +-
 3 files changed, 88 insertions(+), 1 deletion(-)
 create mode 100644 lib/igt_kmod_null.c

diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
index c71ec147..cd374609 100644
--- a/lib/igt_kmod.h
+++ b/lib/igt_kmod.h
@@ -24,7 +24,9 @@
 #ifndef IGT_KMOD_H
 #define IGT_KMOD_H
 
+#if defined(__linux__)
 #include <libkmod.h>
+#endif
 
 #include "igt_list.h"
 
diff --git a/lib/igt_kmod_null.c b/lib/igt_kmod_null.c
new file mode 100644
index 00000000..9df64e8f
--- /dev/null
+++ b/lib/igt_kmod_null.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright © 2019 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "igt_kmod.h"
+
+bool igt_kmod_is_loaded(const char *mod_name) {
+	return true;
+}
+
+void igt_kmod_list_loaded(void) {
+}
+
+bool igt_kmod_has_param(const char *mod_name, const char *param) {
+	return true;
+}
+
+int igt_kmod_load(const char *mod_name, const char *opts) {
+	return 0;
+}
+
+int igt_kmod_unload(const char *mod_name, unsigned int flags) {
+	return 0;
+}
+
+int igt_i915_driver_load(const char *opts) {
+	return 0;
+}
+
+int igt_i915_driver_unload(void) {
+	return 0;
+}
+
+void igt_kselftests(const char *module_name,
+		    const char *module_options,
+		    const char *result_option,
+		    const char *filter) {
+}
+
+int igt_kselftest_init(struct igt_kselftest *tst,
+		       const char *module_name) {
+	return 0;
+}
+
+int igt_kselftest_begin(struct igt_kselftest *tst) {
+	return 0;
+}
+
+void igt_kselftest_get_tests(struct kmod_module *kmod,
+			     const char *filter,
+			     struct igt_list_head *tests) {
+}
+
+int igt_kselftest_execute(struct igt_kselftest *tst,
+			  struct igt_kselftest_list *tl,
+			  const char *module_options,
+			  const char *result) {
+	return 0;
+}
+
+void igt_kselftest_end(struct igt_kselftest *tst) {
+}
+
+void igt_kselftest_fini(struct igt_kselftest *tst) {
+}
diff --git a/lib/meson.build b/lib/meson.build
index 6a56fff0..4a58d9cf 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -54,7 +54,6 @@ lib_sources = [
 	'igt_pm.c',
 	'igt_dummyload.c',
 	'uwildmat/uwildmat.c',
-	'igt_kmod.c',
 	'igt_panfrost.c',
 	'igt_v3d.c',
 	'igt_vc4.c',
@@ -69,10 +68,12 @@ lib_sources = [
 if host_machine.system() == 'linux'
 	lib_sources += [
 		'igt_aux.c',
+		'igt_kmod.c',
 	]
 else
 	lib_sources += [
 		'igt_aux_null.c',
+		'igt_kmod_null.c',
 	]
 endif
 
-- 
2.23.0



More information about the igt-dev mailing list