blob: 0be5c59d4f305f866fe7bfe529eabe6145168a7d [file] [log] [blame]
Andrew Geissler78b72792022-06-14 06:47:25 -05001# Copyright (C) 2022 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
6from oeqa.core.decorator.data import skipIfNotFeature
7
8class SwTpmTest(OERuntimeTestCase):
9 @classmethod
10 def setUpClass(cls):
Andrew Geissler615f2f12022-07-15 14:00:58 -050011 cls.tc.target.run('swtpm_ioctl -s --tcp :2322')
Andrew Geissler78b72792022-06-14 06:47:25 -050012 cls.tc.target.run('mkdir /tmp/myvtpm2')
13 cls.tc.target.run('chown tss:root /tmp/myvtpm2')
14
15 @classmethod
16 def tearDownClass(cls):
Andrew Geissler615f2f12022-07-15 14:00:58 -050017 cls.tc.target.run('swtpm_ioctl -s --tcp :2322')
Andrew Geissler78b72792022-06-14 06:47:25 -050018 cls.tc.target.run('rm -fr /tmp/myvtpm2')
19
20 @skipIfNotFeature('tpm2','Test tpm2_swtpm_socket requires tpm2 to be in DISTRO_FEATURES')
21 @OETestDepends(['ssh.SSHTest.test_ssh'])
22 @OEHasPackage(['swtpm'])
23 def test_swtpm2_ek_cert(self):
24 cmd = 'swtpm_setup --tpmstate /tmp/myvtpm2 --create-ek-cert --create-platform-cert --tpm2',
25 status, output = self.target.run(cmd)
26 self.assertEqual(status, 0, msg="swtpm create-ek-cert failed: %s" % output)