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

test-runner: write separators for transient processes

Many processes are not long running (e.g. hostapd_cli, ip, iw, etc)
and the separators written to log files don't show up for these which
makes debugging difficult. This is even true for IWD/Hostapd for tests
with start_iwd=0.

After writing separators for long running processes write them out for
any additional log files too.
This commit is contained in:
James Prestwood 2022-04-06 12:14:49 -07:00 committed by Denis Kenzior
parent f199e3f40d
commit e70d7e0857
2 changed files with 26 additions and 2 deletions

View File

@ -724,7 +724,10 @@ def start_test(ctx, subtests, rqueue):
sys.__stdout__.flush() sys.__stdout__.flush()
Process.write_separators("\n====== %s:%s ======\n\n" % (file, func)) name = os.path.basename(os.getcwd())
Process.write_separators(name, "\n====== %s:%s:%s ======\n\n" %
(name, file, func))
if not skip: if not skip:
# Run test (setUp/tearDown run automatically) # Run test (setUp/tearDown run automatically)

View File

@ -131,12 +131,33 @@ class Process(subprocess.Popen):
sys.__stdout__.flush() sys.__stdout__.flush()
@classmethod @classmethod
def write_separators(cls, sep): def write_separators(cls, test, sep):
#
# There are either log running processes (cls.processes) or
# processes that have terminated already but a log file exists
# on disk. We still want the separators to show for both cases
# so after writing separators for running processes, also
# write them in any additional log files.
#
nowrite = []
for proc in cls.processes.values(): for proc in cls.processes.values():
if proc.killed: if proc.killed:
continue continue
cls._write_io(proc, sep, stdout=False) cls._write_io(proc, sep, stdout=False)
nowrite.append(proc.args[0])
if cls.testargs.log:
logfiles = os.listdir('%s/%s' % (cls.testargs.log, test))
extra = list(set(logfiles) - set(nowrite))
for log in extra:
logfile = '%s/%s/%s' % (cls.testargs.log, test, log)
with open(logfile, 'a') as f:
f.write(sep)
f.close()
def process_io(self, source, condition): def process_io(self, source, condition):
if condition & GLib.IO_HUP: if condition & GLib.IO_HUP: