#!/usr/bin/env python
import os
import re
+import sys
from run_utils import Err, log, execute, getPlatformVersion, isColorEnabled, TempEnvDir
from run_long import LONG_TESTS_DEBUG_VALGRIND, longTestFilter
return False
return os.access(fullpath, os.X_OK)
- def wrapInValgrind(self, cmd=[]):
+ def wrapCommand(self, module, cmd, env):
if self.options.valgrind:
res = ['valgrind']
supp = self.options.valgrind_supp or []
print("WARNING: Valgrind suppression file is missing, SKIP: %s" % f)
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 [])
+ return res + cmd + ([longTestFilter(LONG_TESTS_DEBUG_VALGRIND, module)] 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):
pass
return False
- def runTest(self, path, logfile, workingDir, args=[]):
+ def runTest(self, module, path, logfile, workingDir, args=[]):
args = args[:]
exe = os.path.abspath(path)
- if path == "java":
- cmd = [self.cache.ant_executable, "-Dopencv.build.type=%s" % self.cache.build_type, "buildAndTest"]
+ if module == "java":
+ cmd = [self.cache.ant_executable, "-Dopencv.build.type=%s" % self.cache.build_type]
+ if self.options.package:
+ cmd += ["-Dopencv.test.package=%s" % self.options.package]
+ if self.options.java_test_exclude:
+ cmd += ["-Dopencv.test.exclude=%s" % self.options.java_test_exclude]
+ cmd += ["buildAndTest"]
ret = execute(cmd, cwd=self.cache.java_test_dir)
return None, ret
- elif path in ['python2', 'python3']:
+ elif module in ['python2', 'python3']:
executable = os.getenv('OPENCV_PYTHON_BINARY', None)
+ if executable is None or module == 'python{}'.format(sys.version_info[0]):
+ executable = sys.executable
if executable is None:
executable = path
if not self.tryCommand([executable, '--version'], workingDir):
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'
env['OPENCV_TRACE_SYNC_OPENCL'] = '1'
tempDir = TempEnvDir('OPENCV_TEMP_PATH', "__opencv_temp.")
tempDir.init()
+ cmd = self.wrapCommand(module, [exe] + args, env)
log.warning("Run: %s" % " ".join(cmd))
ret = execute(cmd, cwd=workingDir, env=env)
try:
if self.options.dry_run:
logfile, r = None, 0
else:
- logfile, r = self.runTest(exe, logname, workingDir, args + more_args)
+ logfile, r = self.runTest(test, exe, logname, workingDir, args + more_args)
log.debug("Test returned: %s ==> %s", r, logfile)
if r != 0: