diff options
Diffstat (limited to 'meta-tpm/lib/oeqa/runtime/cases/tpm2.py')
-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) | ||