Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 3
0
    def runTest(self, path, logfile, workingDir, args=[]):
        args = args[:]
        exe = os.path.abspath(path)

        if exe.endswith(".apk"):
            info = self.aapt.dump(exe)
            if not info:
                raise Err("Can not read info from test package: %s", exe)
            info.forcePackage(self.options.package)
            self.adb.run(["uninstall", info.pkg_name])

            output = self.adb.run(["install", exe], silent=True)
            if not (output and "Success" in output):
                raise Err("Can not install package: %s", exe)

            params = ["-e package %s" % info.pkg_target]
            ret = self.adb.run([
                "shell",
                "am instrument -w %s %s/%s" %
                (" ".join(params), info.pkg_name, info.pkg_runner)
            ])
            return None, ret
        else:
            device_dir = getpass.getuser().replace(
                " ", "") + "_" + self.options.mode + "/"
            if isColorEnabled(args):
                args.append("--gtest_color=yes")
            tempdir = "/data/local/tmp/"
            android_dir = tempdir + device_dir
            exename = os.path.basename(exe)
            android_exe = android_dir + exename
            self.adb.run(["push", exe, android_exe])
            self.adb.run(["shell", "chmod 777 " + android_exe])
            env_pieces = ["export %s=%s" % (a, b) for a, b in self.env.items()]
            pieces = [
                "cd %s" % android_dir,
                "./%s %s" % (exename, " ".join(args))
            ]
            log.warning("Run: %s" % " && ".join(pieces))
            ret = self.adb.run(["shell", " && ".join(env_pieces + pieces)])
            # try get log
            hostlogpath = os.path.join(workingDir, logfile)
            self.adb.run(["pull", android_dir + logfile, hostlogpath])
            # cleanup
            self.adb.run(["shell", "rm " + android_dir + logfile])
            self.adb.run(["shell", "rm " + tempdir + "__opencv_temp.*"],
                         silent=True)
            if os.path.isfile(hostlogpath):
                return hostlogpath, ret
            return None, ret
Ejemplo n.º 4
0
    def runTest(self, path, logfile, workingDir, args=[]):
        args = args[:]
        exe = os.path.abspath(path)

        if exe.endswith(".apk"):
            info = self.aapt.dump(exe)
            if not info:
                raise Err("Can not read info from test package: %s", exe)
            info.forcePackage(self.options.package)
            self.adb.run(["uninstall", info.pkg_name])

            output = self.adb.run(["install", exe], silent=True)
            if not (output and "Success" in output):
                raise Err("Can not install package: %s", exe)

            params = ["-e package %s" % info.pkg_target]
            ret = self.adb.run(["shell", "am instrument -w %s %s/%s" % (" ".join(params), info.pkg_name, info.pkg_runner)])
            return None, ret
        else:
            device_dir = getpass.getuser().replace(" ", "") + "_" + self.options.mode + "/"
            if isColorEnabled(args):
                args.append("--gtest_color=yes")
            tempdir = "/data/local/tmp/"
            android_dir = tempdir + device_dir
            exename = os.path.basename(exe)
            android_exe = android_dir + exename
            self.adb.run(["push", exe, android_exe])
            self.adb.run(["shell", "chmod 777 " + android_exe])
            env_pieces = ["export %s=%s" % (a, b) for a, b in self.env.items()]
            pieces = ["cd %s" % android_dir, "./%s %s" % (exename, " ".join(args))]
            log.warning("Run: %s" % " && ".join(pieces))
            ret = self.adb.run(["shell", " && ".join(env_pieces + pieces)])
            # try get log
            hostlogpath = os.path.join(workingDir, logfile)
            self.adb.run(["pull", android_dir + logfile, hostlogpath])
            # cleanup
            self.adb.run(["shell", "rm " + android_dir + logfile])
            self.adb.run(["shell", "rm " + tempdir + "__opencv_temp.*"], silent=True)
            if os.path.isfile(hostlogpath):
                return hostlogpath, ret
            return None, ret
