diff options
author | Armin Kuster <akuster808@gmail.com> | 2022-05-19 14:32:01 -0700 |
---|---|---|
committer | Armin Kuster <akuster808@gmail.com> | 2022-05-23 07:56:47 -0700 |
commit | 0325071a1d12f132e9f260a03eb63b8d46b328a8 (patch) | |
tree | da3aa1c3838ca447d33aeddcd0750d3db80506bb | |
parent | 4270d36b751055b846bbf504aeddeb2424f7d36b (diff) | |
download | meta-security-0325071a1d12f132e9f260a03eb63b8d46b328a8.tar.gz |
oeqa/cases/tpm2: fix and enhance test suite
local.conf
TEST_SUITES = "ssh ping tpm2"
IMAGE_INSTALL:append = " swtpm tpm2-pkcs11"
RESULTS:
RESULTS - ping.PingTest.test_ping: PASSED (0.05s)
RESULTS - ssh.SSHTest.test_ssh: PASSED (2.19s)
RESULTS - tpm2.Tpm2Test.test_tpm2_pcrread: PASSED (1.06s)
RESULTS - tpm2.Tpm2Test.test_tpm2_pkcs11: PASSED (1.17s)
RESULTS - tpm2.Tpm2Test.test_tpm2_swtpm_reset: PASSED (0.59s)
RESULTS - tpm2.Tpm2Test.test_tpm2_swtpm_socket: PASSED (307.72s)
Signed-off-by: Armin Kuster <akuster808@gmail.com>
(cherry picked from commit 8be830dd85846a1a7da18a1a4adb2aa87cba5c78)
Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r-- | meta-tpm/lib/oeqa/runtime/cases/tpm2.py | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/meta-tpm/lib/oeqa/runtime/cases/tpm2.py b/meta-tpm/lib/oeqa/runtime/cases/tpm2.py index c6f9d92..c2c95e7 100644 --- a/meta-tpm/lib/oeqa/runtime/cases/tpm2.py +++ b/meta-tpm/lib/oeqa/runtime/cases/tpm2.py | |||
@@ -16,28 +16,45 @@ class Tpm2Test(OERuntimeTestCase): | |||
16 | if expected_endlines: | 16 | if expected_endlines: |
17 | self.fail('Missing expected line endings:\n %s' % '\n '.join(expected_endlines)) | 17 | self.fail('Missing expected line endings:\n %s' % '\n '.join(expected_endlines)) |
18 | 18 | ||
19 | @OEHasPackage(['tpm2-tss']) | ||
20 | @OEHasPackage(['tpm2-abrmd']) | ||
21 | @OEHasPackage(['tpm2-tools']) | 19 | @OEHasPackage(['tpm2-tools']) |
22 | @OEHasPackage(['ibmswtpm2']) | 20 | @OEHasPackage(['tpm2-abrmd']) |
21 | @OEHasPackage(['swtpm']) | ||
23 | @OETestDepends(['ssh.SSHTest.test_ssh']) | 22 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
24 | def test_tpm2_sim(self): | 23 | def test_tpm2_swtpm_socket(self): |
25 | cmds = [ | 24 | cmds = [ |
26 | 'tpm_server &', | 25 | 'mkdir /tmp/myvtpm', |
27 | 'tpm2-abrmd --allow-root --tcti=mssim &' | 26 | 'swtpm socket --tpmstate dir=/tmp/myvtpm --tpm2 --ctrl type=tcp,port=2322 --server type=tcp,port=2321 --flags not-need-init &', |
27 | 'export TPM2TOOLS_TCTI="swtpm:port=2321"', | ||
28 | 'tpm2_startup -c' | ||
28 | ] | 29 | ] |
29 | 30 | ||
30 | for cmd in cmds: | 31 | for cmd in cmds: |
31 | status, output = self.target.run(cmd) | 32 | status, output = self.target.run(cmd) |
32 | self.assertEqual(status, 0, msg='\n'.join([cmd, output])) | 33 | self.assertEqual(status, 0, msg='\n'.join([cmd, output])) |
33 | 34 | ||
34 | @OETestDepends(['tpm2.Tpm2Test.test_tpm2_sim']) | 35 | @OETestDepends(['tpm2.Tpm2Test.test_tpm2_swtpm_socket']) |
35 | def test_tpm2(self): | 36 | def test_tpm2_pcrread(self): |
36 | (status, output) = self.target.run('tpm2_pcrlist') | 37 | (status, output) = self.target.run('tpm2_pcrread') |
37 | expected_endlines = [] | 38 | expected_endlines = [] |
38 | expected_endlines.append('sha1 :') | 39 | expected_endlines.append(' sha1:') |
39 | expected_endlines.append(' 0 : 0000000000000000000000000000000000000003') | 40 | expected_endlines.append(' 0 : 0x0000000000000000000000000000000000000000') |
40 | expected_endlines.append(' 1 : 0000000000000000000000000000000000000000') | 41 | expected_endlines.append(' 1 : 0x0000000000000000000000000000000000000000') |
42 | expected_endlines.append(' sha256:') | ||
43 | expected_endlines.append(' 0 : 0x0000000000000000000000000000000000000000000000000000000000000000') | ||
44 | expected_endlines.append(' 1 : 0x0000000000000000000000000000000000000000000000000000000000000000') | ||
45 | |||
41 | 46 | ||
42 | self.check_endlines(output, expected_endlines) | 47 | self.check_endlines(output, expected_endlines) |
43 | 48 | ||
49 | |||
50 | @OEHasPackage(['p11-kit']) | ||
51 | @OEHasPackage(['tpm2-pkcs11']) | ||
52 | @OETestDepends(['tpm2.Tpm2Test.test_tpm2_swtpm_socket']) | ||
53 | def test_tpm2_pkcs11(self): | ||
54 | (status, output) = self.target.run('p11-kit list-modules -v') | ||
55 | self.assertEqual(status, 0, msg="Modules missing: %s" % output) | ||
56 | |||
57 | @OETestDepends(['tpm2.Tpm2Test.test_tpm2_pkcs11']) | ||
58 | def test_tpm2_swtpm_reset(self): | ||
59 | (status, output) = self.target.run('swtpm_ioctl -i --tcp :2322') | ||
60 | self.assertEqual(status, 0, msg="swtpm reset failed: %s" % output) | ||