From: Jouni Malinen Date: Wed, 19 Nov 2014 00:01:27 +0000 (+0200) Subject: tests: Add run-tests.py -i to control execution from stdin X-Git-Tag: hostap_2_4~1111 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0d7456e9fd2ed98502ffde267b536b5b0f1a713a;p=thirdparty%2Fhostap.git tests: Add run-tests.py -i to control execution from stdin The new -i command line argument can be used to control test case execution from stdin to run-tests.py and vm-run.sh. This can be used, e.g., to run multiple repeated test sequences in a virtual machine without havign to restart the VM between each iteration. Signed-off-by: Jouni Malinen --- diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py index b267228ff..481b7858b 100755 --- a/tests/hwsim/run-tests.py +++ b/tests/hwsim/run-tests.py @@ -204,6 +204,8 @@ def main(): type=str, choices=[[]] + test_modules, nargs='+') parser.add_argument('-l', metavar='', dest='mfile', help='test modules file name') + parser.add_argument('-i', action='store_true', dest='stdin_ctrl', + help='stdin-controlled test case execution') parser.add_argument('tests', metavar='', nargs='*', type=str, help='tests to run (only valid without -f)', choices=[[]] + test_names) @@ -339,7 +341,34 @@ def main(): shuffle(tests_to_run) count = 0 - for t in tests_to_run: + if args.stdin_ctrl: + print "READY" + sys.stdout.flush() + else: + remaining_tests = tests_to_run + while True: + if args.stdin_ctrl: + test = sys.stdin.readline() + if not test: + break + test = test.splitlines()[0] + if test == '': + break + t = None + for tt in tests: + name = tt.__name__.replace('test_', '', 1) + if name == test: + t = tt + break + if not t: + print "NOT-FOUND" + sys.stdout.flush() + continue + else: + if len(remaining_tests) == 0: + break + t = remaining_tests.pop(0) + name = t.__name__.replace('test_', '', 1) if log_handler: log_handler.stream.close()