summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorJose Perez Carranza <jose.perez.carranza@linux-ntel.com>2017-03-10 13:58:09 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-22 11:35:19 +0000
commitb64105296169dc3705e9bcea389c06328ce68505 (patch)
treee567647dc0454d6c505bc9671e15aab1a5e381a6 /meta
parentcc2744267f6c6daa594b8c4381d56ac27fe70b81 (diff)
downloadpoky-b64105296169dc3705e9bcea389c06328ce68505.tar.gz
selftest/devtool: Add test to verify "modify virtual/kernel"
The purpose of this test case is to verify that devtool modify works correctly when building the kernel. [YOCTO #10817] (From OE-Core rev: 0fa3d331df7d5a5fbd8431febc75efe6bcc6f96b) Signed-off-by: Jose Perez Carranza <jose.perez.carranza@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/selftest/devtool.py85
1 files changed, 85 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py
index f1661efeb1..c389d50602 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -1606,3 +1606,88 @@ class DevtoolTests(DevtoolBase):
1606 checkvars['S'] = '${WORKDIR}/${BPN}-%s' % recipever 1606 checkvars['S'] = '${WORKDIR}/${BPN}-%s' % recipever
1607 checkvars['SRC_URI'] = url 1607 checkvars['SRC_URI'] = url
1608 self._test_recipe_contents(newrecipefile, checkvars, []) 1608 self._test_recipe_contents(newrecipefile, checkvars, [])
1609
1610 @testcase(1577)
1611 def test_devtool_virtual_kernel_modify(self):
1612 """
1613 Summary: The purpose of this test case is to verify that
1614 devtool modify works correctly when building
1615 the kernel.
1616 Dependencies: NA
1617 Steps: 1. Build kernel with bitbake.
1618 2. Save the config file generated.
1619 3. Clean the environment.
1620 4. Use `devtool modify virtual/kernel` to validate following:
1621 4.1 The source is checked out correctly.
1622 4.2 The resulting configuration is the same as
1623 what was get on step 2.
1624 4.3 The Kernel can be build correctly.
1625 4.4 Changes made on the source are reflected on the
1626 subsequent builds.
1627 4.5 Changes on the configuration are reflected on the
1628 subsequent builds
1629 Expected: devtool modify is able to checkout the source of the kernel
1630 and modification to the source and configurations are reflected
1631 when building the kernel.
1632 """
1633 #Set machine to qemxu86 to be able to modify the kernel and
1634 #verify the modification.
1635 features = 'MACHINE = "qemux86"\n'
1636 self.write_config(features)
1637 # Clean up the enviroment
1638 bitbake('linux-yocto -c cleansstate')
1639 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
1640 self.track_for_cleanup(tempdir)
1641 self.track_for_cleanup(self.workspacedir)
1642 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
1643 self.add_command_to_tearDown('bitbake -c clean linux-yocto')
1644 #Step 1
1645 #Here is just generated the config file instead of all the kernel to optimize the
1646 #time of executing this test case.
1647 bitbake('linux-yocto -c configure')
1648 bbconfig = os.path.join(get_bb_var('B',"linux-yocto"),'.config')
1649 buildir= get_bb_var('TOPDIR')
1650 #Step 2
1651 runCmd('cp %s %s' % (bbconfig, buildir))
1652 self.assertTrue(os.path.exists(os.path.join(buildir, '.config')),
1653 'Could not copy .config file from kernel')
1654
1655 tmpconfig = os.path.join(buildir, '.config')
1656 #Step 3
1657 bitbake('linux-yocto -c cleanall')
1658 #Step 4.1
1659 runCmd('devtool modify virtual/kernel -x %s' % tempdir)
1660 self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile')),
1661 'Extracted source could not be found')
1662 #Step 4.2
1663 configfile = os.path.join(tempdir,'.config')
1664 diff = runCmd('diff %s %s' % (tmpconfig, configfile))
1665 self.assertEqual(0,diff.status,'Kernel .config file is not the same using bitbake and devtool')
1666 #Step 4.3
1667 #NOTE: virtual/kernel is mapped to linux-yocto
1668 result = runCmd('devtool build linux-yocto')
1669 self.assertEqual(0,result.status,'Cannot build kernel using `devtool build`')
1670 kernelfile = os.path.join(get_bb_var('KBUILD_OUTPUT',"linux-yocto"), 'vmlinux')
1671 self.assertTrue(os.path.exists(kernelfile),'Kernel was not build correctly')
1672
1673 #Modify the kernel source, this is specific for qemux86
1674 modfile = os.path.join(tempdir,'arch/x86/boot/header.S')
1675 modstring = "use a boot loader - Devtool kernel testing"
1676 modapplied = runCmd("sed -i 's/boot loader/%s/' %s" % (modstring, modfile))
1677 self.assertEqual(0,modapplied.status,'Modification to %s on kernel source failed' % modfile)
1678 #Modify the configuration
1679 codeconfigfile = os.path.join(tempdir,'.config.new')
1680 modconfopt = "CONFIG_SG_POOL=n"
1681 modconf = runCmd("sed -i 's/CONFIG_SG_POOL=y/%s/' %s" % (modconfopt, codeconfigfile))
1682 self.assertEqual(0,modconf.status,'Modification to %s failed' % codeconfigfile)
1683 #Build again kernel with devtool
1684 rebuild = runCmd('devtool build linux-yocto')
1685 self.assertEqual(0,rebuild.status,'Fail to build kernel after modification of source and config')
1686 #Step 4.4
1687 bzimagename = 'bzImage-' + get_bb_var('KERNEL_VERSION_NAME',"linux-yocto")
1688 bzimagefile = os.path.join(get_bb_var('D',"linux-yocto"),'boot', bzimagename)
1689 checkmodcode = runCmd("grep '%s' %s" % (modstring, bzimagefile))
1690 self.assertEqual(0,checkmodcode.status,'Modification on kernel source failed')
1691 #Step 4.5
1692 checkmodconfg = runCmd("grep %s %s" % (modconfopt, codeconfigfile))
1693 self.assertEqual(0,checkmodconfg.status,'Modification to configuration file failed')