blob: 11ad7b7f01b519ddee7875296f9549bdb3a5b64b [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001import os
2
3from oeqa.runtime.case import OERuntimeTestCase
4from oeqa.core.decorator.depends import OETestDepends
5from oeqa.core.decorator.oeid import OETestID
6from oeqa.core.decorator.data import skipIfNotFeature
7
8class KernelModuleTest(OERuntimeTestCase):
9
10 @classmethod
11 def setUpClass(cls):
12 src = os.path.join(cls.tc.runtime_files_dir, 'hellomod.c')
13 dst = '/tmp/hellomod.c'
14 cls.tc.target.copyTo(src, dst)
15
16 src = os.path.join(cls.tc.runtime_files_dir, 'hellomod_makefile')
17 dst = '/tmp/Makefile'
18 cls.tc.target.copyTo(src, dst)
19
20 @classmethod
21 def tearDownClass(cls):
22 files = '/tmp/Makefile /tmp/hellomod.c'
23 cls.tc.target.run('rm %s' % files)
24
25 @OETestID(1541)
26 @skipIfNotFeature('tools-sdk',
27 'Test requires tools-sdk to be in IMAGE_FEATURES')
28 @OETestDepends(['gcc.GccCompileTest.test_gcc_compile'])
29 def test_kernel_module(self):
30 cmds = [
31 'cd /usr/src/kernel && make scripts',
32 'cd /tmp && make',
33 'cd /tmp && insmod hellomod.ko',
34 'lsmod | grep hellomod',
35 'dmesg | grep Hello',
36 'rmmod hellomod', 'dmesg | grep "Cleaning up hellomod"'
37 ]
38 for cmd in cmds:
39 status, output = self.target.run(cmd, 900)
40 self.assertEqual(status, 0, msg='\n'.join([cmd, output]))