All of lore.kernel.org
 help / color / mirror / Atom feed
* should the functional-testing scratch_file() utility guarantee that the path it returns doesn't exist?
@ 2025-09-08 13:13 Peter Maydell
  2025-09-08 13:42 ` Daniel P. Berrangé
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2025-09-08 13:13 UTC (permalink / raw)
  To: QEMU Developers
  Cc: Thomas Huth, Phil Mathieu-Daudé, Daniel P. Berrange,
	Pierrick Bouvier

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=yEysob0w@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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-08 13:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-08 13:13 should the functional-testing scratch_file() utility guarantee that the path it returns doesn't exist? Peter Maydell
2025-09-08 13:42 ` Daniel P. Berrangé
2025-09-08 13:48   ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.