Selftest fixes
cover Selftest fixes
These fixes should hopefully address the recent SyntaxWarning errors seen in [YOCTO #16468]. They also switch us to a supported method of setting the gpg-agent auto-expand-secmem option.
This does leave us with meta/lib/oe/gpg_sign.py still using the unsupported method of passing arguments to the gpg-agent. That isn't as easy to fix as we don't have a temporary gnupg homedir where we can modify gpg-agent.conf. So, I've opened [YOCTO #16480] to fix that at a later date.
These have been tested with an oe-selftest-fedora build on the AB [1], and I've checked that the affected test cases were executed.
[1]: https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/4973
---
Paul Barker (4):
oeqa: selftest: signing: Fix use of gnupg-native sysroot
oeqa: selftest: signing: Use supported method to set auto-expand-secmem
oeqa: selftest: prservice: Don't print regex in failure message
oeqa: selftest: Use raw strings where required for regexes
meta/lib/oeqa/selftest/cases/bblock.py | 4 ++-- meta/lib/oeqa/selftest/cases/buildhistory.py | 2 +- meta/lib/oeqa/selftest/cases/prservice.py | 2 +- meta/lib/oeqa/selftest/cases/signing.py | 10 ++++++---- 4 files changed, 10 insertions(+), 8 deletions(-)
---
base-commit: b62d5e681741394ad90501a83a1c66b0e3ab7ce3
change-id: 20261030-selftest-fixes-2e33b2710bab
Best regards,
Signature · 1 line
Paul Barker
PATCH 1/4 oeqa: selftest: signing: Fix use of gnupg-native sysroot
Instead of modifying PATH in os.environ (which is global), pass the sysroot to runCmd() via the native_sysroot argument.
--- meta/lib/oeqa/selftest/cases/signing.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
meta/lib/oeqa/selftest/cases/signing.py +2 -3
@@ -34,7 +34,7 @@ class Signing(OESelftestTestCase): nsysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "gnupg-native") runCmd('gpg --agent-program=`which gpg-agent`\|--auto-expand-secmem --batch --homedir %s --import %s %s' % (self.gpg_dir, self.pub_key_path, self.secret_key_path), native_sysroot=nsysroot) - return nsysroot + get_bb_var("bindir_native") + return nsysroot @contextmanager
@@ -155,7 +155,6 @@ class Signing(OESelftestTestCase): with self.create_new_builddir(os.environ['BUILDDIR'], builddir): - os.environ["PATH"] = nsysroot + ":" + os.environ["PATH"] self.add_command_to_tearDown('bitbake -c clean %s' % test_recipe) self.add_command_to_tearDown('rm -rf %s' % sstatedir) self.add_command_to_tearDown('rm -rf %s' % builddir)
@@ -169,7 +168,7 @@ class Signing(OESelftestTestCase): self.assertEqual(len(recipe_sig), 1, 'Failed to find .sig file.') self.assertEqual(len(recipe_archive), 1, 'Failed to find .tar.zst file.') - ret = runCmd('gpg --homedir %s --verify %s %s' % (self.gpg_dir, recipe_sig[0], recipe_archive[0])) + ret = runCmd('gpg --homedir %s --verify %s %s' % (self.gpg_dir, recipe_sig[0], recipe_archive[0]), native_sysroot=nsysroot) # gpg: Signature made Thu 22 Oct 2015 01:45:09 PM EEST using RSA key ID 61EEFB30 # gpg: Good signature from "testuser (nocomment) <[email protected]>" self.assertIn('gpg: Good signature from', ret.output, 'Package signed incorrectly.')
Signature · 1 line
2.43.0
PATCH 2/4 oeqa: selftest: signing: Use supported method to set auto-expand-secmem
In reply to Paul BarkerUsing a | character with gpg --agent-program to specify arguments for the gpg-agent process is not officially supported. The docs describe it as "a regression test suite hack" [1].
As we are already placing the gpg homedir in a temporary directory, we can instead create a gpg-agent.conf file to specify this option.
[1]: https://www.gnupg.org/documentation/manuals/gnupg24/gpg.1.html
--- meta/lib/oeqa/selftest/cases/signing.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
meta/lib/oeqa/selftest/cases/signing.py +4 -1
@@ -33,7 +33,10 @@ class Signing(OESelftestTestCase): nsysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "gnupg-native") - runCmd('gpg --agent-program=`which gpg-agent`\|--auto-expand-secmem --batch --homedir %s --import %s %s' % (self.gpg_dir, self.pub_key_path, self.secret_key_path), native_sysroot=nsysroot) + with open(os.path.join(self.gpg_dir, "gpg-agent.conf"), "w") as f: + f.write("auto-expand-secmem\n") + + runCmd('gpg --batch --homedir %s --import %s %s' % (self.gpg_dir, self.pub_key_path, self.secret_key_path), native_sysroot=nsysroot) return nsysroot
Signature · 1 line
2.43.0
PATCH 3/4 oeqa: selftest: prservice: Don't print regex in failure message
In reply to Paul BarkerPrinting the regex doesn't clarify anything.
--- meta/lib/oeqa/selftest/cases/prservice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oeqa/selftest/cases/prservice.py +1 -1
@@ -37,7 +37,7 @@ class BitbakePrTests(OESelftestTestCase): package_data_file = os.path.join(self.pkgdata_dir, 'runtime', package_name) package_data = ftools.read_file(package_data_file) find_pr = re.search(r"PKGR: r[0-9]+\.([0-9]+)", package_data) - self.assertTrue(find_pr, "No PKG revision found via regex 'PKGR: r[0-9]+\.([0-9]+)' in %s" % package_data_file) + self.assertTrue(find_pr, "No PKG revision found in %s" % package_data_file) return int(find_pr.group(1)) def get_task_stamp(self, package_name, recipe_task):
Signature · 1 line
2.43.0
PATCH 4/4 oeqa: selftest: Use raw strings where required for regexes
In reply to Paul BarkerWe need to use raw string literals to avoid misinterpretation of escape sequences.
--- meta/lib/oeqa/selftest/cases/bblock.py | 4 ++-- meta/lib/oeqa/selftest/cases/buildhistory.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
meta/lib/oeqa/selftest/cases/bblock.py +2 -2
@@ -35,7 +35,7 @@ class BBLock(OESelftestTestCase): for recipe in recipes: for task in tasks: find_in_contents = re.search( - 'SIGGEN_LOCKEDSIGS_.+\s\+=\s"%s:%s:.*"' % (recipe, task), + r'SIGGEN_LOCKEDSIGS_.+\s\+=\s"%s:%s:.*"' % (recipe, task), contents, ) self.assertFalse(
@@ -62,7 +62,7 @@ class BBLock(OESelftestTestCase): if tasks: for task in tasks: find_in_contents = re.search( - 'SIGGEN_LOCKEDSIGS_.+\s\+=\s"%s:%s:.*"' % (recipe, task), + r'SIGGEN_LOCKEDSIGS_.+\s\+=\s"%s:%s:.*"' % (recipe, task), contents, ) self.assertTrue(
meta/lib/oeqa/selftest/cases/buildhistory.py +1 -1
@@ -55,7 +55,7 @@ class BuildhistoryTests(OESelftestTestCase): def test_buildhistory_buildtime_pr_backwards(self): target = 'xcursor-transparent-theme' - error = "ERROR:.*QA Issue: Package version for package %s went backwards which would break package feeds \(from .*-r1.* to .*-r0.*\)" % target + error = r"ERROR:.*QA Issue: Package version for package %s went backwards which would break package feeds \(from .*-r1.* to .*-r0.*\)" % target self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True) self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True, error_regex=error)
Signature · 1 line
2.43.0