tests: parallel-vm: allow running without curses
Allow running without curses, in which case the log is simply written to stdout instead of a file. This is useful for automated (but parallel) testing. Note that in most cases, you'd want to specify --debug, and so I added a .rstrip() there on the lines to clean that up a bit. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
4ee5a50358
commit
f124367afb
1 changed files with 22 additions and 3 deletions
|
@ -104,7 +104,7 @@ def vm_read_stdout(vm, test_queue):
|
||||||
if e.errno == errno.EAGAIN:
|
if e.errno == errno.EAGAIN:
|
||||||
return False
|
return False
|
||||||
raise
|
raise
|
||||||
logger.debug("VM[%d] stdout.read[%s]" % (vm['idx'], out))
|
logger.debug("VM[%d] stdout.read[%s]" % (vm['idx'], out.rstrip()))
|
||||||
pending = vm['pending'] + out
|
pending = vm['pending'] + out
|
||||||
lines = []
|
lines = []
|
||||||
while True:
|
while True:
|
||||||
|
@ -389,6 +389,8 @@ def main():
|
||||||
help="run tests under valgrind")
|
help="run tests under valgrind")
|
||||||
p.add_argument('--telnet', dest='telnet', metavar='<baseport>', type=int,
|
p.add_argument('--telnet', dest='telnet', metavar='<baseport>', type=int,
|
||||||
help="enable telnet server inside VMs, specify the base port here")
|
help="enable telnet server inside VMs, specify the base port here")
|
||||||
|
p.add_argument('--nocurses', dest='nocurses', action='store_const',
|
||||||
|
const=True, default=False, help="Don't use curses for output")
|
||||||
p.add_argument('params', nargs='*')
|
p.add_argument('params', nargs='*')
|
||||||
args = p.parse_args()
|
args = p.parse_args()
|
||||||
|
|
||||||
|
@ -452,7 +454,10 @@ def main():
|
||||||
tests = [t for t in tests if t not in long_tests]
|
tests = [t for t in tests if t not in long_tests]
|
||||||
|
|
||||||
logger.setLevel(debug_level)
|
logger.setLevel(debug_level)
|
||||||
log_handler = logging.FileHandler('parallel-vm.log')
|
if not args.nocurses:
|
||||||
|
log_handler = logging.FileHandler('parallel-vm.log')
|
||||||
|
else:
|
||||||
|
log_handler = logging.StreamHandler(sys.stdout)
|
||||||
log_handler.setLevel(debug_level)
|
log_handler.setLevel(debug_level)
|
||||||
fmt = "%(asctime)s %(levelname)s %(message)s"
|
fmt = "%(asctime)s %(levelname)s %(message)s"
|
||||||
log_formatter = logging.Formatter(fmt)
|
log_formatter = logging.Formatter(fmt)
|
||||||
|
@ -481,7 +486,21 @@ def main():
|
||||||
vm[i]['skip_reason'] = []
|
vm[i]['skip_reason'] = []
|
||||||
print('')
|
print('')
|
||||||
|
|
||||||
curses.wrapper(show_progress)
|
if not args.nocurses:
|
||||||
|
curses.wrapper(show_progress)
|
||||||
|
else:
|
||||||
|
class FakeScreen:
|
||||||
|
def leaveok(self, n):
|
||||||
|
pass
|
||||||
|
def refresh(self):
|
||||||
|
pass
|
||||||
|
def addstr(self, *args, **kw):
|
||||||
|
pass
|
||||||
|
def move(self, x, y):
|
||||||
|
pass
|
||||||
|
def clrtoeol(self):
|
||||||
|
pass
|
||||||
|
show_progress(FakeScreen())
|
||||||
|
|
||||||
with open('{}/{}-parallel.log'.format(dir, timestamp), 'w') as f:
|
with open('{}/{}-parallel.log'.format(dir, timestamp), 'w') as f:
|
||||||
for i in range(0, num_servers):
|
for i in range(0, num_servers):
|
||||||
|
|
Loading…
Reference in a new issue