示例#1
0
 def testAndroid(self):
     self._WriteTestInput(V8_JSON)
     mock.patch('run_perf.AndroidPlatform.PreExecution').start()
     mock.patch('run_perf.AndroidPlatform.PostExecution').start()
     mock.patch('run_perf.AndroidPlatform.PreTests').start()
     mock.patch('run_perf.AndroidPlatform.Run',
                return_value=(Output(
                    stdout='Richards: 1.234\nDeltaBlue: 10657567\n'),
                              NULL_OUTPUT)).start()
     mock.patch('testrunner.local.android._Driver', autospec=True).start()
     mock.patch('run_perf.Platform.ReadBuildConfig',
                return_value={
                    'is_android': True
                }).start()
     self.assertEquals(0, self._CallMain('--arch', 'arm'))
     self._VerifyResults('test', 'score', [
         {
             'name': 'Richards',
             'results': ['1.234'],
             'stddev': ''
         },
         {
             'name': 'DeltaBlue',
             'results': ['10657567.0'],
             'stddev': ''
         },
     ])
示例#2
0
    def _MockCommand(self, *args, **kwargs):
        # Fake output for each test run.
        test_outputs = [
            Output(stdout=arg,
                   timed_out=kwargs.get('timed_out', False),
                   exit_code=kwargs.get('exit_code', 0)) for arg in args[1]
        ]

        def create_cmd(*args, **kwargs):
            cmd = mock.MagicMock()

            def execute(*args, **kwargs):
                return test_outputs.pop()

            cmd.execute = mock.MagicMock(side_effect=execute)
            return cmd

        mock.patch.object(run_perf.command, 'PosixCommand',
                          mock.MagicMock(side_effect=create_cmd)).start()

        # Check that d8 is called from the correct cwd for each test run.
        dirs = [os.path.join(TEST_WORKSPACE, arg) for arg in args[0]]

        def chdir(*args, **kwargs):
            self.assertEquals(dirs.pop(), args[0])

        os.chdir = mock.MagicMock(side_effect=chdir)

        subprocess.check_call = mock.MagicMock()
        platform.system = mock.MagicMock(return_value='Linux')
示例#3
0
    def _Run(self, runnable, count, secondary=False):
        target_dir = 'bin_secondary' if secondary else 'bin'
        self.driver.drop_ram_caches()

        # Relative path to benchmark directory.
        if runnable.path:
            bench_rel = os.path.normpath(os.path.join(*runnable.path))
        else:
            bench_rel = '.'

        logcat_file = None
        if self.args.dump_logcats_to:
            runnable_name = '-'.join(runnable.graphs)
            logcat_file = os.path.join(
                self.args.dump_logcats_to, 'logcat-%s-#%d%s.log' %
                (runnable_name, count + 1, '-secondary' if secondary else ''))
            logging.debug('Dumping logcat into %s', logcat_file)

        output = Output()
        start = time.time()
        try:
            output.stdout = self.driver.run(
                target_dir=target_dir,
                binary=runnable.binary,
                args=runnable.GetCommandFlags(self.extra_flags),
                rel_path=bench_rel,
                timeout=runnable.timeout,
                logcat_file=logcat_file,
            )
        except android.CommandFailedException as e:
            output.stdout = e.output
            output.exit_code = e.status
        except android.TimeoutException as e:
            output.stdout = e.output
            output.timed_out = True
        if runnable.process_size:
            output.stdout += 'MaxMemory: Unsupported'
        output.duration = time.time() - start
        return output
示例#4
0
    def _MockCommand(self, *args, **kwargs):
        on_bots = kwargs.pop('on_bots', False)
        # Fake output for each test run.
        test_outputs = [
            Output(stdout=arg,
                   timed_out=kwargs.get('timed_out', False),
                   exit_code=kwargs.get('exit_code', 0),
                   duration=42) for arg in args[1]
        ]

        def create_cmd(*args, **kwargs):
            cmd = mock.MagicMock()

            def execute(*args, **kwargs):
                return test_outputs.pop()

            cmd.execute = mock.MagicMock(side_effect=execute)
            return cmd

        mock.patch.object(run_perf.command, 'PosixCommand',
                          mock.MagicMock(side_effect=create_cmd)).start()

        build_dir = 'Release' if on_bots else 'x64.release'
        out_dirs = ['out', 'out-secondary']
        return_values = [
            os.path.join(os.path.dirname(BASE_DIR), out, build_dir)
            for out in out_dirs
        ]
        mock.patch.object(run_perf, 'find_build_directory',
                          mock.MagicMock(side_effect=return_values)).start()

        # Check that d8 is called from the correct cwd for each test run.
        dirs = [os.path.join(TEST_WORKSPACE, arg) for arg in args[0]]

        def chdir(*args, **kwargs):
            self.assertEqual(dirs.pop(), args[0])

        os.chdir = mock.MagicMock(side_effect=chdir)

        subprocess.check_call = mock.MagicMock()
        platform.system = mock.MagicMock(return_value='Linux')
示例#5
0
文件: run_perf.py 项目: v8/v8
  def _Run(self, runnable, count, secondary=False):
    target_dir = 'bin_secondary' if secondary else 'bin'
    self.driver.drop_ram_caches()

    # Relative path to benchmark directory.
    if runnable.path:
      bench_rel = os.path.normpath(os.path.join(*runnable.path))
    else:
      bench_rel = '.'

    logcat_file = None
    if self.args.dump_logcats_to:
      runnable_name = '-'.join(runnable.graphs)
      logcat_file = os.path.join(
          self.args.dump_logcats_to, 'logcat-%s-#%d%s.log' % (
            runnable_name, count + 1, '-secondary' if secondary else ''))
      logging.debug('Dumping logcat into %s', logcat_file)

    output = Output()
    start = time.time()
    try:
      output.stdout = self.driver.run(
          target_dir=target_dir,
          binary=runnable.binary,
          args=runnable.GetCommandFlags(self.extra_flags),
          rel_path=bench_rel,
          timeout=runnable.timeout,
          logcat_file=logcat_file,
      )
    except android.CommandFailedException as e:
      output.stdout = e.output
      output.exit_code = e.status
    except android.TimeoutException as e:
      output.stdout = e.output
      output.timed_out = True
    if runnable.process_size:
      output.stdout += 'MaxMemory: Unsupported'
    output.duration = time.time() - start
    return output