From af883e88e16fa7a898ec5d253c3a78659a26555e Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 31 Aug 2018 17:28:27 +0300 Subject: [PATCH] ts: support QEMU launcher --- modules/ts/misc/run.py | 3 +++ modules/ts/misc/run_suite.py | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/ts/misc/run.py b/modules/ts/misc/run.py index 74b353a532..29c0aa6b90 100755 --- a/modules/ts/misc/run.py +++ b/modules/ts/misc/run.py @@ -40,6 +40,9 @@ if __name__ == "__main__": parser.add_argument("--valgrind_supp", metavar="FILE", action='append', help="Path to valgrind suppression file (example: --valgrind_supp opencv/platforms/scripts/valgrind.supp)") parser.add_argument("--valgrind_opt", metavar="OPT", action="append", default=[], help="Add command line option to valgrind (example: --valgrind_opt=--leak-check=full)") + # QEMU + parser.add_argument("--qemu", default="", help="Specify qemu binary and base parameters") + # Android parser.add_argument("--android", action="store_true", default=False, help="Android: force all tests to run on device") parser.add_argument("--android_sdk", metavar="PATH", help="Android: path to SDK to use adb and aapt tools") diff --git a/modules/ts/misc/run_suite.py b/modules/ts/misc/run_suite.py index 947db1e2b5..c7103a6263 100644 --- a/modules/ts/misc/run_suite.py +++ b/modules/ts/misc/run_suite.py @@ -77,7 +77,7 @@ class TestSuite(object): return False return os.access(fullpath, os.X_OK) - def wrapInValgrind(self, cmd=[]): + def wrapCommand(self, cmd, env): if self.options.valgrind: res = ['valgrind'] supp = self.options.valgrind_supp or [] @@ -89,6 +89,14 @@ class TestSuite(object): res.extend(self.options.valgrind_opt) has_gtest_filter = next((True for x in cmd if x.startswith('--gtest_filter=')), False) return res + cmd + ([longTestFilter(LONG_TESTS_DEBUG_VALGRIND)] if not has_gtest_filter else []) + elif self.options.qemu: + import shlex + res = shlex.split(self.options.qemu) + for (name, value) in [entry for entry in os.environ.items() if entry[0].startswith('OPENCV') and not entry[0] in env]: + res += ['-E', '"{}={}"'.format(name, value)] + for (name, value) in env.items(): + res += ['-E', '"{}={}"'.format(name, value)] + return res + ['--'] + cmd return cmd def tryCommand(self, cmd, workingDir): @@ -125,7 +133,6 @@ class TestSuite(object): else: if isColorEnabled(args): args.append("--gtest_color=yes") - cmd = self.wrapInValgrind([exe] + args) env = {} if not self.options.valgrind and self.options.trace: env['OPENCV_TRACE'] = '1' @@ -133,6 +140,7 @@ class TestSuite(object): env['OPENCV_TRACE_SYNC_OPENCL'] = '1' tempDir = TempEnvDir('OPENCV_TEMP_PATH', "__opencv_temp.") tempDir.init() + cmd = self.wrapCommand([exe] + args, env) log.warning("Run: %s" % " ".join(cmd)) ret = execute(cmd, cwd=workingDir, env=env) try: