diff options
author | Stefan Berger <stefanb@linux.ibm.com> | 2024-11-06 13:07:51 -0500 |
---|---|---|
committer | Stefan Berger <stefanb@linux.ibm.com> | 2024-11-07 09:57:20 -0500 |
commit | e3edada526f3ac28f71dc8ae7a0acbc76f8e2050 (patch) | |
tree | 8693ef8dd1fbf47ef385d73bb8d9936608d34465 | |
parent | 63dc36944383f70f1c7a20f6104966d8560300fa (diff) |
tests: Adjust path for swtpm state to use path under /var/tmp/
To avoid AppArmor-related test failures when functional test are run from
somewhere under /mnt, adjust the path to swtpm's state to use an AppArmor-
supported path, such as /var/tmp, which is provided by the python function
tempfile.TemporaryDirectory().
An update to swtpm's AppArmor profile is also being done to support /var/tmp.
Link: https://lore.kernel.org/qemu-devel/CAFEAcA8A=kWLtTZ+nua-MpzqkaEjW5srOYZruZnE2tB6vmoMig@mail.gmail.com/
Link: https://github.com/stefanberger/swtpm/pull/944
Tested-by: Peter Maydell <peter.maydell@linaro.org>
Fixes: f04cb2d00d5c ("tests/functional: Convert most Aspeed machine tests")
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
-rw-r--r-- | tests/functional/test_arm_aspeed.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/functional/test_arm_aspeed.py b/tests/functional/test_arm_aspeed.py index 9761fc06a4..274eb20e81 100644 --- a/tests/functional/test_arm_aspeed.py +++ b/tests/functional/test_arm_aspeed.py @@ -227,11 +227,14 @@ class AST2x00Machine(LinuxKernelTest): image_path = self.ASSET_BR2_202302_AST2600_TPM_FLASH.fetch() - socket_dir = tempfile.TemporaryDirectory(prefix="qemu_") - socket = os.path.join(socket_dir.name, 'swtpm-socket') + tpmstate_dir = tempfile.TemporaryDirectory(prefix="qemu_") + socket = os.path.join(tpmstate_dir.name, 'swtpm-socket') + # We must put the TPM state dir in /tmp/, not the build dir, + # because some distros use AppArmor to lock down swtpm and + # restrict the set of locations it can access files in. subprocess.run(['swtpm', 'socket', '-d', '--tpm2', - '--tpmstate', f'dir={self.vm.temp_dir}', + '--tpmstate', f'dir={tpmstate_dir.name}', '--ctrl', f'type=unixio,path={socket}']) self.vm.add_args('-chardev', f'socket,id=chrtpm,path={socket}') |