summaryrefslogtreecommitdiffstats
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-11-27 22:13:11 +0000
commit05edac6a961bfce0a0cd03db62b3bd61352daf99 (patch)
tree433a18981ad3e8f1ae2382eb880d62830eb245d1
parente2f53e48231c1cdf18f32c2386d81c0cc5b04052 (diff)
downloadpoky-05edac6a961bfce0a0cd03db62b3bd61352daf99.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) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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 a130ac96cf..97e9cfd44d 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