ZTS: test-runner: always apply timestamp to outputdir before updating

The default outputdir had a timestamp appended in TestRun.__init__, and
then the timestamp was unconditionally applied again after the runfile
had been loaded, assuming that an outputdir would be set in the runfile
too. If the runfile didn't have an outputdir, then the outputdir would
get a second timestamp appended.

Further, if test groups or individual tests themselves specificed an
outputdir, those would be set on their config, but would not get a
timestamp appended. It's not entirely clear if that's wrong or not, but
it is certainly not consistent with the rest.

To clean all this up, change things to append a timestamp to a received
outputdir (from arg or runfile) before setting it in any TestRun,
TestGroup or Test object.

Sponsored-by: https://despairlabs.com/sponsor/
Signed-off-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
This commit is contained in:
Rob Norris 2025-02-15 10:23:04 +11:00 committed by Tony Hutter
parent 4581c4fcbe
commit 2c897e0666

View File

@ -746,8 +746,11 @@ class TestRun(object):
for opt in TestRun.props:
if config.has_option('DEFAULT', opt):
if opt == 'outputdir':
outputdir = config.get('DEFAULT', opt)
setattr(self, opt, os.path.join(outputdir, self.timestamp))
else:
setattr(self, opt, config.get('DEFAULT', opt))
self.outputdir = os.path.join(self.outputdir, self.timestamp)
testdir = options.testdir
@ -775,6 +778,11 @@ class TestRun(object):
failsafe = config.get(sect, prop)
setattr(testgroup, prop,
os.path.join(testdir, failsafe))
elif prop == 'outputdir':
outputdir = config.get(sect, prop)
setattr(self, opt,
os.path.join(outputdir,
self.timestamp))
else:
setattr(testgroup, prop,
config.get(sect, prop))
@ -793,6 +801,11 @@ class TestRun(object):
failsafe = config.get(sect, prop)
setattr(test, prop,
os.path.join(testdir, failsafe))
elif prop == 'outputdir':
outputdir = config.get(sect, prop)
setattr(self, opt,
os.path.join(outputdir,
self.timestamp))
else:
setattr(test, prop, config.get(sect, prop))