iotests: Write test output to TEST_DIR

Drop the use of OUTPUT_DIR (test/qemu-iotests under the build
directory), and instead write test output files (.out.bad, .notrun, and
.casenotrun) to TEST_DIR.

With this, the same test can be run concurrently without the separate
instances interfering, because they will need separate TEST_DIRs anyway.
Running the same test separately is useful when running the iotests with
various format/protocol combinations in parallel, or when you just want
to aggressively exercise a single test (e.g. when it fails only
sporadically).

Putting this output into TEST_DIR means that it will stick around for
inspection after the test run is done (though running the same test in
the same TEST_DIR will overwrite it, just as it used to be); but given
that TEST_DIR is a scratch directory, it should be clear that users can
delete all of its content at any point.  (And if TEST_DIR is on tmpfs,
it will just disappear on shutdown.)  Contrarily, alternative approaches
that would put these output files into OUTPUT_DIR with some prefix to
differentiate between separate test runs might easily lead to cluttering
OUTPUT_DIR.

(This change means OUTPUT_DIR is no longer written to by the iotests, so
we can drop its usage altogether.)

Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220221172909.762858-1-hreitz@redhat.com>
[hreitz: Simplified `Path(os.path.join(x, y))` to `Path(x, y)`, as
         suggested by Vladimir; and rebased on 9086c76398
         ("tests/qemu-iotests: Rework the checks and spots using GNU
         sed")]
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
This commit is contained in:
Hanna Reitz 2022-02-21 18:29:09 +01:00
parent db4b2133b8
commit 1a8fcca03f
4 changed files with 14 additions and 16 deletions

View file

@ -85,7 +85,6 @@ qemu_print = os.environ.get('PRINT_QEMU', False)
imgfmt = os.environ.get('IMGFMT', 'raw')
imgproto = os.environ.get('IMGPROTO', 'file')
output_dir = os.environ.get('OUTPUT_DIR', '.')
try:
test_dir = os.environ['TEST_DIR']
@ -1239,7 +1238,7 @@ def notrun(reason):
# Each test in qemu-iotests has a number ("seq")
seq = os.path.basename(sys.argv[0])
with open('%s/%s.notrun' % (output_dir, seq), 'w', encoding='utf-8') \
with open('%s/%s.notrun' % (test_dir, seq), 'w', encoding='utf-8') \
as outfile:
outfile.write(reason + '\n')
logger.warning("%s not run: %s", seq, reason)
@ -1254,7 +1253,7 @@ def case_notrun(reason):
# Each test in qemu-iotests has a number ("seq")
seq = os.path.basename(sys.argv[0])
with open('%s/%s.casenotrun' % (output_dir, seq), 'a', encoding='utf-8') \
with open('%s/%s.casenotrun' % (test_dir, seq), 'a', encoding='utf-8') \
as outfile:
outfile.write(' [case not run] ' + reason + '\n')