def remove_include(cls): if "#include added by oe-selftest.py" \ in ftools.read_file(os.path.join(cls.builddir, "conf/local.conf")): cls.logger.info("Removing the include from local.conf") ftools.remove_from_file(os.path.join(cls.builddir, "conf/local.conf"), \ "\n#include added by oe-selftest.py\ninclude machine.inc\ninclude selftest.inc") if "#include added by oe-selftest.py" \ in ftools.read_file(os.path.join(cls.builddir, "conf/bblayers.conf")): cls.logger.info("Removing the include from bblayers.conf") ftools.remove_from_file(os.path.join(cls.builddir, "conf/bblayers.conf"), \ "\n#include added by oe-selftest.py\ninclude bblayers.inc")
def add_include(cls): if "#include added by oe-selftest" \ not in ftools.read_file(os.path.join(cls.builddir, "conf/local.conf")): cls.logger.info("Adding: \"include selftest.inc\" in %s" % os.path.join(cls.builddir, "conf/local.conf")) ftools.append_file(os.path.join(cls.builddir, "conf/local.conf"), \ "\n#include added by oe-selftest\ninclude machine.inc\ninclude selftest.inc") if "#include added by oe-selftest" \ not in ftools.read_file(os.path.join(cls.builddir, "conf/bblayers.conf")): cls.logger.info("Adding: \"include bblayers.inc\" in bblayers.conf") ftools.append_file(os.path.join(cls.builddir, "conf/bblayers.conf"), \ "\n#include added by oe-selftest\ninclude bblayers.inc")
def get_pr_version(self, package_name): pkgdata_dir = get_bb_var('PKGDATA_DIR') package_data_file = os.path.join(pkgdata_dir, 'runtime', package_name) package_data = ftools.read_file(package_data_file) find_pr = re.search("PKGR: r[0-9]+\.([0-9]+)", package_data) self.assertTrue(find_pr, "No PKG revision found in %s" % package_data_file) return int(find_pr.group(1))
def test_incremental_image_generation(self): image_pkgtype = get_bb_var("IMAGE_PKGTYPE") if image_pkgtype != 'rpm': self.skipTest('Not using RPM as main package format') bitbake("-c clean core-image-minimal") self.write_config('INC_RPM_IMAGE_GEN = "1"') self.append_config('IMAGE_FEATURES += "ssh-server-openssh"') bitbake("core-image-minimal") log_data_file = os.path.join(get_bb_var("WORKDIR", "core-image-minimal"), "temp/log.do_rootfs") log_data_created = ftools.read_file(log_data_file) incremental_created = re.search(r"Installing\s*:\s*packagegroup-core-ssh-openssh", log_data_created) self.remove_config('IMAGE_FEATURES += "ssh-server-openssh"') self.assertTrue(incremental_created, msg = "Match failed in:\n%s" % log_data_created) bitbake("core-image-minimal") log_data_removed = ftools.read_file(log_data_file) incremental_removed = re.search(r"Erasing\s*:\s*packagegroup-core-ssh-openssh", log_data_removed) self.assertTrue(incremental_removed, msg = "Match failed in:\n%s" % log_data_removed)
def test_incremental_image_generation(self): image_pkgtype = get_bb_var("IMAGE_PKGTYPE") if image_pkgtype != 'rpm': self.skipTest('Not using RPM as main package format') bitbake("-c cleanall core-image-minimal") self.write_config('INC_RPM_IMAGE_GEN = "1"') self.append_config('IMAGE_FEATURES += "ssh-server-openssh"') bitbake("core-image-minimal") log_data_file = os.path.join(get_bb_var("WORKDIR", "core-image-minimal"), "temp/log.do_rootfs") log_data_created = ftools.read_file(log_data_file) incremental_created = re.search("NOTE: load old install solution for incremental install\nNOTE: old install solution not exist\nNOTE: creating new install solution for incremental install(\n.*)*NOTE: Installing the following packages:.*packagegroup-core-ssh-openssh", log_data_created) self.remove_config('IMAGE_FEATURES += "ssh-server-openssh"') self.assertTrue(incremental_created, msg = "Match failed in:\n%s" % log_data_created) bitbake("core-image-minimal") log_data_removed = ftools.read_file(log_data_file) incremental_removed = re.search("NOTE: load old install solution for incremental install\nNOTE: creating new install solution for incremental install(\n.*)*NOTE: incremental removed:.*openssh-sshd-.*", log_data_removed) self.assertTrue(incremental_removed, msg = "Match failed in:\n%s" % log_data_removed)
def test_bitbakelayers_flatten(self): self.assertFalse(os.path.isdir(os.path.join(self.builddir, 'test'))) result = runCmd('bitbake-layers flatten test') bb_file = os.path.join(self.builddir, 'test/recipes-graphics/xcursor-transparent-theme/xcursor-transparent-theme_0.1.1.bb') self.assertTrue(os.path.isfile(bb_file)) contents = ftools.read_file(bb_file) find_in_contents = re.search("##### bbappended from meta-selftest #####\n(.*\n)*include test_recipe.inc", contents) shutil.rmtree(os.path.join(self.builddir, 'test')) self.assertTrue(find_in_contents)
def test_bitbakelayers_flatten(self): testoutdir = os.path.join(self.builddir, 'test_bitbakelayers_flatten') self.assertFalse(os.path.isdir(testoutdir)) self.track_for_cleanup(testoutdir) result = runCmd('bitbake-layers flatten %s' % testoutdir) bb_file = os.path.join(testoutdir, 'recipes-graphics/xcursor-transparent-theme/xcursor-transparent-theme_0.1.1.bb') self.assertTrue(os.path.isfile(bb_file)) contents = ftools.read_file(bb_file) find_in_contents = re.search("##### bbappended from meta-selftest #####\n(.*\n)*include test_recipe.inc", contents) self.assertTrue(find_in_contents)
def test_bitbakelayers_flatten(self): testoutdir = os.path.join(self.builddir, 'test_bitbakelayers_flatten') self.assertFalse(os.path.isdir(testoutdir), msg = "test_bitbakelayers_flatten should not exist at this point in time") self.track_for_cleanup(testoutdir) result = runCmd('bitbake-layers flatten %s' % testoutdir) bb_file = os.path.join(testoutdir, 'recipes-graphics/xcursor-transparent-theme/xcursor-transparent-theme_0.1.1.bb') self.assertTrue(os.path.isfile(bb_file), msg = "Cannot find xcursor-transparent-theme_0.1.1.bb in the test_bitbakelayers_flatten local dir.") contents = ftools.read_file(bb_file) find_in_contents = re.search("##### bbappended from meta-selftest #####\n(.*\n)*include test_recipe.inc", contents) self.assertTrue(find_in_contents, msg = "Flattening layers did not work. bitbake-layers flatten output: %s" % result.output)
def test_layer_appends(self): corebase = get_bb_var("COREBASE") for l in ["0", "1", "2"]: layer = os.path.join(corebase, "meta-layertest" + l) self.assertFalse(os.path.exists(layer)) os.mkdir(layer) os.mkdir(layer + "/conf") with open(layer + "/conf/layer.conf", "w") as f: f.write(self.layerconf.replace("INT", l)) os.mkdir(layer + "/recipes-test") if l == "0": with open(layer + "/recipes-test/layerappendtest.bb", "w") as f: f.write(self.recipe) elif l == "1": with open(layer + "/recipes-test/layerappendtest.bbappend", "w") as f: f.write(self.append) os.mkdir(layer + "/recipes-test/layerappendtest") with open(layer + "/recipes-test/layerappendtest/appendtest.txt", "w") as f: f.write("Layer 1 test") elif l == "2": with open(layer + "/recipes-test/layerappendtest.bbappend", "w") as f: f.write(self.append2) os.mkdir(layer + "/recipes-test/layerappendtest") with open(layer + "/recipes-test/layerappendtest/appendtest.txt", "w") as f: f.write("Layer 2 test") self.track_for_cleanup(layer) self.layerappend = "BBLAYERS += \"{0}/meta-layertest0 {0}/meta-layertest1 {0}/meta-layertest2\"".format(corebase) ftools.append_file(self.builddir + "/conf/bblayers.conf", self.layerappend) stagingdir = get_bb_var("SYSROOT_DESTDIR", "layerappendtest") bitbake("layerappendtest") data = ftools.read_file(stagingdir + "/appendtest.txt") self.assertEqual(data, "Layer 2 test") os.remove(corebase + "/meta-layertest2/recipes-test/layerappendtest/appendtest.txt") bitbake("layerappendtest") data = ftools.read_file(stagingdir + "/appendtest.txt") self.assertEqual(data, "Layer 1 test") with open(corebase + "/meta-layertest2/recipes-test/layerappendtest/appendtest.txt", "w") as f: f.write("Layer 2 test") bitbake("layerappendtest") data = ftools.read_file(stagingdir + "/appendtest.txt") self.assertEqual(data, "Layer 2 test")
def test_incremental_image_generation(self): image_pkgtype = get_bb_var("IMAGE_PKGTYPE") if image_pkgtype != 'rpm': self.skipTest('Not using RPM as main package format') bitbake("-c clean core-image-minimal") self.write_config('INC_RPM_IMAGE_GEN = "1"') self.append_config('IMAGE_FEATURES += "ssh-server-openssh"') bitbake("core-image-minimal") log_data_file = os.path.join( get_bb_var("WORKDIR", "core-image-minimal"), "temp/log.do_rootfs") log_data_created = ftools.read_file(log_data_file) incremental_created = re.search( r"Installing\s*:\s*packagegroup-core-ssh-openssh", log_data_created) self.remove_config('IMAGE_FEATURES += "ssh-server-openssh"') self.assertTrue(incremental_created, msg="Match failed in:\n%s" % log_data_created) bitbake("core-image-minimal") log_data_removed = ftools.read_file(log_data_file) incremental_removed = re.search( r"Erasing\s*:\s*packagegroup-core-ssh-openssh", log_data_removed) self.assertTrue(incremental_removed, msg="Match failed in:\n%s" % log_data_removed)
def test_bitbakelayers_flatten(self): self.assertFalse(os.path.isdir(os.path.join(self.builddir, 'test'))) result = runCmd('bitbake-layers flatten test') bb_file = os.path.join( self.builddir, 'test/recipes-graphics/xcursor-transparent-theme/xcursor-transparent-theme_0.1.1.bb' ) self.assertTrue(os.path.isfile(bb_file)) contents = ftools.read_file(bb_file) find_in_contents = re.search( "##### bbappended from meta-selftest #####\n(.*\n)*include test_recipe.inc", contents) shutil.rmtree(os.path.join(self.builddir, 'test')) self.assertTrue(find_in_contents)
def test_bitbake_g(self): result = bitbake('-g core-image-minimal') for f in ['pn-buildlist', 'recipe-depends.dot', 'task-depends.dot']: self.addCleanup(os.remove, f) self.assertTrue( 'Task dependencies saved to \'task-depends.dot\'' in result.output, msg= "No task dependency \"task-depends.dot\" file was generated for the given task target. bitbake output: %s" % result.output) self.assertTrue( 'busybox' in ftools.read_file(os.path.join(self.builddir, 'task-depends.dot')), msg="No \"busybox\" dependency found in task-depends.dot file.")
def test_bitbakelayers_flatten(self): testoutdir = os.path.join(self.builddir, 'test_bitbakelayers_flatten') self.assertFalse(os.path.isdir(testoutdir)) self.track_for_cleanup(testoutdir) result = runCmd('bitbake-layers flatten %s' % testoutdir) bb_file = os.path.join( testoutdir, 'recipes-graphics/xcursor-transparent-theme/xcursor-transparent-theme_0.1.1.bb' ) self.assertTrue(os.path.isfile(bb_file)) contents = ftools.read_file(bb_file) find_in_contents = re.search( "##### bbappended from meta-selftest #####\n(.*\n)*include test_recipe.inc", contents) self.assertTrue(find_in_contents)
def test_incremental_image_generation(self): image_pkgtype = get_bb_var("IMAGE_PKGTYPE") if image_pkgtype != 'rpm': self.skipTest('Not using RPM as main package format') bitbake("-c cleanall core-image-minimal") self.write_config('INC_RPM_IMAGE_GEN = "1"') self.append_config('IMAGE_FEATURES += "ssh-server-openssh"') bitbake("core-image-minimal") log_data_file = os.path.join( get_bb_var("WORKDIR", "core-image-minimal"), "temp/log.do_rootfs") log_data_created = ftools.read_file(log_data_file) incremental_created = re.search( "NOTE: load old install solution for incremental install\nNOTE: old install solution not exist\nNOTE: creating new install solution for incremental install(\n.*)*NOTE: Installing the following packages:.*packagegroup-core-ssh-openssh", log_data_created) self.remove_config('IMAGE_FEATURES += "ssh-server-openssh"') self.assertTrue(incremental_created, msg="Match failed in:\n%s" % log_data_created) bitbake("core-image-minimal") log_data_removed = ftools.read_file(log_data_file) incremental_removed = re.search( "NOTE: load old install solution for incremental install\nNOTE: creating new install solution for incremental install(\n.*)*NOTE: incremental removed:.*openssh-sshd-.*", log_data_removed) self.assertTrue(incremental_removed, msg="Match failed in:\n%s" % log_data_removed)
def test_bitbake_g(self): result = bitbake('-g core-image-full-cmdline') for f in [ 'pn-buildlist', 'pn-depends.dot', 'package-depends.dot', 'task-depends.dot' ]: self.addCleanup(os.remove, f) self.assertTrue( 'NOTE: PN build list saved to \'pn-buildlist\'' in result.output, msg= "No dependency \"pn-buildlist\" file was generated for the given task target. bitbake output: %s" % result.output) self.assertTrue( 'openssh' in ftools.read_file(os.path.join(self.builddir, 'pn-buildlist')), msg="No \"openssh\" dependency found in pn-buildlist file.")
def test_force_task_1(self): # test 1 from bug 5875 test_recipe = 'zlib' test_data = "Microsoft Made No Profit From Anyone's Zunes Yo" image_dir = get_bb_var('D', test_recipe) pkgsplit_dir = get_bb_var('PKGDEST', test_recipe) man_dir = get_bb_var('mandir', test_recipe) bitbake('-c cleansstate %s' % test_recipe) bitbake(test_recipe) self.add_command_to_tearDown('bitbake -c clean %s' % test_recipe) man_file = os.path.join(image_dir + man_dir, 'man3/zlib.3') ftools.append_file(man_file, test_data) bitbake('-c package -f %s' % test_recipe) man_split_file = os.path.join(pkgsplit_dir, 'zlib-doc' + man_dir, 'man3/zlib.3') man_split_content = ftools.read_file(man_split_file) self.assertIn(test_data, man_split_content, 'The man file has not changed in packages-split.') ret = bitbake(test_recipe) self.assertIn('task do_package_write_rpm:', ret.output, 'Task do_package_write_rpm did not re-executed.')
def test_bitbake_g(self): result = bitbake('-g core-image-minimal') for f in ['pn-buildlist', 'recipe-depends.dot', 'task-depends.dot']: self.addCleanup(os.remove, f) self.assertTrue('Task dependencies saved to \'task-depends.dot\'' in result.output, msg = "No task dependency \"task-depends.dot\" file was generated for the given task target. bitbake output: %s" % result.output) self.assertTrue('busybox' in ftools.read_file(os.path.join(self.builddir, 'task-depends.dot')), msg = "No \"busybox\" dependency found in task-depends.dot file.")
def test_bitbake_g(self): result = bitbake("-g core-image-full-cmdline") self.assertTrue("NOTE: PN build list saved to 'pn-buildlist'" in result.output) self.assertTrue("openssh" in ftools.read_file(os.path.join(self.builddir, "pn-buildlist"))) for f in ["pn-buildlist", "pn-depends.dot", "package-depends.dot", "task-depends.dot"]: os.remove(f)
def test_bitbake_g(self): result = bitbake('-g core-image-full-cmdline') self.assertTrue('NOTE: PN build list saved to \'pn-buildlist\'' in result.output) self.assertTrue('openssh' in ftools.read_file(os.path.join(self.builddir, 'pn-buildlist'))) for f in ['pn-buildlist', 'pn-depends.dot', 'package-depends.dot', 'task-depends.dot']: os.remove(f)
def test_bitbake_g(self): result = bitbake('-g core-image-full-cmdline') for f in ['pn-buildlist', 'pn-depends.dot', 'package-depends.dot', 'task-depends.dot']: self.addCleanup(os.remove, f) self.assertTrue('NOTE: PN build list saved to \'pn-buildlist\'' in result.output, msg = "No dependency \"pn-buildlist\" file was generated for the given task target. bitbake output: %s" % result.output) self.assertTrue('openssh' in ftools.read_file(os.path.join(self.builddir, 'pn-buildlist')), msg = "No \"openssh\" dependency found in pn-buildlist file.")