The functional testing framework includes a utility function scratch_file() which you can use to get a path for a scratch file to use in the test. However, it doesn't do anything to ensure that the path it returns doesn't already exist. Should it?
I ran into this with the aarch64/test_rme_sbsaref.py test: this does: rme_stack = self.scratch_file('.') to get a scratch path, and then uses it both to place specific files: pflash0 = join(rme_stack, 'out', 'SBSA_FLASH0.fd') and to place subdirectories: efi = join(rme_stack, 'out', 'EFI') os.makedirs(efi, exist_ok=True) In the original version of this test we used os.mkdir(efi), but this fails sometimes because the directory already exists (typically if the test was interrupted during a previous run); see this email for the error log: https://lore.kernel.org/qemu-devel/CAFEAcA_ZQ13qMRUQsieJiEPV=ULrDbz8=EJaW4_kw=yeyso...@mail.gmail.com/ But this seems a bit of a hacky workaround to me -- shouldn't the test framework guarantee to the test that it's returning a path that doesn't already have something there? Secondary question: is it OK to pass '.' to this function and then construct filenames based on the return value, or would it be better to call scratch_file('out', 'SBSA_FLASH0.fd') etc and have the utility function construct the whole path? thanks -- PMM