3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-25 09:39:25 +01:00

test-runner: fix logging for namespaces and pre-test processes

Namespace process logs were appearing under 'ip' (and also overwriting
actual 'ip' logs) since they were executed with 'ip netns exec <namespace>'.
Instead special case this and append '-<namespace>' to the log file name.

In addition processes executed prior to any tests were being put under
a folder (name of testhome directory). Now this case is detected and these
logs are put at the top level log directory.
This commit is contained in:
James Prestwood 2022-03-31 16:16:32 -07:00 committed by Denis Kenzior
parent b5df2e27be
commit 54552db7ba

View File

@ -129,6 +129,8 @@ class Process(subprocess.Popen):
self.killed = False self.killed = False
self.namespace = namespace self.namespace = namespace
logfile = args[0]
if not self.ctx: if not self.ctx:
global config global config
self.ctx = config.ctx self.ctx = config.ctx
@ -138,6 +140,7 @@ class Process(subprocess.Popen):
if namespace: if namespace:
args = ['ip', 'netns', 'exec', namespace] + args args = ['ip', 'netns', 'exec', namespace] + args
logfile += '-%s' % namespace
if outfile: if outfile:
# outfile is only used by iwmon, in which case we don't want # outfile is only used by iwmon, in which case we don't want
@ -145,9 +148,16 @@ class Process(subprocess.Popen):
self._append_outfile(outfile, append=False) self._append_outfile(outfile, append=False)
if self.ctx.args.log: if self.ctx.args.log:
logfile = '%s/%s/%s' % (self.ctx.args.log, testdir = os.getcwd()
os.path.basename(os.getcwd()),
args[0]) # Special case any processes started prior to a test
# (i.e. from testhome). Put these in the root log directory
if testdir == self.ctx.args.testhome:
testdir = '.'
else:
testdir = os.path.basename(testdir)
logfile = '%s/%s/%s' % (self.ctx.args.log, testdir, logfile)
self._append_outfile(logfile) self._append_outfile(logfile)
super().__init__(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, super().__init__(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,