blob: 240a9b3bab1a138fdf3e4cda9bfdb6d3f74911ce [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001# Copyright (C) 2019 Armin Kuster <akuster808@gmail.com>
2#
3from oeqa.runtime.case import OERuntimeTestCase
4from oeqa.core.decorator.depends import OETestDepends
5from oeqa.runtime.decorator.package import OEHasPackage
6
7
8class 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