diff options
-rw-r--r-- | meta-tpm/lib/oeqa/runtime/cases/tpm2.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/meta-tpm/lib/oeqa/runtime/cases/tpm2.py b/meta-tpm/lib/oeqa/runtime/cases/tpm2.py new file mode 100644 index 0000000..240a9b3 --- /dev/null +++ b/meta-tpm/lib/oeqa/runtime/cases/tpm2.py | |||
@@ -0,0 +1,43 @@ | |||
1 | # Copyright (C) 2019 Armin Kuster <akuster808@gmail.com> | ||
2 | # | ||
3 | from oeqa.runtime.case import OERuntimeTestCase | ||
4 | from oeqa.core.decorator.depends import OETestDepends | ||
5 | from oeqa.runtime.decorator.package import OEHasPackage | ||
6 | |||
7 | |||
8 | class Tpm2Test(OERuntimeTestCase): | ||
9 | def check_endlines(self, results, expected_endlines): | ||
10 | for line in results.splitlines(): | ||
11 | for el in expected_endlines: | ||
12 | if line == el: | ||
13 | expected_endlines.remove(el) | ||
14 | break | ||
15 | |||
16 | if expected_endlines: | ||
17 | self.fail('Missing expected line endings:\n %s' % '\n '.join(expected_endlines)) | ||
18 | |||
19 | @OEHasPackage(['tpm2.0-tss']) | ||
20 | @OEHasPackage(['tpm2-abrmd']) | ||
21 | @OEHasPackage(['tpm2.0-tools']) | ||
22 | @OEHasPackage(['ibmswtpm2']) | ||
23 | @OETestDepends(['ssh.SSHTest.test_ssh']) | ||
24 | def test_tpm2_sim(self): | ||
25 | cmds = [ | ||
26 | 'tpm_server &', | ||
27 | 'tpm2-abrmd --allow-root --tcti=mssim &' | ||
28 | ] | ||
29 | |||
30 | for cmd in cmds: | ||
31 | status, output = self.target.run(cmd) | ||
32 | self.assertEqual(status, 0, msg='\n'.join([cmd, output])) | ||
33 | |||
34 | @OETestDepends(['tpm2.Tpm2Test.test_tpm2_sim']) | ||
35 | def test_tpm2(self): | ||
36 | (status, output) = self.target.run('tpm2_pcrlist') | ||
37 | expected_endlines = [] | ||
38 | expected_endlines.append('sha1 :') | ||
39 | expected_endlines.append(' 0 : 0000000000000000000000000000000000000003') | ||
40 | expected_endlines.append(' 1 : 0000000000000000000000000000000000000000') | ||
41 | |||
42 | self.check_endlines(output, expected_endlines) | ||
43 | |||