tl;dr:
- temp directories now include the name of the test when run through the test_runner
- passing a
--tmpdirprefixto the test_runner allows test_runner to be called by cron/build jobs without risk of directory name collision
==================
By default, the functional tests create their temp directories in the $TMPDIR as follows:
$TMPDIR
|
-- test<rand_chars>
|
-- <port seed>
|
-- temp files
-- ...
a --tmpdir argument can be passed into the individual test case, which causes the temp directory to be written to:
<specified --tmpdir>
|
-- <port seed>
|
-- temp files
-- ...
If --tmpdir is passed to the test_runner, then it gets passed down to the indivdual tests and the directory structure is:
<specified --tmpdir>
|
-- <port seed 1>
|
-- temp files
-- ...
-- <port seed 2>
|
-- temp files
-- ...
-- ...
There are a few problems:
- the directory names give no indication of which test was being run, so it's difficult to quickly find the temp directory for an indvidual test if using the test_runner
- if a
--tmpdirdirectory is passed to the test_runner and there are already directories in that tmpdir with names that clash with the port seed, then tests will fail when they try to use that subdirectory. This can be a problem when running test_runner as a cron job or build job with a specified tmpdir. Test failures in one build will cause subsequent runs to fail because the subdirectories are not cleaned up - even if a tmpdir is specified, test_framework will still create an empty temp directory
$TMPDIR/test<rand_chars>(this is becausetempfile.mkdtemp(prefix="test")is called even when--tmpdiris used).
This PR changes the temp dir structure so that:
- if running the test directly:
- if no
--tmpdiris specified- temp directory is
$TMPDIR/test<rand_chars>(as now, except without the<port seed>subdirectory)
- temp directory is
- if a
--tmpdiris specified- temp directory is the specified tmpdir (as now, except without the
<port seed>subdirectory)
- temp directory is the specified tmpdir (as now, except without the
- if no
- if running through the test_runner
- if no
--tmpdirprefixis specified- temp directory is
$TMPDIR/bitcoin_test_runner_<date>_<time>/<test_name>_portseed.
- temp directory is
- if a
--tmpdirprefixis specified- temp directory is
<tmpdirprefix>/bitcoin_test_runner_<date>_<time>/<test_name>_portseed.
- temp directory is
- if no
<tmpdirprefix> will be cleaned up by the test_runner if it is empty at the end of all tests (ie if all tests have cleaned up their own temp directories).