[oe-commits] [openembedded-core] 26/26: oeqa/kerneldevelopment: Able to apply a single patch to the Linux kernel source

git at git.openembedded.org git at git.openembedded.org
Thu Aug 22 08:26:10 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 02180a3bbd74cbfcc425480f80f74628bc69b6c2
Author: Mazliana <mazliana.mohamad at intel.com>
AuthorDate: Thu Aug 22 16:15:38 2019 +0800

    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
    
    Signed-off-by: Mazliana <mazliana.mohamad at intel.com
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/lib/oeqa/selftest/cases/kerneldevelopment.py | 65 +++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/meta/lib/oeqa/selftest/cases/kerneldevelopment.py b/meta/lib/oeqa/selftest/cases/kerneldevelopment.py
new file mode 100644
index 0000000..15cef40
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/kerneldevelopment.py
@@ -0,0 +1,65 @@
+import os
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, runCmd, get_bb_var
+from oeqa.utils.git import GitRepo, GitError
+
+class KernelDev(OESelftestTestCase):
+
+    @classmethod 
+    def setUpClass(cls):
+        super(KernelDev, cls).setUpClass()
+        # Create the recipe directory structure inside the created layer
+        cls.layername = 'meta-kerneltest'
+        runCmd('bitbake-layers create-layer %s' %cls.layername)
+        runCmd('mkdir -p %s/recipes-kernel/linux/linux-yocto' %cls.layername)
+        cls.recipes_linuxyocto_dir=os.path.join(cls.builddir, cls.layername, 'recipes-kernel', 'linux', 'linux-yocto')
+        cls.recipeskernel_dir=os.path.dirname(cls.recipes_linuxyocto_dir)
+        runCmd('bitbake-layers add-layer %s' %cls.layername)
+        
+    @classmethod
+    def tearDownClass(cls):
+        runCmd('bitbake-layers remove-layer %s' %cls.layername, ignore_status=True)
+        runCmd('rm -rf %s' %cls.layername)
+        super(KernelDev, cls).tearDownClass()
+        
+    def setUp(self):
+        super(KernelDev, self).setUp()
+        self.set_machine_config('MACHINE = "%s"\n' %'qemux86-64')
+        
+    def test_apply_patches(self):
+        """
+        Summary:     Able to apply a single patch to the Linux kernel source
+        Expected:    The README file should exist and the patch changes should be 
+                     displayed at the end of the file. 
+        Product:     Kernel Development
+        Author:      Yeoh Ee Peng <ee.peng.yeoh at intel.com>
+        AutomatedBy: Mazliana Mohamad <mazliana.mohamad at intel.com>
+        """
+        runCmd('bitbake virtual/kernel -c patch')
+        kernel_source = get_bb_var('STAGING_KERNEL_DIR')
+        readme = os.path.join(kernel_source,'README')
+        
+        # This test step adds modified file 'README' to git and creates a 
+        # patch file '0001-KERNEL_DEV_TEST_CASE.patch' at the same location as file
+        patch_content = 'This is a test to apply a patch to the kernel'
+        runCmd('echo %s >> %s' %(patch_content,readme))
+        repo=GitRepo('%s' %kernel_source,is_topdir=True)
+        repo.run_cmd('add %s'%readme)
+        repo.run_cmd(['commit', '-m', 'KERNEL_DEV_TEST_CASE'])
+        repo.run_cmd(['format-patch', '-1'])
+        patch_name = '0001-KERNEL_DEV_TEST_CASE.patch'
+        patchpath = os.path.join(kernel_source, patch_name)
+        runCmd('mv %s %s' %(patchpath, self.recipes_linuxyocto_dir))
+        runCmd('rm %s ' %readme)
+        self.assertFalse(os.path.exists(readme))
+        
+        recipe_append = os.path.join(self.recipeskernel_dir,'linux-yocto_%.bbappend')
+        with open(recipe_append, 'w+') as fh:
+            fh.write('SRC_URI += "file://%s"\n' %patch_name)
+            fh.write('FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"')
+        
+        runCmd('bitbake virtual/kernel -c cleansstate')  
+        runCmd('bitbake virtual/kernel -c patch')
+        self.assertTrue(os.path.exists(readme))  
+        result = runCmd('tail -n 1 %s' %readme)
+        self.assertEqual(result.output, patch_content)
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list