Andrew Geissler | 78b7279 | 2022-06-14 06:47:25 -0500 | [diff] [blame] | 1 | # Copyright (C) 2022 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 | from oeqa.core.decorator.data import skipIfNotFeature |
| 7 | |
| 8 | class SwTpmTest(OERuntimeTestCase): |
| 9 | @classmethod |
| 10 | def setUpClass(cls): |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 11 | cls.tc.target.run('swtpm_ioctl -s --tcp :2322') |
Andrew Geissler | 78b7279 | 2022-06-14 06:47:25 -0500 | [diff] [blame] | 12 | 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 Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 17 | cls.tc.target.run('swtpm_ioctl -s --tcp :2322') |
Andrew Geissler | 78b7279 | 2022-06-14 06:47:25 -0500 | [diff] [blame] | 18 | 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) |