Пример #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
Пример #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