summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases
diff options
context:
space:
mode:
authorMazliana <mazliana.mohamad@intel.com>2019-08-23 10:29:18 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-08-28 11:31:21 +0100
commit1b376420f6816b184144adf45b25ac91830e356c (patch)
tree40dc5b931d36b705acbcede68d4643111d62bff8 /meta/lib/oeqa/selftest/cases
parented929bed4cccdf9836dff149ac8beab62abbfbd3 (diff)
downloadpoky-1b376420f6816b184144adf45b25ac91830e356c.tar.gz
oeqa/kerneldevelopment: Able to apply a single patch to the Linux kernel source
Purpose of kernel development is basically to customize our own recipes kernel by reused existing recipes.   This is an initiative of automating manual kernel development test cases. Applying a single patch to the Linux kernel source is one of the manual test cases of kernel development. Objective of this test is as a developer we can make changes of a file in kernel source and able to apply a single patch to the kernel source.   ref:https://wiki.yoctoproject.org/wiki/Kernel_Development_Test_Cases (From OE-Core rev: 00a5df641b94ef47eec36e742630db7b659102a4) Signed-off-by: Mazliana <mazliana.mohamad@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases')
-rw-r--r--meta/lib/oeqa/selftest/cases/kerneldevelopment.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/kerneldevelopment.py b/meta/lib/oeqa/selftest/cases/kerneldevelopment.py
new file mode 100644
index 0000000000..a61876ee61
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/kerneldevelopment.py
@@ -0,0 +1,67 @@
1import os
2from oeqa.selftest.case import OESelftestTestCase
3from oeqa.utils.commands import runCmd, get_bb_var
4from oeqa.utils.git import GitRepo
5
6class KernelDev(OESelftestTestCase):
7
8 @classmethod
9 def setUpClass(cls):
10 super(KernelDev, cls).setUpClass()
11 # Create the recipe directory structure inside the created layer
12 cls.layername = 'meta-kerneltest'
13 runCmd('bitbake-layers create-layer %s' % cls.layername)
14 runCmd('mkdir -p %s/recipes-kernel/linux/linux-yocto' % cls.layername)
15 cls.recipes_linuxyocto_dir = os.path.join \
16 (cls.builddir, cls.layername, 'recipes-kernel', 'linux', 'linux-yocto')
17 cls.recipeskernel_dir = os.path.dirname(cls.recipes_linuxyocto_dir)
18 runCmd('bitbake-layers add-layer %s' % cls.layername)
19
20 @classmethod
21 def tearDownClass(cls):
22 runCmd('bitbake-layers remove-layer %s' % cls.layername, ignore_status=True)
23 runCmd('rm -rf %s' % cls.layername)
24 super(KernelDev, cls).tearDownClass()
25
26 def setUp(self):
27 super(KernelDev, self).setUp()
28 self.set_machine_config('MACHINE = "qemux86-64"\n')
29
30 def test_apply_patches(self):
31 """
32 Summary: Able to apply a single patch to the Linux kernel source
33 Expected: The README file should exist and the patch changes should be
34 displayed at the end of the file.
35 Product: Kernel Development
36 Author: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
37 AutomatedBy: Mazliana Mohamad <mazliana.mohamad@intel.com>
38 """
39 runCmd('bitbake virtual/kernel -c patch')
40 kernel_source = get_bb_var('STAGING_KERNEL_DIR')
41 readme = os.path.join(kernel_source, 'README')
42
43 # This test step adds modified file 'README' to git and creates a
44 # patch file '0001-KERNEL_DEV_TEST_CASE.patch' at the same location as file
45 patch_content = 'This is a test to apply a patch to the kernel'
46 with open(readme, 'a+') as f:
47 f.write(patch_content)
48 repo = GitRepo('%s' % kernel_source, is_topdir=True)
49 repo.run_cmd('add %s' % readme)
50 repo.run_cmd(['commit', '-m', 'KERNEL_DEV_TEST_CASE'])
51 repo.run_cmd(['format-patch', '-1'])
52 patch_name = '0001-KERNEL_DEV_TEST_CASE.patch'
53 patchpath = os.path.join(kernel_source, patch_name)
54 runCmd('mv %s %s' % (patchpath, self.recipes_linuxyocto_dir))
55 runCmd('rm %s ' % readme)
56 self.assertFalse(os.path.exists(readme))
57
58 recipe_append = os.path.join(self.recipeskernel_dir, 'linux-yocto_%.bbappend')
59 with open(recipe_append, 'w+') as fh:
60 fh.write('SRC_URI += "file://%s"\n' % patch_name)
61 fh.write('FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"')
62
63 runCmd('bitbake virtual/kernel -c clean')
64 runCmd('bitbake virtual/kernel -c patch')
65 self.assertTrue(os.path.exists(readme))
66 result = runCmd('tail -n 1 %s' % readme)
67 self.assertEqual(result.output, patch_content)