Example #1
0
    def ListTests(self, context):
        shell = os.path.abspath(os.path.join(context.shell_dir, self.name))
        if utils.IsWindows():
            shell += ".exe"

        output = None
        for i in xrange(3):  # Try 3 times in case of errors.
            cmd = command.Command(cmd_prefix=context.command_prefix,
                                  shell=shell,
                                  args=['--gtest_list_tests'] +
                                  context.extra_flags)
            output = cmd.execute()
            if output.exit_code == 0:
                break
            print "Test executable failed to list the tests (try %d).\n\nCmd:" % i
            print cmd
            print "\nStdout:"
            print output.stdout
            print "\nStderr:"
            print output.stderr
            print "\nExit code: %d" % output.exit_code
        else:
            raise Exception("Test executable failed to list the tests.")

        tests = []
        test_case = ''
        for line in output.stdout.splitlines():
            test_desc = line.strip().split()[0]
            if test_desc.endswith('.'):
                test_case = test_desc
            elif test_case and test_desc:
                test_path = test_case + test_desc
                tests.append(self._create_test(test_path))
        tests.sort(key=lambda t: t.path)
        return tests
Example #2
0
 def _create_cmd(self, shell, params, env, timeout):
   return command.Command(
     cmd_prefix=self._test_config.command_prefix,
     shell=os.path.abspath(os.path.join(self._test_config.shell_dir, shell)),
     args=params,
     env=env,
     timeout=timeout,
     verbose=self._test_config.verbose,
     resources_func=self._get_resources,
     handle_sigterm=True,
   )
Example #3
0
 def ListTests(self, context):
     shell = os.path.abspath(os.path.join(context.shell_dir, SHELL))
     if utils.IsWindows():
         shell += ".exe"
     cmd = command.Command(cmd_prefix=context.command_prefix,
                           shell=shell,
                           args=["--list"] + context.extra_flags)
     output = cmd.execute()
     if output.exit_code != 0:
         print cmd
         print output.stdout
         print output.stderr
         return []
     tests = map(self._create_test, output.stdout.strip().split())
     tests.sort(key=lambda t: t.path)
     return tests
Example #4
0
  def GetCommand(self, cmd_prefix, shell_dir, extra_flags=None):
    # TODO(machenbach): This requires +.exe if run on windows.
    extra_flags = extra_flags or []
    if self.binary != 'd8' and '--prof' in extra_flags:
      logging.info("Profiler supported only on a benchmark run with d8")

    if self.process_size:
      cmd_prefix = ["/usr/bin/time", "--format=MaxMemory: %MKB"] + cmd_prefix
    if self.binary.endswith('.py'):
      # Copy cmd_prefix instead of update (+=).
      cmd_prefix = cmd_prefix + [sys.executable]

    return command.Command(
        cmd_prefix=cmd_prefix,
        shell=os.path.join(shell_dir, self.binary),
        args=self.GetCommandFlags(extra_flags=extra_flags),
        timeout=self.timeout or 60)
Example #5
0
    def _list_test_filenames(self):
        shell = os.path.abspath(os.path.join(self.test_config.shell_dir,
                                             SHELL))
        if utils.IsWindows():
            shell += ".exe"
        cmd = command.Command(cmd_prefix=self.test_config.command_prefix,
                              shell=shell,
                              args=["--list"] + self.test_config.extra_flags)
        output = cmd.execute()
        # TODO make errors visible (see duplicated code in 'unittests')
        if output.exit_code != 0:
            print(cmd)
            print(output.stdout)
            print(output.stderr)
            return []

        return sorted(output.stdout.strip().split())
def main(args):
    def allocation_str(stdout):
        for line in reversed((stdout or '').splitlines()):
            if maybe_decode(line).startswith('### Allocations = '):
                return line
        return None

    cmd = command.Command(args[0],
                          args[1:],
                          timeout=TIMEOUT,
                          handle_sigterm=True)

    previous_allocations = None
    for run in range(1, MAX_TRIES + 1):
        print('### Predictable run #%d' % run)
        output = cmd.execute()
        if output.stdout:
            print('### Stdout:')
            print(output.stdout)
        if output.stderr:
            print('### Stderr:')
            print(output.stderr)
        print('### Return code: %s' % output.exit_code)
        if output.HasTimedOut():
            # If we get a timeout in any run, we are in an unpredictable state. Just
            # report it as a failure and don't rerun.
            print('### Test timed out')
            return 1
        allocations = allocation_str(output.stdout)
        if not allocations:
            print('### Test had no allocation output. Ensure this is built '
                  'with v8_enable_verify_predictable and that '
                  '--verify-predictable is passed at the cmd line.')
            return 2
        if previous_allocations and previous_allocations != allocations:
            print('### Allocations differ')
            return 3
        if run >= MAX_TRIES:
            # No difference on the last run -> report a success.
            return 0
        previous_allocations = allocations
    # Unreachable.
    assert False
Example #7
0
 def ListTests(self, context):
     shell = os.path.abspath(os.path.join(context.shell_dir, self.SHELL))
     if utils.IsWindows():
         shell += ".exe"
     cmd = command.Command(cmd_prefix=context.command_prefix,
                           shell=shell,
                           args=["--list"] + context.extra_flags)
     output = cmd.execute()
     if output.exit_code != 0:
         print cmd
         print output.stdout
         print output.stderr
         return []
     tests = []
     for test_desc in output.stdout.strip().split():
         test = testcase.TestCase(self, test_desc)
         tests.append(test)
     tests.sort(key=lambda t: t.path)
     return tests
Example #8
0
  def _list_test_filenames(self):
    shell = os.path.abspath(
      os.path.join(self.test_config.shell_dir, SHELL))
    if utils.IsWindows():
      shell += ".exe"
    cmd = command.Command(
      cmd_prefix=self.test_config.command_prefix,
      shell=shell,
      args=['--list'] + self.test_config.extra_flags)
    output = cmd.execute()

    if output.exit_code != 0:
      print("Test executable failed to list the tests.\n\nCmd:")
      print(cmd)
      print("\nStdout:")
      print(output.stdout)
      print("\nStderr:")
      print(output.stderr)
      print("\nExit code: %d" % output.exit_code)

    return sorted(output.stdout.strip().split())
Example #9
0
    def _list_test_filenames(self):
        shell = os.path.abspath(
            os.path.join(self.test_config.shell_dir, "wasm_api_tests"))
        if utils.IsWindows():
            shell += ".exe"

        output = None
        for i in range(3):  # Try 3 times in case of errors.
            cmd = command.Command(cmd_prefix=self.test_config.command_prefix,
                                  shell=shell,
                                  args=['--gtest_list_tests'] +
                                  self.test_config.extra_flags)
            output = cmd.execute()
            if output.exit_code == 0:
                break

            print(
                "Test executable failed to list the tests (try %d).\n\nCmd:" %
                i)
            print(cmd)
            print("\nStdout:")
            print(output.stdout)
            print("\nStderr:")
            print(output.stderr)
            print("\nExit code: %d" % output.exit_code)
        else:
            raise Exception("Test executable failed to list the tests.")

        # TODO create an ExecutableTestLoader for refactoring this similar to
        # JSTestLoader.
        test_names = []
        test_case = ''
        for line in output.stdout.splitlines():
            test_desc = line.strip().split()[0]
            if test_desc.endswith('.'):
                test_case = test_desc
            elif test_case and test_desc:
                test_names.append(test_case + test_desc)

        return sorted(test_names)