diff options
author | Armin Kuster <akuster808@gmail.com> | 2023-02-01 08:26:13 -0500 |
---|---|---|
committer | Armin Kuster <akuster808@gmail.com> | 2023-02-22 15:29:22 -0500 |
commit | a30a85dba10b744b5365b6b24dcea1de74608c34 (patch) | |
tree | 0f5fc39b7490363fcf3cbf86562e28bf2d0b1ba8 | |
parent | c79262a30bd385f5dbb009ef8704a1a01644528e (diff) | |
download | meta-security-a30a85dba10b744b5365b6b24dcea1de74608c34.tar.gz |
oeqa/tpm2: fix and cleanup tests
Signed-off-by: Armin Kuster <akuster808@gmail.com>
(cherry picked from commit 3db9e08300c3d5e3f7b6e4e6cb743a914ed3f00b)
Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r-- | meta-tpm/lib/oeqa/runtime/cases/tpm2.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/meta-tpm/lib/oeqa/runtime/cases/tpm2.py b/meta-tpm/lib/oeqa/runtime/cases/tpm2.py index c2c95e7..e64d19d 100644 --- a/meta-tpm/lib/oeqa/runtime/cases/tpm2.py +++ b/meta-tpm/lib/oeqa/runtime/cases/tpm2.py | |||
@@ -1,11 +1,19 @@ | |||
1 | # Copyright (C) 2019 Armin Kuster <akuster808@gmail.com> | 1 | # Copyright (C) 2019 - 2022 Armin Kuster <akuster808@gmail.com> |
2 | # | 2 | # |
3 | from oeqa.runtime.case import OERuntimeTestCase | 3 | from oeqa.runtime.case import OERuntimeTestCase |
4 | from oeqa.core.decorator.depends import OETestDepends | 4 | from oeqa.core.decorator.depends import OETestDepends |
5 | from oeqa.runtime.decorator.package import OEHasPackage | 5 | from oeqa.runtime.decorator.package import OEHasPackage |
6 | 6 | from oeqa.core.decorator.data import skipIfNotFeature | |
7 | 7 | ||
8 | class Tpm2Test(OERuntimeTestCase): | 8 | class Tpm2Test(OERuntimeTestCase): |
9 | @classmethod | ||
10 | def setUpClass(cls): | ||
11 | cls.tc.target.run('mkdir /tmp/myvtpm2') | ||
12 | |||
13 | @classmethod | ||
14 | def tearDownClass(cls): | ||
15 | cls.tc.target.run('rm -fr /tmp/myvtpm2') | ||
16 | |||
9 | def check_endlines(self, results, expected_endlines): | 17 | def check_endlines(self, results, expected_endlines): |
10 | for line in results.splitlines(): | 18 | for line in results.splitlines(): |
11 | for el in expected_endlines: | 19 | for el in expected_endlines: |
@@ -19,20 +27,19 @@ class Tpm2Test(OERuntimeTestCase): | |||
19 | @OEHasPackage(['tpm2-tools']) | 27 | @OEHasPackage(['tpm2-tools']) |
20 | @OEHasPackage(['tpm2-abrmd']) | 28 | @OEHasPackage(['tpm2-abrmd']) |
21 | @OEHasPackage(['swtpm']) | 29 | @OEHasPackage(['swtpm']) |
30 | @skipIfNotFeature('tpm2','Test tpm2_startup requires tpm2 to be in DISTRO_FEATURES') | ||
22 | @OETestDepends(['ssh.SSHTest.test_ssh']) | 31 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
23 | def test_tpm2_swtpm_socket(self): | 32 | def test_tpm2_startup(self): |
24 | cmds = [ | 33 | cmds = [ |
25 | 'mkdir /tmp/myvtpm', | 34 | 'swtpm socket -d --tpmstate dir=/tmp/myvtpm2 --tpm2 --ctrl type=tcp,port=2322 --server type=tcp,port=2321 --flags not-need-init', |
26 | 'swtpm socket --tpmstate dir=/tmp/myvtpm --tpm2 --ctrl type=tcp,port=2322 --server type=tcp,port=2321 --flags not-need-init &', | 35 | 'tpm2_startup -c -T "swtpm:port=2321"', |
27 | 'export TPM2TOOLS_TCTI="swtpm:port=2321"', | ||
28 | 'tpm2_startup -c' | ||
29 | ] | 36 | ] |
30 | 37 | ||
31 | for cmd in cmds: | 38 | for cmd in cmds: |
32 | status, output = self.target.run(cmd) | 39 | status, output = self.target.run(cmd) |
33 | self.assertEqual(status, 0, msg='\n'.join([cmd, output])) | 40 | self.assertEqual(status, 0, msg='\n'.join([cmd, output])) |
34 | 41 | ||
35 | @OETestDepends(['tpm2.Tpm2Test.test_tpm2_swtpm_socket']) | 42 | @OETestDepends(['tpm2.Tpm2Test.test_tpm2_startup']) |
36 | def test_tpm2_pcrread(self): | 43 | def test_tpm2_pcrread(self): |
37 | (status, output) = self.target.run('tpm2_pcrread') | 44 | (status, output) = self.target.run('tpm2_pcrread') |
38 | expected_endlines = [] | 45 | expected_endlines = [] |
@@ -49,7 +56,7 @@ class Tpm2Test(OERuntimeTestCase): | |||
49 | 56 | ||
50 | @OEHasPackage(['p11-kit']) | 57 | @OEHasPackage(['p11-kit']) |
51 | @OEHasPackage(['tpm2-pkcs11']) | 58 | @OEHasPackage(['tpm2-pkcs11']) |
52 | @OETestDepends(['tpm2.Tpm2Test.test_tpm2_swtpm_socket']) | 59 | @OETestDepends(['tpm2.Tpm2Test.test_tpm2_pcrread']) |
53 | def test_tpm2_pkcs11(self): | 60 | def test_tpm2_pkcs11(self): |
54 | (status, output) = self.target.run('p11-kit list-modules -v') | 61 | (status, output) = self.target.run('p11-kit list-modules -v') |
55 | self.assertEqual(status, 0, msg="Modules missing: %s" % output) | 62 | self.assertEqual(status, 0, msg="Modules missing: %s" % output) |