Ejemplo n.º 5
0
            else:
                log.debug("Creating native test runner")
                suite = TestSuite(args, cache)

            if args.list or args.list_short or args.list_short_main:
                suite.listTests(args.list_short or args.list_short_main,
                                args.list_short_main)
            else:
                log.debug("Running tests in '%s', working dir: '%s'", path,
                          args.cwd)

                def parseTests(s):
                    return [o.strip() for o in s.split(",") if o]

                l, r = suite.runTests(parseTests(args.tests),
                                      parseTests(args.blacklist), args.cwd,
                                      test_args)
                logs.extend(l)
                if r != 0:
                    ret = r
        except Err as e:
            log.error("ERROR: test path '%s' ==> %s", path, e.msg)
            ret = -1

    if logs:
        log.warning("Collected: %s", ", ".join(logs))

    if ret != 0:
        log.error("ERROR: some tests have failed")
    exit(ret)
Ejemplo n.º 6
0
        if args.android or cache.getOS() == "android":
            log.debug("Creating Android test runner")
            suite = AndroidTestSuite(args, cache, stamp, android_env)
        else:
            log.debug("Creating native test runner")
            suite = TestSuite(args, cache, stamp)

        if args.list or args.list_short or args.list_short_main:
            suite.listTests(args.list_short or args.list_short_main,
                            args.list_short_main)
        else:
            log.debug("Running tests in '%s', working dir: '%s'", path,
                      args.cwd)

            def parseTests(s):
                return [o.strip() for o in s.split(",") if o]

            logs, ret = suite.runTests(parseTests(args.tests),
                                       parseTests(args.blacklist), args.cwd,
                                       test_args)
    except Err as e:
        log.error("ERROR: test path '%s' ==> %s", path, e.msg)
        ret = -1

    if logs:
        log.warning("Collected: %s", logs)

    if ret != 0:
        log.error("ERROR: some tests have failed")
    exit(ret)
Ejemplo n.º 7
0
            cache.read(path, fname)
        else:
            log.debug("Assuming folder contains tests: %s", path)
            cache.setDummy(path)

        if args.android or cache.getOS() == "android":
            log.debug("Creating Android test runner")
            suite = AndroidTestSuite(args, cache, stamp, android_env)
        else:
            log.debug("Creating native test runner")
            suite = TestSuite(args, cache, stamp)

        if args.list or args.list_short or args.list_short_main:
            suite.listTests(args.list_short or args.list_short_main, args.list_short_main)
        else:
            log.debug("Running tests in '%s', working dir: '%s'", path, args.cwd)

            def parseTests(s):
                return [o.strip() for o in s.split(",") if o]
            logs, ret = suite.runTests(parseTests(args.tests), parseTests(args.blacklist), args.cwd, test_args)
    except Err as e:
        log.error("ERROR: test path '%s' ==> %s", path, e.msg)
        ret = -1

    if logs:
        log.warning("Collected: %s", logs)

    if ret != 0:
        log.error("ERROR: some tests have failed")
    exit(ret)
Ejemplo n.º 8
0
                log.debug("Assuming folder contains tests: %s", path)
                cache.setDummy(path)

            if args.android or cache.getOS() == "android":
                log.debug("Creating Android test runner")
                suite = AndroidTestSuite(args, cache, android_env)
            else:
                log.debug("Creating native test runner")
                suite = TestSuite(args, cache)

            if args.list or args.list_short or args.list_short_main:
                suite.listTests(args.list_short or args.list_short_main, args.list_short_main)
            else:
                log.debug("Running tests in '%s', working dir: '%s'", path, args.cwd)
                def parseTests(s):
                    return [o.strip() for o in s.split(",") if o]
                l, r = suite.runTests(parseTests(args.tests), parseTests(args.blacklist), args.cwd, test_args)
                logs.extend(l)
                if r != 0:
                    ret = r
        except Err as e:
            log.error("ERROR: test path '%s' ==> %s", path, e.msg)
            ret = -1

    if logs:
        log.warning("Collected: %s", ", ".join(logs))

    if ret != 0:
        log.error("ERROR: some tests have failed")
    exit(ret)