summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2018-11-24 17:56:06 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-12-16 14:31:26 +0000
commitac342873846822a4a92477d95744badcf5d6de5b (patch)
tree23b295288071e7a1226ff73340396a03386c112e /meta/lib
parent30148ab8742e39277e833300f26760d84e818a84 (diff)
downloadpoky-ac342873846822a4a92477d95744badcf5d6de5b.tar.gz
oeqa/selftest/signing: Skip tests if gpg isn't found
Raising an assertionError in the class setup isn't a particuarly good way to indicate gpg isn't installed. Instead skip the tests if the required binary isn't present. For the signing tests we do require it to be present and can't use a prebuilt one. (From OE-Core rev: 2d486af97e51b9daa9c40482c31d637c9ab4ae79) (From OE-Core rev: 65403bb556f7e3132722288a62ef36631af0b557) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/selftest/cases/signing.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/meta/lib/oeqa/selftest/cases/signing.py b/meta/lib/oeqa/selftest/cases/signing.py
index a750cfc7b2..28afcdccb4 100644
--- a/meta/lib/oeqa/selftest/cases/signing.py
+++ b/meta/lib/oeqa/selftest/cases/signing.py
@@ -15,23 +15,18 @@ class Signing(OESelftestTestCase):
15 pub_key_path = "" 15 pub_key_path = ""
16 secret_key_path = "" 16 secret_key_path = ""
17 17
18 @classmethod 18 def setup_gpg(self):
19 def setUpClass(cls):
20 super(Signing, cls).setUpClass()
21 # Check that we can find the gpg binary and fail early if we can't 19 # Check that we can find the gpg binary and fail early if we can't
22 if not shutil.which("gpg"): 20 if not shutil.which("gpg"):
23 raise AssertionError("This test needs GnuPG") 21 self.skipTest('gpg binary not found')
24 22
25 cls.gpg_dir = tempfile.mkdtemp(prefix="oeqa-signing-") 23 self.gpg_dir = tempfile.mkdtemp(prefix="oeqa-signing-")
24 self.track_for_cleanup(self.gpg_dir)
26 25
27 cls.pub_key_path = os.path.join(cls.testlayer_path, 'files', 'signing', "key.pub") 26 self.pub_key_path = os.path.join(self.testlayer_path, 'files', 'signing', "key.pub")
28 cls.secret_key_path = os.path.join(cls.testlayer_path, 'files', 'signing', "key.secret") 27 self.secret_key_path = os.path.join(self.testlayer_path, 'files', 'signing', "key.secret")
29 28
30 runCmd('gpg --batch --homedir %s --import %s %s' % (cls.gpg_dir, cls.pub_key_path, cls.secret_key_path)) 29 runCmd('gpg --batch --homedir %s --import %s %s' % (self.gpg_dir, self.pub_key_path, self.secret_key_path))
31
32 @classmethod
33 def tearDownClass(cls):
34 shutil.rmtree(cls.gpg_dir, ignore_errors=True)
35 30
36 @OETestID(1362) 31 @OETestID(1362)
37 def test_signing_packages(self): 32 def test_signing_packages(self):
@@ -46,6 +41,8 @@ class Signing(OESelftestTestCase):
46 """ 41 """
47 import oe.packagedata 42 import oe.packagedata
48 43
44 self.setup_gpg()
45
49 package_classes = get_bb_var('PACKAGE_CLASSES') 46 package_classes = get_bb_var('PACKAGE_CLASSES')
50 if 'package_rpm' not in package_classes: 47 if 'package_rpm' not in package_classes:
51 self.skipTest('This test requires RPM Packaging.') 48 self.skipTest('This test requires RPM Packaging.')
@@ -111,6 +108,8 @@ class Signing(OESelftestTestCase):
111 builddir = os.environ.get('BUILDDIR') 108 builddir = os.environ.get('BUILDDIR')
112 sstatedir = os.path.join(builddir, 'test-sstate') 109 sstatedir = os.path.join(builddir, 'test-sstate')
113 110
111 self.setup_gpg()
112
114 self.add_command_to_tearDown('bitbake -c clean %s' % test_recipe) 113 self.add_command_to_tearDown('bitbake -c clean %s' % test_recipe)
115 self.add_command_to_tearDown('rm -rf %s' % sstatedir) 114 self.add_command_to_tearDown('rm -rf %s' % sstatedir)
116 115