kernelmodule.py 1.4 KB

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