aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArmin Kuster <akuster808@gmail.com>2019-03-21 16:57:40 -0700
committerArmin Kuster <akuster808@gmail.com>2019-03-23 09:15:39 -0700
commit3406611b124b866d873fc25b43c87dff748e94ca (patch)
tree7b18dd0a52147383f333d62d8d0220361bbae847
parent30699d6baee86bc6fda8a2b68e2e5d87fd01bdab (diff)
downloadmeta-security-3406611b124b866d873fc25b43c87dff748e94ca.tar.gz
meta-security-3406611b124b866d873fc25b43c87dff748e94ca.tar.bz2
meta-security-3406611b124b866d873fc25b43c87dff748e94ca.zip
meta-tpm: add runtime test for tpm2
This runs a basic tpm test using the simulator Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r--meta-tpm/lib/oeqa/runtime/cases/tpm2.py43
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 @@
+# Copyright (C) 2019 Armin Kuster <akuster808@gmail.com>
+#
+from oeqa.runtime.case import OERuntimeTestCase
+from oeqa.core.decorator.depends import OETestDepends
+from oeqa.runtime.decorator.package import OEHasPackage
+
+
+class Tpm2Test(OERuntimeTestCase):
+ def check_endlines(self, results, expected_endlines):
+ for line in results.splitlines():
+ for el in expected_endlines:
+ if line == el:
+ expected_endlines.remove(el)
+ break
+
+ if expected_endlines:
+ self.fail('Missing expected line endings:\n %s' % '\n '.join(expected_endlines))
+
+ @OEHasPackage(['tpm2.0-tss'])
+ @OEHasPackage(['tpm2-abrmd'])
+ @OEHasPackage(['tpm2.0-tools'])
+ @OEHasPackage(['ibmswtpm2'])
+ @OETestDepends(['ssh.SSHTest.test_ssh'])
+ def test_tpm2_sim(self):
+ cmds = [
+ 'tpm_server &',
+ 'tpm2-abrmd --allow-root --tcti=mssim &'
+ ]
+
+ for cmd in cmds:
+ status, output = self.target.run(cmd)
+ self.assertEqual(status, 0, msg='\n'.join([cmd, output]))
+
+ @OETestDepends(['tpm2.Tpm2Test.test_tpm2_sim'])
+ def test_tpm2(self):
+ (status, output) = self.target.run('tpm2_pcrlist')
+ expected_endlines = []
+ expected_endlines.append('sha1 :')
+ expected_endlines.append(' 0 : 0000000000000000000000000000000000000003')
+ expected_endlines.append(' 1 : 0000000000000000000000000000000000000000')
+
+ self.check_endlines(output, expected_endlines)
+