[tests] improve tmpdir structure #10433
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tl;dr:
--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:
a
--tmpdirargument can be passed into the individual test case, which causes the temp directory to be written to:If
--tmpdiris passed to the test_runner, then it gets passed down to the indivdual tests and the directory structure is:There are a few problems:
--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$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:
--tmpdiris specified$TMPDIR/test<rand_chars>(as now, except without the<port seed>subdirectory)--tmpdiris specified<port seed>subdirectory)--tmpdirprefixis specified$TMPDIR/bitcoin_test_runner_<date>_<time>/<test_name>_portseed.--tmpdirprefixis specified<tmpdirprefix>/bitcoin_test_runner_<date>_<time>/<test_name>_portseed.<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).