def test_force_task_1(self): # test 1 from bug 5875 import uuid test_recipe = 'zlib' # Need to use uuid otherwise hash equivlance would change the workflow test_data = "Microsoft Made No Profit From Anyone's Zunes Yo %s" % uuid.uuid1( ) bb_vars = get_bb_vars(['D', 'PKGDEST', 'mandir'], test_recipe) image_dir = bb_vars['D'] pkgsplit_dir = bb_vars['PKGDEST'] man_dir = bb_vars['mandir'] self.write_config("PACKAGE_CLASSES = \"package_rpm\"") bitbake('-c clean %s' % test_recipe) bitbake('-c package -f %s' % 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_force_task_1(self): # test 1 from bug 5875 test_recipe = 'zlib' test_data = "Microsoft Made No Profit From Anyone's Zunes Yo" bb_vars = get_bb_vars(['D', 'PKGDEST', 'mandir'], test_recipe) image_dir = bb_vars['D'] pkgsplit_dir = bb_vars['PKGDEST'] man_dir = bb_vars['mandir'] bitbake('-c clean %s' % test_recipe) bitbake('-c package -f %s' % 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 append_config(self, data): self.log.debug("Appending to: %s\n%s\n" % (self.testinc_path, data)) ftools.append_file(self.testinc_path, data) custommachine = os.getenv('CUSTOMMACHINE') if custommachine and 'MACHINE' in data: machine = get_bb_var('MACHINE') self.log.warning('MACHINE overridden: %s' % machine)
def append_config(self, data): """Append to <builddir>/conf/selftest.inc""" self.logger.debug("Appending to: %s\n%s\n" % (self.testinc_path, data)) ftools.append_file(self.testinc_path, data) if self.tc.custommachine and 'MACHINE' in data: machine = get_bb_var('MACHINE') self.logger.warning('MACHINE overridden: %s' % machine)
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_non_gplv3(self): data = 'INCOMPATIBLE_LICENSE = "GPLv3"' conf = os.path.join(self.builddir, 'conf/local.conf') ftools.append_file(conf ,data) self.addCleanup(ftools.remove_from_file, conf ,data) result = bitbake('readline', ignore_status=True) self.assertEqual(result.status, 0, "Bitbake failed, exit code %s, output %s" % (result.status, result.output)) self.assertFalse(os.path.isfile(os.path.join(self.builddir, 'tmp/deploy/licenses/readline/generic_GPLv3'))) self.assertTrue(os.path.isfile(os.path.join(self.builddir, 'tmp/deploy/licenses/readline/generic_GPLv2')))
def test_non_gplv3(self): data = 'INCOMPATIBLE_LICENSE = "GPLv3"' conf = os.path.join(self.builddir, 'conf/local.conf') ftools.append_file(conf ,data) result = bitbake('readline', ignore_status=True) self.assertEqual(result.status, 0) self.assertFalse(os.path.isfile(os.path.join(self.builddir, 'tmp/deploy/licenses/readline/generic_GPLv3'))) self.assertTrue(os.path.isfile(os.path.join(self.builddir, 'tmp/deploy/licenses/readline/generic_GPLv2'))) ftools.remove_from_file(conf ,data)
def test_non_gplv3(self): data = 'INCOMPATIBLE_LICENSE = "GPLv3"' conf = os.path.join(self.builddir, 'conf/local.conf') ftools.append_file(conf ,data) self.addCleanup(ftools.remove_from_file, conf ,data) result = bitbake('readline', ignore_status=True) self.assertEqual(result.status, 0, "Bitbake failed, exit code %s, output %s" % (result.status, result.output)) lic_dir = get_bb_var('LICENSE_DIRECTORY') self.assertFalse(os.path.isfile(os.path.join(lic_dir, 'readline/generic_GPLv3'))) self.assertTrue(os.path.isfile(os.path.join(lic_dir, 'readline/generic_GPLv2')))
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 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 configure_builddir(self, builddir): os.mkdir(builddir) self.track_for_cleanup(builddir) os.mkdir(os.path.join(builddir, 'conf')) shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/local.conf'), os.path.join(builddir, 'conf/local.conf')) config = {} config['default_sstate_dir'] = "SSTATE_DIR ?= \"${TOPDIR}/sstate-cache\"" config['null_sstate_mirrors'] = "SSTATE_MIRRORS = \"\"" config['default_tmp_dir'] = "TMPDIR = \"${TOPDIR}/tmp\"" for key in config: ftools.append_file(os.path.join(builddir, 'conf/selftest.inc'), config[key]) shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/bblayers.conf'), os.path.join(builddir, 'conf/bblayers.conf')) try: shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/auto.conf'), os.path.join(builddir, 'conf/auto.conf')) except: pass
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_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 configure_builddir(self, builddir): os.mkdir(builddir) self.track_for_cleanup(builddir) os.mkdir(os.path.join(builddir, 'conf')) shutil.copyfile( os.path.join(os.environ.get('BUILDDIR'), 'conf/local.conf'), os.path.join(builddir, 'conf/local.conf')) config = {} config[ 'default_sstate_dir'] = "SSTATE_DIR ?= \"${TOPDIR}/sstate-cache\"" config['null_sstate_mirrors'] = "SSTATE_MIRRORS = \"\"" config['default_tmp_dir'] = "TMPDIR = \"${TOPDIR}/tmp\"" for key in config: ftools.append_file(os.path.join(builddir, 'conf/selftest.inc'), config[key]) shutil.copyfile( os.path.join(os.environ.get('BUILDDIR'), 'conf/bblayers.conf'), os.path.join(builddir, 'conf/bblayers.conf')) try: shutil.copyfile( os.path.join(os.environ.get('BUILDDIR'), 'conf/auto.conf'), os.path.join(builddir, 'conf/auto.conf')) except: pass
def append_bblayers_config(self, data): self.log.debug("Appending to: %s\n%s\n" % (self.testinc_bblayers_path, data)) ftools.append_file(self.testinc_bblayers_path, data)
def append_recipeinc(self, recipe, data): """Append data to meta-selftest/recipes-test/<recipe>/test_recipe.inc""" inc_file = self.recipeinc(recipe) self.logger.debug("Appending to: %s\n%s\n" % (inc_file, data)) ftools.append_file(inc_file, data) return inc_file
def append_bblayers_config(self, data): """Append to <builddir>/conf/bblayers.inc""" self.logger.debug("Appending to: %s\n%s\n" % (self.testinc_bblayers_path, data)) ftools.append_file(self.testinc_bblayers_path, data)
def append_recipeinc(self, recipe, data): inc_file = os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc') self.log.debug("Appending to: %s\n%s\n" % (inc_file, data)) ftools.append_file(inc_file, data)
def append_config(self, data): self.log.debug("Appending to: %s\n%s\n" % (self.testinc_path, data)) ftools.append_file(self.testinc_path, data)
def append_recipeinc(self, recipe, data): """Append data to meta-sefltest/recipes-test/<recipe>/test_recipe.inc""" inc_file = os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc') self.logger.debug("Appending to: %s\n%s\n" % (inc_file, data)) ftools.append_file(inc_file, data)