This patch enhances scripts/test.py to allow passing extra arguments to run.py. This allows executing running unit tests with different than default parameters.
See examples below how to run tests with different virtio configuration: ./scripts/test.py --run_options '--virtio legacy' ./scripts/test.py --run_options '--virtio modern' ./scripts/test.py --run_options '--virtio modern -S' Signed-off-by: Waldemar Kozaczuk <[email protected]> --- scripts/test.py | 8 +++++++- scripts/tests/testing.py | 10 +++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/test.py b/scripts/test.py index 5f8f0b6d..ffc95701 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -57,6 +57,7 @@ def run_test(test): start = time.time() try: + test.set_run_py_args(run_py_args) test.run() except: sys.stdout.write("Test %s FAILED\n" % test.name) @@ -75,7 +76,7 @@ def run_tests_in_single_instance(): run(filter(lambda test: not isinstance(test, TestRunnerTest), tests)) blacklist_tests = ' '.join(blacklist) - args = ["-s", "-e", "/testrunner.so -b %s" % (blacklist_tests)] + args = run_py_args + ["-s", "-e", "/testrunner.so -b %s" % (blacklist_tests)] if subprocess.call(["./scripts/run.py"] + args): exit(1) @@ -182,6 +183,11 @@ if __name__ == "__main__": parser.add_argument("-s", "--single", action="store_true", help="run as much tests as possible in a single OSv instance") parser.add_argument("-n", "--nfs", action="store_true", help="run nfs test in a single OSv instance") parser.add_argument("--name", action="store", help="run all tests whose names match given regular expression") + parser.add_argument("--run_options", action="store", help="pass extra options to run.py") cmdargs = parser.parse_args() set_verbose_output(cmdargs.verbose) + if cmdargs.run_options != None: + run_py_args = cmdargs.run_options.split() + else: + run_py_args = [] main() diff --git a/scripts/tests/testing.py b/scripts/tests/testing.py index 6d73e41c..587366b5 100644 --- a/scripts/tests/testing.py +++ b/scripts/tests/testing.py @@ -16,6 +16,10 @@ class TestFailed(Exception): class Test(object): def __init__(self, name): self.name = name + self.run_py_args = [] + + def set_run_py_args(self, args): + self.run_py_args = args def run(self): pass @@ -26,7 +30,7 @@ class SingleCommandTest(Test): self.command = command def run(self): - run_command_in_guest(self.command).join() + run_command_in_guest(self.command, run_py_args=self.run_py_args).join() class test(Test): """ @@ -182,7 +186,7 @@ def run_command_in_guest(command, **kwargs): class Guest(SupervisedProcess): def __init__(self, args, forward=[], hold_with_poweroff=False, show_output_on_error=True, - scan_for_failed_to_load_object_error=True): + scan_for_failed_to_load_object_error=True, run_py_args=[]): run_script = os.path.join(osv_base, "scripts/run.py") @@ -197,7 +201,7 @@ class Guest(SupervisedProcess): args.extend(['--unsafe-cache']) - SupervisedProcess.__init__(self, [run_script] + args, + SupervisedProcess.__init__(self, [run_script] + run_py_args + args, show_output=_verbose_output, show_output_on_error=show_output_on_error, scan_for_failed_to_load_object_error=scan_for_failed_to_load_object_error) -- 2.19.1 -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
