blob: 27a2c35b711bcce12e6a3fe2dd7c6f6a15545494 [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
Brad Bishop977dc1a2019-02-06 16:01:43 -05007from oeqa.runtime.decorator.package import OEHasPackage
Brad Bishop6e60e8b2018-02-01 10:27:11 -05008
9class KernelModuleTest(OERuntimeTestCase):
10
11 @classmethod
Brad Bishop977dc1a2019-02-06 16:01:43 -050012 def setUp(cls):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013 src = os.path.join(cls.tc.runtime_files_dir, 'hellomod.c')
14 dst = '/tmp/hellomod.c'
15 cls.tc.target.copyTo(src, dst)
16
17 src = os.path.join(cls.tc.runtime_files_dir, 'hellomod_makefile')
18 dst = '/tmp/Makefile'
19 cls.tc.target.copyTo(src, dst)
20
21 @classmethod
Brad Bishop977dc1a2019-02-06 16:01:43 -050022 def tearDown(cls):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050023 files = '/tmp/Makefile /tmp/hellomod.c'
24 cls.tc.target.run('rm %s' % files)
25
26 @OETestID(1541)
27 @skipIfNotFeature('tools-sdk',
28 'Test requires tools-sdk to be in IMAGE_FEATURES')
29 @OETestDepends(['gcc.GccCompileTest.test_gcc_compile'])
Brad Bishop977dc1a2019-02-06 16:01:43 -050030 @OEHasPackage(['kernel-devsrc'])
31 @OEHasPackage(['make'])
32 @OEHasPackage(['gcc'])
Brad Bishop6e60e8b2018-02-01 10:27:11 -050033 def test_kernel_module(self):
34 cmds = [
Brad Bishop316dfdd2018-06-25 12:45:53 -040035 'cd /usr/src/kernel && make scripts prepare',
Brad Bishop6e60e8b2018-02-01 10:27:11 -050036 'cd /tmp && make',
37 'cd /tmp && insmod hellomod.ko',
38 'lsmod | grep hellomod',
39 'dmesg | grep Hello',
40 'rmmod hellomod', 'dmesg | grep "Cleaning up hellomod"'
41 ]
42 for cmd in cmds:
43 status, output = self.target.run(cmd, 900)
44 self.assertEqual(status, 0, msg='\n'.join([cmd, output]))