diff options
| -rw-r--r-- | meta/classes/testimage.bbclass | 2 | ||||
| -rw-r--r-- | meta/lib/oeqa/runtime/files/hellomod.c | 19 | ||||
| -rw-r--r-- | meta/lib/oeqa/runtime/files/hellomod_makefile | 8 | ||||
| -rw-r--r-- | meta/lib/oeqa/runtime/kernelmodule.py | 33 |
4 files changed, 61 insertions, 1 deletions
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass index 2f9c974554..5d61c2baee 100644 --- a/meta/classes/testimage.bbclass +++ b/meta/classes/testimage.bbclass | |||
| @@ -28,7 +28,7 @@ TEST_LOG_DIR ?= "${WORKDIR}/testimage" | |||
| 28 | DEFAULT_TEST_SUITES = "ping auto" | 28 | DEFAULT_TEST_SUITES = "ping auto" |
| 29 | DEFAULT_TEST_SUITES_pn-core-image-minimal = "ping" | 29 | DEFAULT_TEST_SUITES_pn-core-image-minimal = "ping" |
| 30 | DEFAULT_TEST_SUITES_pn-core-image-sato = "ping ssh df connman syslog xorg scp vnc date rpm smart dmesg" | 30 | DEFAULT_TEST_SUITES_pn-core-image-sato = "ping ssh df connman syslog xorg scp vnc date rpm smart dmesg" |
| 31 | DEFAULT_TEST_SUITES_pn-core-image-sato-sdk = "ping ssh df connman syslog xorg scp vnc date perl ldd gcc rpm smart dmesg" | 31 | DEFAULT_TEST_SUITES_pn-core-image-sato-sdk = "ping ssh df connman syslog xorg scp vnc date perl ldd gcc rpm smart kernelmodule dmesg" |
| 32 | 32 | ||
| 33 | TEST_SUITES ?= "${DEFAULT_TEST_SUITES}" | 33 | TEST_SUITES ?= "${DEFAULT_TEST_SUITES}" |
| 34 | 34 | ||
diff --git a/meta/lib/oeqa/runtime/files/hellomod.c b/meta/lib/oeqa/runtime/files/hellomod.c new file mode 100644 index 0000000000..a383397e93 --- /dev/null +++ b/meta/lib/oeqa/runtime/files/hellomod.c | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | #include <linux/module.h> | ||
| 2 | #include <linux/kernel.h> | ||
| 3 | #include <linux/init.h> | ||
| 4 | |||
| 5 | static int __init hello_init(void) | ||
| 6 | { | ||
| 7 | printk(KERN_INFO "Hello world!\n"); | ||
| 8 | return 0; | ||
| 9 | } | ||
| 10 | |||
| 11 | static void __exit hello_cleanup(void) | ||
| 12 | { | ||
| 13 | printk(KERN_INFO "Cleaning up hellomod.\n"); | ||
| 14 | } | ||
| 15 | |||
| 16 | module_init(hello_init); | ||
| 17 | module_exit(hello_cleanup); | ||
| 18 | |||
| 19 | MODULE_LICENSE("GPL"); | ||
diff --git a/meta/lib/oeqa/runtime/files/hellomod_makefile b/meta/lib/oeqa/runtime/files/hellomod_makefile new file mode 100644 index 0000000000..b92d5c8fe0 --- /dev/null +++ b/meta/lib/oeqa/runtime/files/hellomod_makefile | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | obj-m := hellomod.o | ||
| 2 | KDIR := /usr/src/kernel | ||
| 3 | |||
| 4 | all: | ||
| 5 | $(MAKE) -C $(KDIR) M=$(PWD) modules | ||
| 6 | |||
| 7 | clean: | ||
| 8 | $(MAKE) -C $(KDIR) M=$(PWD) clean | ||
diff --git a/meta/lib/oeqa/runtime/kernelmodule.py b/meta/lib/oeqa/runtime/kernelmodule.py new file mode 100644 index 0000000000..cbc5742eff --- /dev/null +++ b/meta/lib/oeqa/runtime/kernelmodule.py | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | import unittest | ||
| 2 | import os | ||
| 3 | from oeqa.oetest import oeRuntimeTest, skipModule | ||
| 4 | from oeqa.utils.decorators import * | ||
| 5 | |||
| 6 | def setUpModule(): | ||
| 7 | if not oeRuntimeTest.hasFeature("tools-sdk"): | ||
| 8 | skipModule("Image doesn't have tools-sdk in IMAGE_FEATURES") | ||
| 9 | |||
| 10 | |||
| 11 | class KernelModuleTest(oeRuntimeTest): | ||
| 12 | |||
| 13 | def setUp(self): | ||
| 14 | self.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "hellomod.c"), "/tmp/hellomod.c") | ||
| 15 | self.target.copy_to(os.path.join(oeRuntimeTest.tc.filesdir, "hellomod_makefile"), "/tmp/Makefile") | ||
| 16 | |||
| 17 | @skipUnlessPassed('test_ssh') | ||
| 18 | @skipUnlessPassed('test_gcc_compile') | ||
| 19 | def test_kernel_module(self): | ||
| 20 | cmds = [ | ||
| 21 | 'cd /usr/src/kernel && make scripts', | ||
| 22 | 'cd /tmp && make', | ||
| 23 | 'cd /tmp && insmod hellomod.ko', | ||
| 24 | 'lsmod | grep hellomod', | ||
| 25 | 'dmesg | grep Hello', | ||
| 26 | 'rmmod hellomod', 'dmesg | grep "Cleaning up hellomod"' | ||
| 27 | ] | ||
| 28 | for cmd in cmds: | ||
| 29 | (status, output) = self.target.run(cmd, 900) | ||
| 30 | self.assertEqual(status, 0, msg="\n".join([cmd, output])) | ||
| 31 | |||
| 32 | def tearDown(self): | ||
| 33 | self.target.run('rm -f /tmp/Makefile /tmp/hellomod.c') | ||
