new file mode 100644
@@ -0,0 +1,2 @@
+# This bbappend is used to alter the recipe using the test_recipe.inc file created by tests.
+include test_recipe.inc
new file mode 100644
@@ -0,0 +1,50 @@
+import unittest
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.selftest.cases.buildhistory import BuildhistoryBase
+from oeqa.utils.commands import bitbake, get_bb_var
+
+class BuildhistoryTests(BuildhistoryBase):
+
+ def test_write_license_to_latest_recipe(self):
+ target = 'glibc'
+ recipe_variables = []
+ self.write_recipeinc(target, 'BUILDHISTORY_EXPORT_RECIPE_VARIABLES += \"LICENSE\"')
+ self.run_buildhistory_operation(target)
+ add_buildhistory_config = 'PACKAGE_CLASSES = \"package_ipk\"'
+ self.append_config(add_buildhistory_config)
+ self.assertTrue(os.path.isdir(get_bb_var('BUILDHISTORY_DIR')), "buildhistory dir was not created.")
+ pkghistdir = get_bb_var('BUILDHISTORY_DIR')
+ PACKAGE_ARCH = get_bb_var('MULTIMACH_TARGET_SYS')
+ bitbake('-c package_write_ipk -f %s' % target)
+ infofile = "{}/packages/{}/{}/latest".format(pkghistdir, PACKAGE_ARCH, target)
+ expected = "LICENSE = GPLv2 & LGPLv2.1"
+ result = False
+ with open(infofile, "r") as f:
+ for line in f:
+ if line.strip() == expected:
+ result = True
+ break
+ if not result:
+ raise AssertionError("Expected License not found")
+
+ def test_write_license_to_latest_package(self):
+ target = 'glibc'
+ recipe_variables = []
+ self.write_recipeinc(target, 'BUILDHISTORY_EXPORT_PACKAGE_VARIABLES += \"LICENSE\"')
+ self.run_buildhistory_operation(target)
+ add_buildhistory_config = 'PACKAGE_CLASSES = \"package_ipk\"'
+ self.append_config(add_buildhistory_config)
+ self.assertTrue(os.path.isdir(get_bb_var('BUILDHISTORY_DIR')), "buildhistory dir was not created.")
+ bitbake('-c package_write_ipk -f %s' % target)
+ pkghistdir = get_bb_var('BUILDHISTORY_DIR')
+ PACKAGE_ARCH = get_bb_var('MULTIMACH_TARGET_SYS')
+ infofile = "{}/packages/{}/{}/{}-dbg/latest".format(pkghistdir, PACKAGE_ARCH, target, target)
+ expected = "LICENSE = GPLv2 & LGPLv2.1"
+ result = False
+ with open(infofile, "r") as f:
+ for line in f:
+ if line.strip() == expected:
+ result = True
+ break
+ if not result:
+ raise AssertionError("Expected License not found")