@@ -31,6 +31,12 @@ def cli():
default=[],
help="Run the testcases present in the given directory and all of its sub directories. Provide the space separated paths to add multiple directories.")
+ parser.add_argument("-p",
+ "--path",
+ nargs='?',
+ default=".",
+ help="Finds the test executables in the given path. Default is the current directory.")
+
return parser.parse_args()
@@ -87,7 +93,7 @@ def main():
args = cli()
setup_logging()
testcases = fetch_testcases(args)
- return TestRunner(testcases).start()
+ return TestRunner(testcases, args).start()
if __name__ == "__main__":
@@ -28,12 +28,12 @@ class Selftest:
Extract the test execution command from test file and executes it.
"""
- def __init__(self, test_path):
+ def __init__(self, test_path, path):
test_command = pathlib.Path(test_path).read_text().strip()
if not test_command:
raise ValueError("Empty test command in " + test_path)
- test_command = os.path.join(".", test_command)
+ test_command = os.path.join(path, test_command)
self.exists = os.path.isfile(test_command.split(maxsplit=1)[0])
self.test_path = test_path
self.command = test_command
@@ -11,11 +11,11 @@ logger = logging.getLogger("runner")
class TestRunner:
- def __init__(self, testcases):
+ def __init__(self, testcases, args):
self.tests = []
for testcase in testcases:
- self.tests.append(Selftest(testcase))
+ self.tests.append(Selftest(testcase, args.path))
def _log_result(self, test_result):
logger.info("*** stdout ***\n" + test_result.stdout)
Add command line option, -p/--path, to specify the directory where test binaries exist. If this option is not provided then default to the current directory. Example: python3 runner --dirs test -p ~/build/selftests This option enables executing tests from out-of-tree builds. Signed-off-by: Vipin Sharma <vipinsh@google.com> --- tools/testing/selftests/kvm/runner/__main__.py | 8 +++++++- tools/testing/selftests/kvm/runner/selftest.py | 4 ++-- tools/testing/selftests/kvm/runner/test_runner.py | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-)