Beispiel #1
0
 def runTest(self, module, path, logfile, workingDir, args=[]):
     args = args[:]
     exe = os.path.abspath(path)
     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]
         cmd += ["buildAndTest"]
         ret = execute(cmd, cwd=self.cache.java_test_dir)
         return None, ret
     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):
                 executable = 'python'
         cmd = [executable, self.cache.opencv_home + '/modules/python/test/test.py', '--repo', self.cache.opencv_home, '-v'] + args
         module_suffix = '' if 'Visual Studio' not in self.cache.cmake_generator else '/' + self.cache.build_type
         env = {}
         env['PYTHONPATH'] = self.cache.opencv_build + '/lib' + module_suffix + os.pathsep + os.getenv('PYTHONPATH', '')
         if self.cache.getOS() == 'nt':
             env['PATH'] = self.cache.opencv_build + '/bin' + module_suffix + os.pathsep + os.getenv('PATH', '')
         else:
             env['LD_LIBRARY_PATH'] = self.cache.opencv_build + '/bin' + os.pathsep + os.getenv('LD_LIBRARY_PATH', '')
         ret = execute(cmd, cwd=workingDir, env=env)
         return None, ret
     else:
         if isColorEnabled(args):
             args.append("--gtest_color=yes")
         env = {}
         if not self.options.valgrind and self.options.trace:
             env['OPENCV_TRACE'] = '1'
             env['OPENCV_TRACE_LOCATION'] = 'OpenCVTrace-{}'.format(self.getLogBaseName(exe))
             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 not self.options.valgrind and self.options.trace and int(self.options.trace_dump) >= 0:
                 import trace_profiler
                 trace = trace_profiler.Trace(env['OPENCV_TRACE_LOCATION']+'.txt')
                 trace.process()
                 trace.dump(max_entries=int(self.options.trace_dump))
         except:
             import traceback
             traceback.print_exc()
             pass
         tempDir.clean()
         hostlogpath = os.path.join(workingDir, logfile)
         if os.path.isfile(hostlogpath):
             return hostlogpath, ret
         return None, ret
Beispiel #2
0
 def runTest(self, module, path, logfile, workingDir, args=[]):
     args = args[:]
     exe = os.path.abspath(path)
     if module == "java":
         cmd = [self.cache.ant_executable, "-Dopencv.build.type=%s" % self.cache.build_type, "buildAndTest"]
         ret = execute(cmd, cwd=self.cache.java_test_dir)
         return None, ret
     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):
                 executable = 'python'
         cmd = [executable, self.cache.opencv_home + '/modules/python/test/test.py', '--repo', self.cache.opencv_home, '-v'] + args
         module_suffix = '' if 'Visual Studio' not in self.cache.cmake_generator else '/' + self.cache.build_type
         env = {}
         env['PYTHONPATH'] = self.cache.opencv_build + '/lib' + module_suffix + os.pathsep + os.getenv('PYTHONPATH', '')
         if self.cache.getOS() == 'nt':
             env['PATH'] = self.cache.opencv_build + '/bin' + module_suffix + os.pathsep + os.getenv('PATH', '')
         else:
             env['LD_LIBRARY_PATH'] = self.cache.opencv_build + '/bin' + os.pathsep + os.getenv('LD_LIBRARY_PATH', '')
         ret = execute(cmd, cwd=workingDir, env=env)
         return None, ret
     else:
         if isColorEnabled(args):
             args.append("--gtest_color=yes")
         env = {}
         if not self.options.valgrind and self.options.trace:
             env['OPENCV_TRACE'] = '1'
             env['OPENCV_TRACE_LOCATION'] = 'OpenCVTrace-{}'.format(self.getLogBaseName(exe))
             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 not self.options.valgrind and self.options.trace and int(self.options.trace_dump) >= 0:
                 import trace_profiler
                 trace = trace_profiler.Trace(env['OPENCV_TRACE_LOCATION']+'.txt')
                 trace.process()
                 trace.dump(max_entries=int(self.options.trace_dump))
         except:
             import traceback
             traceback.print_exc()
             pass
         tempDir.clean()
         hostlogpath = os.path.join(workingDir, logfile)
         if os.path.isfile(hostlogpath):
             return hostlogpath, ret
         return None, ret
Beispiel #3
0
 def tryCommand(self, cmd, workingDir):
     try:
         if 0 == execute(cmd, cwd=workingDir):
             return True
     except:
         pass
     return False
Beispiel #4
0
 def tryCommand(self, cmd, workingDir):
     try:
         if 0 == execute(cmd, cwd=workingDir):
             return True
     except:
         pass
     return False
Beispiel #5
0
    android_env = []
    if args.android_env:
        android_env.extend([entry.split("=", 1) for entry in args.android_env])
    if args.android_propagate_opencv_env:
        android_env.extend([
            entry for entry in os.environ.items()
            if entry[0].startswith('OPENCV')
        ])
    android_env = dict(android_env)
    if args.android_test_data_path:
        android_env['OPENCV_TEST_DATA_PATH'] = args.android_test_data_path

    if args.valgrind:
        try:
            ver = execute(["valgrind", "--version"], silent=True)
            log.debug("Using %s", ver)
        except OSError as e:
            log.error("Failed to run valgrind: %s", e)
            exit(1)

    if len(args.build_path) != 1:
        test_args = [
            a for a in test_args if not a.startswith("--gtest_output=")
        ]

    if args.check:
        if not [a for a in test_args if a.startswith("--perf_min_samples=")]:
            test_args.extend(["--perf_min_samples=1"])
        if not [a for a in test_args if a.startswith("--perf_force_samples=")]:
            test_args.extend(["--perf_force_samples=1"])
Beispiel #6
0
        exit(1)

    args.mode = "test" if args.accuracy else "perf"

    android_env = []
    if args.android_env:
        android_env.extend([entry.split("=", 1) for entry in args.android_env])
    if args.android_propagate_opencv_env:
        android_env.extend([entry for entry in os.environ.items() if entry[0].startswith('OPENCV')])
    android_env = dict(android_env)
    if args.android_test_data_path:
        android_env['OPENCV_TEST_DATA_PATH'] = args.android_test_data_path

    if args.valgrind:
        try:
            ver = execute(["valgrind", "--version"], silent=True)
            log.debug("Using %s", ver)
        except OSError as e:
            log.error("Failed to run valgrind: %s", e)
            exit(1)

    if len(args.build_path) != 1:
        test_args = [a for a in test_args if not a.startswith("--gtest_output=")]

    if args.check:
        if not [a for a in test_args if a.startswith("--perf_min_samples=")]:
            test_args.extend(["--perf_min_samples=1"])
        if not [a for a in test_args if a.startswith("--perf_force_samples=")]:
            test_args.extend(["--perf_force_samples=1"])
        if not [a for a in test_args if a.startswith("--perf_verify_sanity")]:
            test_args.extend(["--perf_verify_sanity"])
Beispiel #7
0
 def run(self, args=[], silent=False):
     cmd = self.cmd[:]
     cmd.extend(args)
     return execute(self.cmd + args, silent)
Beispiel #8
0
 def run(self, args=[], silent=False):
     cmd = self.cmd[:]
     cmd.extend(args)
     return execute(self.cmd + args, silent)