summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hello0
-rw-r--r--meta/lib/oeqa/selftest/cases/kernel_dev.py140
-rw-r--r--meta/lib/oeqa/selftest/cases/kernel_pre.py54
-rw-r--r--meta/lib/oeqa/selftest/cases/kernel_setup.py62
-rw-r--r--meta/lib/oeqa/selftest/cases/kernel_test1.py66
-rw-r--r--meta/lib/oeqa/selftest/cases/kernel_test2.py31
-rw-r--r--meta/lib/oeqa/selftest/cases/kernel_test3.py35
7 files changed, 253 insertions, 135 deletions
diff --git a/hello b/hello
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/hello
+++ /dev/null
diff --git a/meta/lib/oeqa/selftest/cases/kernel_dev.py b/meta/lib/oeqa/selftest/cases/kernel_dev.py
index ad68737b317..e8db23de3f1 100644
--- a/meta/lib/oeqa/selftest/cases/kernel_dev.py
+++ b/meta/lib/oeqa/selftest/cases/kernel_dev.py
@@ -1,47 +1,67 @@
-import sys
import os
-import re
from oeqa.selftest.case import OESelftestTestCase
from oeqa.utils.commands import bitbake, runqemu, get_bb_var, runCmd
from oeqa.utils.git import GitRepo, GitError
class KernelDev(OESelftestTestCase):
+ @classmethod
+ def setUpClass(cls):
+ global poky_path, kernel_local_repo_path, linux_kernel_version, linuxkernelversion
+ super(KernelDev, cls).setUpClass()
+# custom_machine = 'qemux86-64'
+# machine_conf = 'MACHINE = "%s"\n' %custom_machine
+# cls.set_machine_config(cls, machine_conf)
+ cls.image = 'core-image-minimal'
+ bitbake(cls.image)
+ builddir = os.environ.get('BUILDDIR')
+ poky_path = os.path.dirname(builddir)
+ base_path = os.path.dirname(poky_path)
+ '''Grep linux kernel version'''
+ result = runCmd('bitbake virtual/kernel -e | grep LINUX_VERSION= > kernel_version')
+ with open ('kernel_version', 'r') as file:
+ for line in file:
+ linux_kernel_version = line.strip()
+ linux_kernel_version = linux_kernel_version.split("\"")[1]
+ linux_kernel_version = linux_kernel_version.split(".")[0] + "." + linux_kernel_version.split(".")[1]
+ linuxkernelversion = linux_kernel_version.split(".")[0]
+ '''Kernel recipe directory structure'''
+ cls.layername = 'meta-kerneltest'
+ result = runCmd('bitbake-layers create-layer %s' %cls.layername, cwd=poky_path)
+ cls.layerpath = os.path.join(poky_path, cls.layername)
+ result =runCmd('mkdir -p %s/recipes-kernel/linux/linux-yocto/' %cls.layername, cwd=poky_path)
+ result =runCmd('mkdir -p %s/recipes-kernel/linux/linux-yocto-custom/' %cls.layername, cwd=poky_path)
+ result =runCmd('touch %s/recipes-kernel/linux/linux-yocto_%s%%.bbappend' %(cls.layername ,linuxkernelversion), cwd=poky_path)
+ src = poky_path + ('/meta/recipes-kernel/linux/linux-yocto_%s.bb' %linux_kernel_version)
+ dest = poky_path + ('/%s/recipes-kernel/linux/linux-yocto-custom_%s.bb' %(cls.layername, linux_kernel_version))
+ result = runCmd('cp %s %s' %(src, dest))
+ result = runCmd('bitbake-layers add-layer ../%s' %cls.layername, cwd=builddir)
+ '''Kernel Local Repo'''
+ result = runCmd('mkdir -p kernel_local_repo', cwd=base_path)
+ kernel_local_repo_path = os.path.join(base_path, 'kernel_local_repo')
+ result = runCmd('git clone git://git.yoctoproject.org/yocto-kernel-cache', cwd=kernel_local_repo_path)
+ kernelcache_path = os.path.join(kernel_local_repo_path, 'yocto-kernel-cache')
+ result = runCmd('git checkout yocto-%s' %linux_kernel_version, cwd=kernelcache_path)
+ result = runCmd('git clone git://git.yoctoproject.org/linux-yocto', cwd=kernel_local_repo_path)
+ linuxyocto_path = os.path.join(kernel_local_repo_path, 'linux-yocto')
+ result = runCmd('git checkout v%s/standard/base' %linux_kernel_version, cwd =linuxyocto_path)
+
+ @classmethod
+ def tearDownClass(cls):
+ runCmd('bitbake-layers remove-layer %s' %cls.layername, ignore_status=True)
+ runCmd('rm -rf %s' %cls.layerpath)
+ super(KernelDev, cls).tearDownClass()
- def setUp(self):
- #common prerequisites
- super(KernelDev, self).setUp()
- global build_path, poky_path
- self.recipe = 'core-image-minimal'
- self.machine = 'qemux86-64'
- self.write_config(
-'''
-MACHINE = '%s'
-'''
-% (self.machine)
- )
- bitbake(self.recipe)
- result = runCmd('bitbake virtual/kernel -e | grep LINUX_VERSION= | cut -b 16-19')
- linux_kernel_version = result.output
- build_path = os.environ.get('BUILDDIR')
- poky_path, tail = os.path.split(build_path)
- poky_dir = os.chdir(poky_path)
- layername = 'meta-kerneltest'
- result = runCmd('bitbake-layers create-layer %s' %layername)
- self.assertTrue(os.path.exists(layername), '%s should exist' % layername)
- result =runCmd('mkdir -p ' + layername +'/recipes-kernel/linux/linux-yocto/')
- result =runCmd('mkdir -p ' + layername +'/recipes-kernel/linux/linux-yocto-custom/')
- result =runCmd('touch ' + layername + '/recipes-kernel/linux/linux-yocto_4%.bbappend')
- path_copy_from = poky_path + ('/meta/recipes-kernel/linux/linux-yocto_%s.bb' %linux_kernel_version)
- path_copy_to = poky_path + ('/%s/recipes-kernel/linux/linux-yocto-custom_%s.bb' %(layername, linux_kernel_version))
- result = runCmd('cp %s %s' %(path_copy_from, path_copy_to))
- build_dir = os.chdir(build_path)
- result = runCmd('bitbake-layers add-layer ../%s' %layername)
- result = runCmd('bitbake-layers show-layers')
- find_in_contents = re.search(re.escape(layername) + r'\s+', result.output)
- self.assertTrue(find_in_contents, "%s found in layers\n%s" % (layername, result.output))
-
def test_apply_patches(self):
- #tc01_kd_apply_patches
+ #TC_KD_01-Applying Patches
+ """
+ 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@intel.com>
+ AutomatedBy: Mazliana Mohamad <mazliana.mohamad@intel.com>
+ """
+ self.builddir = os.environ.get('BUILDDIR')
+ poky_path = os.path.dirname(self.builddir)
result = runCmd('echo This is a test to apply a patch to the kernel. >> tmp/work-shared/qemux86-64/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
repo = GitRepo('tmp/work-shared/qemux86-64/kernel-source', is_topdir=True)
@@ -52,20 +72,46 @@ MACHINE = '%s'
repo.run_cmd(git_commit)
git_patch = ['format-patch', '-1']
repo.run_cmd(git_patch)
- poky_dir = os.chdir(poky_path)
- patch_file = build_path + '/tmp/work-shared/qemux86-64/kernel-source/0001-KERNEL-DEV-TEST-CASE.patch'
- linux_yocto_path = poky_path + '/meta-kerneltest/recipes-kernel/linux/linux-yocto/'
- result = runCmd('mv %s %s' %(patch_file, linux_yocto_path))
+ patch_file = self.builddir + '/tmp/work-shared/qemux86-64/kernel-source/0001-KERNEL-DEV-TEST-CASE.patch'
+ layername = 'meta-kerneltest'
+ linux_yocto_path = poky_path + ('/%s/recipes-kernel/linux/linux-yocto/' %layername)
+ result = runCmd('mv %s %s' %(patch_file, linux_yocto_path), cwd=self.builddir)
self.assertFalse(os.path.exists(patch_file))
- recipe_append = poky_path + '/meta-kerneltest/recipes-kernel/linux/linux-yocto_4%.bbappend'
+ recipe_append = poky_path + ('/%s/recipes-kernel/linux/linux-yocto_%s%%.bbappend' %(layername,linuxkernelversion))
with open (recipe_append, 'w') as file:
file.write('SRC_URI += \'file://0001-KERNEL-DEV-TEST-CASE.patch\'' + '\n')
file.write('FILESEXTRAPATHS_prepend := \'${THISDIR}/${PN}:\'')
- readme_path = build_path + '/tmp/work-shared/qemux86-64/kernel-source/README'
- result = runCmd('rm %s ' %readme_path)
- self.assertFalse(os.path.exists(readme_path))
+ readme_file = self.builddir + '/tmp/work-shared/qemux86-64/kernel-source/README'
+ result = runCmd('rm %s ' %readme_file)
+ self.assertFalse(os.path.exists(readme_file))
result = runCmd('bitbake virtual/kernel -c cleansstate')
result = runCmd('bitbake virtual/kernel -c patch')
- self.assertTrue(os.path.exists(readme_path))
- result = runCmd('tail -n 1 %s ' %readme_path)
- self.assertEqual(result.output, 'This is a test to apply a patch to the kernel.') \ No newline at end of file
+ self.assertTrue(os.path.exists(readme_file))
+ result = runCmd('tail -n 1 %s ' %readme_file)
+ self.assertEqual(result.output, 'This is a test to apply a patch to the kernel.')
+
+ def test_linuxyocto_local_source(self):
+ #TC_KD_02-linux-yocto_Local_Source
+ """
+ Summary: Able to work with my own Linux kernel sources
+ Expected: Bitbake variables output should display that the SRC_URI variable
+ Product: Kernel Development
+ Author: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
+ AutomatedBy: Mazliana Mohamad <mazliana.mohamad@intel.com>
+ """
+ self.append_config(
+'''
+PREFERRED_VERSION_linux-yocto_qemux86-64 = '%s%%'
+'''
+% (linux_kernel_version)
+ )
+ url = "SRC_URI = \"git://%s/linux-yocto;protocol=file;name=machine;branch=${KBRANCH}; git://%s/yocto-kernel-cache;protocol=file;type=kmeta;name=meta;branch=yocto-%s;destsuffix=${KMETA}\"" %(kernel_local_repo_path,kernel_local_repo_path,linux_kernel_version)
+ layername = 'meta-kerneltest'
+ recipe_append = poky_path + ('/%s/recipes-kernel/linux/linux-yocto_%s%%.bbappend' %(layername,linuxkernelversion))
+ with open (recipe_append, 'w') as file:
+ file.write(url)
+ os.chdir(self.builddir)
+ result = runCmd('bitbake virtual/kernel -c cleansstate')
+ result = runCmd('bitbake virtual/kernel')
+ result = runCmd('bitbake virtual/kernel -e | grep "SRC_URI="')
+ self.assertIn('git://%s'%kernel_local_repo_path ,result.output) \ No newline at end of file
diff --git a/meta/lib/oeqa/selftest/cases/kernel_pre.py b/meta/lib/oeqa/selftest/cases/kernel_pre.py
deleted file mode 100644
index 2e8dc464279..00000000000
--- a/meta/lib/oeqa/selftest/cases/kernel_pre.py
+++ /dev/null
@@ -1,54 +0,0 @@
-import sys
-import os
-import re
-from oeqa.selftest.case import OESelftestTestCase
-from oeqa.utils.commands import bitbake, runqemu, get_bb_var, runCmd
-
-class KernelDev(OESelftestTestCase):
-
- def setUpLocal(self):
- super(KernelDev, self).setUpLocal()
- self.recipe = 'core-image-minimal'
- self.machine = 'qemux86-64'
- self.write_config(
-"""
-MACHINE = "%s"
-"""
-% (self.machine)
- )
- bitbake(self.recipe)
-
- def test_agetMachine(self):
- getmachine = get_bb_var('MACHINE')
- self.assertEqual(getmachine, 'qemux86-64')
-
- def test_bgetLinuxVersion(self):
- result = runCmd('bitbake virtual/kernel -e | grep LINUX_VERSION=')
- getlinuxversion = runCmd('bitbake virtual/kernel -e | grep LINUX_VERSION= > kernel_version')
- with open ('kernel_version', 'r') as file:
- for line in file:
- linux_kernel_version = line.strip()
- self.assertEqual(result.output, linux_kernel_version)
- linux_kernel_version = linux_kernel_version.split("\"")[1]
- linux_kernel_version = linux_kernel_version.split(".")[0] + "." + linux_kernel_version.split(".")[1]
- build_path = os.environ.get('BUILDDIR')
- poky_path, tail = os.path.split(build_path)
- poky_dir = os.chdir(poky_path)
- layername = 'meta-kernelautomated'
- layerpath = os.path.exists(layername)
- self.assertTrue(os.path.exists(layerpath), '%s should not exist at this point in time' % layerpath)
- result = runCmd('bitbake-layers create-layer %s' %layername)
- self.assertTrue(os.path.exists(layerpath), '%s should exist' % layerpath)
- dir_recipe = runCmd('mkdir -p ' + layername +'/recipes-kernel/linux/')
- dir_linux_yocto =runCmd('mkdir ' + layername +'/recipes-kernel/linux/linux-yocto/')
- dir_linux_yocto_custom =runCmd('mkdir ' + layername +'/recipes-kernel/linux/linux-yocto-custom/')
- recipe_append =runCmd('touch ' + layername + '/recipes-kernel/linux/linux-yocto_4%.bbappend')
- path_copy_from = poky_path + ("/meta/recipes-kernel/linux/linux-yocto_%s.bb" %linux_kernel_version)
- path_copy_to = poky_path + ("/%s/recipes-kernel/linux/linux-yocto_custom_%s.bb" %(layername, linux_kernel_version))
- result_copy = runCmd('cp %s %s' %(path_copy_from, path_copy_to))
- #with open (path_copy_to, 'a') as file:
- #file.write('PV = \"${%s}\"' %linux_kernel_version )
- build_dir = os.chdir(build_path)
- result = runCmd('bitbake-layers add-layer ../%s' %layername)
-
-
diff --git a/meta/lib/oeqa/selftest/cases/kernel_setup.py b/meta/lib/oeqa/selftest/cases/kernel_setup.py
new file mode 100644
index 00000000000..24b5216ffa4
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/kernel_setup.py
@@ -0,0 +1,62 @@
+import os
+import re
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, runqemu, get_bb_var, runCmd
+
+class KernelDev(OESelftestTestCase):
+ def setUp(self):
+ '''
+ Each test case depend on prerequisites
+ Problem: This prerequisites should be able setup on time only so that we not repetative same process. Also reduce time to rebuild image
+ '''
+ global linux_kernel_version, poky_path, linux_yocto_path, recipe, recipe_append, kernel_local_repo_path
+ super(KernelDev, self).setUp()
+ self.image = 'core-image-minimal'
+ self.machine = 'qemux86-64'
+ self.set_machine_config(
+'''
+MACHINE = '%s'
+'''
+% (self.machine)
+ )
+ bitbake(self.image)
+ result = runCmd('bitbake virtual/kernel -e | grep LINUX_VERSION= | cut -b 16-19')
+ linux_kernel_version = result.output
+ poky_path = os.path.dirname(os.path.realpath(self.builddir))
+ layername = 'meta-kerneltest'
+ result = runCmd('bitbake-layers create-layer %s' %layername, cwd=poky_path)
+ layerpath = os.path.join(poky_path, layername)
+ self.assertTrue(os.path.exists(layerpath), '%s should exist' % layerpath)
+ result =runCmd('mkdir -p %s/recipes-kernel/linux/linux-yocto/' %layername, cwd=poky_path)
+ linux_yocto_path = os.path.join(poky_path, 'meta-kerneltest/recipes-kernel/linux/linux-yocto/')
+ result =runCmd('mkdir -p %s/recipes-kernel/linux/linux-yocto-custom/' %layername, cwd=poky_path)
+ result =runCmd('touch %s/recipes-kernel/linux/linux-yocto_4%%.bbappend' %layername, cwd=poky_path)
+ recipe_append = os.path.join(poky_path, 'meta-kerneltest/recipes-kernel/linux/linux-yocto_4%.bbappend')
+ src_recipe = os.path.join(poky_path,'meta/recipes-kernel/linux/linux-yocto_%s.bb' %linux_kernel_version)
+ recipe = os.path.join(poky_path, '%s/recipes-kernel/linux/linux-yocto-custom_%s.bb' %(layername, linux_kernel_version))
+ result = runCmd('cp %s %s' %(src_recipe, recipe))
+ result = runCmd('bitbake-layers add-layer ../%s' %layername, cwd=self.builddir)
+ result = runCmd('bitbake-layers show-layers', cwd=self.builddir)
+ find_in_contents = re.search(re.escape(layername) + r'\s+', result.output)
+ self.assertTrue(find_in_contents, "%s found in layers\n%s" % (layername, result.output))
+
+ base_path = os.path.dirname(poky_path)
+ result = runCmd('mkdir kernel_local_repo', cwd=base_path)
+ kernel_local_repo_path = os.path.join(base_path, 'kernel_local_repo')
+ result = runCmd('git clone git://git.yoctoproject.org/yocto-kernel-cache', cwd=kernel_local_repo_path)
+ kernelcache_path = os.path.join(kernel_local_repo_path, 'yocto-kernel-cache')
+ result = runCmd('git checkout yocto-4.18', cwd=kernelcache_path)
+ result = runCmd('git clone git://git.yoctoproject.org/linux-yocto', cwd=kernel_local_repo_path)
+ linuxyocto_path = os.path.join(kernel_local_repo_path, 'linux-yocto')
+ result = runCmd('git checkout v%s/standard/base' %linux_kernel_version, cwd =linuxyocto_path)
+
+ def tearDown(self):
+ runCmd('bitbake-layers remove-layer %s' % layername)
+ runCmd('rm -rf %s' % layerpath)
+ runCmd('rm -rf %s' % kernel_local_repo_path)
+ super(KernelDev, self).tearDown()
+
+
+# def test_agetMachine(self):
+# getmachine = get_bb_var('MACHINE')
+# self.assertEqual(getmachine, 'qemux86-64') \ No newline at end of file
diff --git a/meta/lib/oeqa/selftest/cases/kernel_test1.py b/meta/lib/oeqa/selftest/cases/kernel_test1.py
index 4e56453f3f9..1b61861ea16 100644
--- a/meta/lib/oeqa/selftest/cases/kernel_test1.py
+++ b/meta/lib/oeqa/selftest/cases/kernel_test1.py
@@ -1,41 +1,39 @@
-import sys
import os
-import logging
from oeqa.selftest.case import OESelftestTestCase
-from oeqa.utils.commands import bitbake, runqemu, get_bb_var, runCmd
+from oeqa.utils.commands import bitbake, runCmd
from oeqa.utils.git import GitRepo, GitError
class KernelDevTc(OESelftestTestCase):
- def test_createpatch(self):
- writetoreadme = runCmd("echo This is a test to apply a patch to the kernel. >> tmp/work-shared/qemux86-64/kernel-source/README")
- self.assertEqual(writetoreadme.output, "")
- #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
- repo = GitRepo("tmp/work-shared/qemux86-64/kernel-source", is_topdir=True)
+ 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@intel.com>
+ Author: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
+ AutomatedBy: Mazliana Mohamad <mazliana.mohamad@intel.com>
+ """
+ result = runCmd('echo This is a test to apply a patch to the kernel. >> tmp/work-shared/qemux86-64/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
+ repo = GitRepo('tmp/work-shared/qemux86-64/kernel-source', is_topdir=True)
git_work_tree = os.path.abspath('tmp/work-shared/qemux86-64/kernel-source/README')
repo.run_cmd('add %s' %(git_work_tree))
- commit_message = "KERNEL DEV TEST CASE"
- git_cmd_commit = ['commit', '-m', commit_message]
- repo.run_cmd(git_cmd_commit)
- git_cmd_patch = ['format-patch', '-1']
- repo.run_cmd(git_cmd_patch)
-
- def test_existingpatch(self):
- build_path = os.environ.get('BUILDDIR')
- poky_path, tail = os.path.split(build_path)
- poky_dir = os.chdir(poky_path)
- patch_file = build_path + '/tmp/work-shared/qemux86-64/kernel-source/0001-KERNEL-DEV-TEST-CASE.patch'
- new_path = poky_path + '/meta-kerneltest/recipes-kernel/linux/linux-yocto/'
- result = runCmd('mv %s %s' %(patch_file, new_path))
- self.assertEqual(result.output, "")
- file_name = poky_path + '/meta-kerneltest/recipes-kernel/linux/linux-yocto_4%.bbappend'
- with open (file_name, 'w') as file:
- file.write("SRC_URI += \"file://0001-KERNEL-DEV-TEST-CASE.patch\"" + "\n")
- file.write('FILESEXTRAPATHS_prepend := \"${THISDIR}/${PN}:\"')
- readme_path = build_path + '/tmp/work-shared/qemux86-64/kernel-source/README'
- remove_readme_file = runCmd('rm %s ' %readme_path)
- self.assertEqual(remove_readme_file.output, "")
- run_cleanstate = runCmd('bitbake virtual/kernel -c cleansstate')
- run_buildpatch = runCmd('bitbake virtual/kernel -c patch')
- file_exists = os.path.exists(readme_path)
- tail_readme_file = runCmd('tail %s ' %readme_path)
- \ No newline at end of file
+ commit_message = 'KERNEL DEV TEST CASE'
+ git_commit = ['commit', '-m', commit_message]
+ repo.run_cmd(git_commit)
+ git_patch = ['format-patch', '-1']
+ repo.run_cmd(git_patch)
+ patch_file = os.path.join(self.builddir, 'tmp/work-shared/qemux86-64/kernel-source/0001-KERNEL-DEV-TEST-CASE.patch')
+ result = runCmd('mv %s %s' %(patch_file, linux_yocto_path), cwd=self.builddir)
+ self.assertFalse(os.path.exists(patch_file))
+ with open (recipe_append, 'w') as file:
+ file.write('SRC_URI += \'file://0001-KERNEL-DEV-TEST-CASE.patch\'' + '\n')
+ file.write('FILESEXTRAPATHS_prepend := \'${THISDIR}/${PN}:\'')
+ readme_path = os.path.join(self.builddir, 'tmp/work-shared/qemux86-64/kernel-source/README')
+ result = runCmd('rm %s ' %readme_path)
+ self.assertFalse(os.path.exists(readme_path))
+ result = runCmd('bitbake virtual/kernel -c cleansstate')
+ result = runCmd('bitbake virtual/kernel -c patch')
+ self.assertTrue(os.path.exists(readme_path))
+ result = runCmd('tail -n 1 %s ' %readme_path)
+ self.assertEqual(result.output, 'This is a test to apply a patch to the kernel.') \ No newline at end of file
diff --git a/meta/lib/oeqa/selftest/cases/kernel_test2.py b/meta/lib/oeqa/selftest/cases/kernel_test2.py
new file mode 100644
index 00000000000..8c39106955c
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/kernel_test2.py
@@ -0,0 +1,31 @@
+import sys
+import os
+import re
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, runCmd
+
+class KernelDev(OESelftestTestCase):
+ def test_linuxyocto_local_source(self):
+ #TC_KD_02-linux-yocto_Local_Source
+ """
+ Summary: Able to work with my own Linux kernel sources
+ Expected: Bitbake variables output should display that the SRC_URI variable
+ Product: Kernel Development
+ Author: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
+ Author: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
+ AutomatedBy: Mazliana Mohamad <mazliana.mohamad@intel.com>
+ """
+ self.append_config(
+'''
+PREFERRED_VERSION_linux-yocto_qemux86-64 = '%s%%'
+'''
+% (linux_kernel_version)
+ )
+ url = 'SRC_URI = "git://%s/linux-yocto;protocol=file;name=machine;branch=${KBRANCH}; git://%s/yocto-kernel-cache;protocol=file;type=kmeta;name=meta;branch=yocto-%s;destsuffix=${KMETA}" '%(kernel_local_repo_path,kernel_local_repo_path,linux_kernel_version)
+ with open (recipe_append, 'w') as file:
+ file.write(url)
+ os.chdir(self.builddir)
+ result = runCmd('bitbake virtual/kernel -c cleansstate')
+ result = runCmd('bitbake virtual/kernel')
+ result = runCmd('bitbake virtual/kernel -e | grep "SRC_URI="')
+ self.assertIn('git://%s'%kernel_local_repo_path ,result.output) \ No newline at end of file
diff --git a/meta/lib/oeqa/selftest/cases/kernel_test3.py b/meta/lib/oeqa/selftest/cases/kernel_test3.py
new file mode 100644
index 00000000000..e6708b9f2ea
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/kernel_test3.py
@@ -0,0 +1,35 @@
+import os
+# import fileinput
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, get_bb_var, runCmd
+
+class KernelDev(OESelftestTestCase):
+ def test_linuxyoctocustom_local_source(self):
+ """
+ Summary: Able to work with my own local sources for a customized linux-yocto kernel
+ Expected: The variables "PREFERRED_PROVIDER_virtual/kernel" and "SRC_URI" should be set successfully
+ Product: Kernel Development
+ Author: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
+ Author: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
+ AutomatedBy: Mazliana Mohamad <mazliana.mohamad@intel.com>
+ """
+ self.append_config(
+'''
+PREFERRED_PROVIDER_virtual/kernel = 'linux-yocto-custom'
+''')
+# src_uri = 'SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH}; \
+# git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-4.18;destsuffix=${KMETA}" '
+ url = 'SRC_URI = "git://%s/linux-yocto;protocol=file;name=machine;branch=${KBRANCH}; git://%s/yocto-kernel-cache;protocol=file;type=kmeta;name=meta;branch=yocto-%s;destsuffix=${KMETA}" '%(kernel_local_repo_path,kernel_local_repo_path,linux_kernel_version)
+ result = runCmd('bitbake virtual/kernel')
+ pn = 'linux-yocto-custom'
+ src_url = get_bb_var('SRC_URI', pn)
+ src_url.replace(src_url, url)
+# with fileinput.FileInput(recipefile, inplace=True) as file:
+# for line in file:
+# replace = line.replace(src_uri, url)
+# sys.stdout.write(replace)
+ os.chdir(self.builddir)
+ result = runCmd('bitbake virtual/kernel -c cleansstate')
+ result = runCmd('bitbake virtual/kernel')
+ result = runCmd('bitbake virtual/kernel -e | grep SRC_URI= ')
+ self.assertIn('git://%s'%kernel_local_repo_path ,result.output) \ No newline at end of file