summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2014-05-02 12:56:46 -0300
committerLucas De Marchi <lucas.demarchi@intel.com>2014-05-02 12:57:17 -0300
commit3f8dd30a7605f7a14567dad78c619f846d0d5172 (patch)
treec9274fa54b8ebb5eedaf2297a0c0f53a98ee16c8
parentf5cdd574a531ed156d30efe2e06c4cf463469588 (diff)
downloadkmod-3f8dd30a7605f7a14567dad78c619f846d0d5172.tar.gz
kmod-3f8dd30a7605f7a14567dad78c619f846d0d5172.tar.bz2
kmod-3f8dd30a7605f7a14567dad78c619f846d0d5172.zip
testsuite: Add module playground dir
-rw-r--r--testsuite/module-playground/Makefile23
-rw-r--r--testsuite/module-playground/moduleA.c24
-rw-r--r--testsuite/module-playground/moduleB.c25
-rw-r--r--testsuite/module-playground/moduleC.c24
-rw-r--r--testsuite/module-playground/printmodule.h5
5 files changed, 101 insertions, 0 deletions
diff --git a/testsuite/module-playground/Makefile b/testsuite/module-playground/Makefile
new file mode 100644
index 0000000..f606823
--- /dev/null
+++ b/testsuite/module-playground/Makefile
@@ -0,0 +1,23 @@
+ifneq ($(KERNELRELEASE),)
+# kbuild part of makefile
+obj-m := moduleA.o moduleB.o moduleC.o
+else
+# normal makefile
+KDIR ?= /lib/modules/`uname -r`/build
+KVER ?= `uname -r`
+TESTDIR_BASE := /tmp/test-kmod
+TESTDIR := $(TESTDIR_BASE)/lib/modules/$(KVER)/
+
+default:
+ $(MAKE) -C $(KDIR) M=$$PWD
+
+install: default
+ mkdir -p $(TESTDIR)/kernel/
+ cp *.ko $(TESTDIR)/kernel/
+ cp modules.order $(TESTDIR)
+ depmod -a -b $(TESTDIR_BASE) $(KVER)
+
+clean:
+ $(MAKE) -C $(KDIR) M=$$PWD clean
+
+endif
diff --git a/testsuite/module-playground/moduleA.c b/testsuite/module-playground/moduleA.c
new file mode 100644
index 0000000..f1041ac
--- /dev/null
+++ b/testsuite/module-playground/moduleA.c
@@ -0,0 +1,24 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/printk.h>
+
+#include "printmodule.h"
+
+static int __init test_module_init(void)
+{
+ printA();
+ printB();
+ return 0;
+}
+module_init(test_module_init);
+
+void printA(void)
+{
+ pr_warn("Hello, world A\n");
+}
+EXPORT_SYMBOL(printA);
+
+MODULE_AUTHOR("Lucas De Marchi <lucas.demarchi@intel.com>");
+MODULE_LICENSE("GPL");
diff --git a/testsuite/module-playground/moduleB.c b/testsuite/module-playground/moduleB.c
new file mode 100644
index 0000000..ae13f53
--- /dev/null
+++ b/testsuite/module-playground/moduleB.c
@@ -0,0 +1,25 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/printk.h>
+
+#include "printmodule.h"
+
+static int __init test_module_init(void)
+{
+ printB();
+ printC();
+
+ return 0;
+}
+module_init(test_module_init);
+
+void printB(void)
+{
+ pr_warn("Hello, world B\n");
+}
+EXPORT_SYMBOL(printB);
+
+MODULE_AUTHOR("Lucas De Marchi <lucas.demarchi@intel.com>");
+MODULE_LICENSE("GPL");
diff --git a/testsuite/module-playground/moduleC.c b/testsuite/module-playground/moduleC.c
new file mode 100644
index 0000000..b74cb07
--- /dev/null
+++ b/testsuite/module-playground/moduleC.c
@@ -0,0 +1,24 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/printk.h>
+
+#include "printmodule.h"
+
+static int __init test_module_init(void)
+{
+ printC();
+ printB();
+ return 0;
+}
+module_init(test_module_init);
+
+void printC(void)
+{
+ pr_warn("Hello, world C\n");
+}
+EXPORT_SYMBOL(printC);
+
+MODULE_AUTHOR("Lucas De Marchi <lucas.demarchi@intel.com>");
+MODULE_LICENSE("GPL");
diff --git a/testsuite/module-playground/printmodule.h b/testsuite/module-playground/printmodule.h
new file mode 100644
index 0000000..8505377
--- /dev/null
+++ b/testsuite/module-playground/printmodule.h
@@ -0,0 +1,5 @@
+#pragma once
+
+void printA(void);
+void printB(void);
+void printC(void);