示例#1
0
 def testParseGTestListTests_typeParameterized_old(self):
   raw_output = [
     'TPTestCase/WithTypeParam/0.',
     '  testOne',
     '  testTwo',
   ]
   actual = gtest_test_instance.ParseGTestListTests(raw_output)
   expected = [
     'TPTestCase/WithTypeParam/0.testOne',
     'TPTestCase/WithTypeParam/0.testTwo',
   ]
   self.assertEqual(expected, actual)
 def list_tests(dev):
     raw_test_list = self._delegate.Run(None,
                                        dev,
                                        flags='--gtest_list_tests',
                                        timeout=30)
     tests = gtest_test_instance.ParseGTestListTests(raw_test_list)
     if not tests:
         logging.info('No tests found. Output:')
         for l in raw_test_list:
             logging.info('  %s', l)
     tests = self._test_instance.FilterTests(tests)
     return tests
 def testParseGTestListTests_valueParameterized_new(self):
     raw_output = [
         'VPTestCase.',
         '  testWithValueParam/0  # GetParam() = 0',
         '  testWithValueParam/1  # GetParam() = 1',
     ]
     actual = gtest_test_instance.ParseGTestListTests(raw_output)
     expected = [
         'VPTestCase.testWithValueParam/0',
         'VPTestCase.testWithValueParam/1',
     ]
     self.assertEqual(expected, actual)
 def list_tests(dev):
     timeout = 30
     if self._test_instance.wait_for_java_debugger:
         timeout = None
     raw_test_list = crash_handler.RetryOnSystemCrash(
         lambda d: self._delegate.Run(
             None, d, flags='--gtest_list_tests', timeout=timeout),
         device=dev)
     tests = gtest_test_instance.ParseGTestListTests(raw_test_list)
     if not tests:
         logging.info('No tests found. Output:')
         for l in raw_test_list:
             logging.info('  %s', l)
     return tests
示例#5
0
    def GetAllTests(self, device):
        lib_path = posixpath.join(constants.TEST_EXECUTABLE_DIR,
                                  '%s_deps' % self.suite_name)

        cmd = []
        if self.tool.GetTestWrapper():
            cmd.append(self.tool.GetTestWrapper())
        cmd.extend([
            posixpath.join(constants.TEST_EXECUTABLE_DIR, self.suite_name),
            '--gtest_list_tests'
        ])

        output = device.RunShellCommand(cmd,
                                        check_return=True,
                                        env={'LD_LIBRARY_PATH': lib_path})
        return gtest_test_instance.ParseGTestListTests(output)
 def GetAllTests(self, device):
   self._CreateCommandLineFileOnDevice(device, '--gtest_list_tests')
   try:
     self.tool.SetupEnvironment()
     # Clear and start monitoring logcat.
     self._ClearFifo(device)
     self._StartActivity(device)
     # Wait for native test to complete.
     p = self._WatchFifo(device, timeout=30 * self.tool.GetTimeoutScale())
     p.expect('<<ScopedMainEntryLogger')
     p.close()
   finally:
     self.tool.CleanUpEnvironment()
   # We need to strip the trailing newline.
   content = [line.rstrip() for line in p.before.splitlines()]
   return gtest_test_instance.ParseGTestListTests(content)
 def testParseGTestListTests_simple(self):
     raw_output = [
         'TestCaseOne.',
         '  testOne',
         '  testTwo',
         'TestCaseTwo.',
         '  testThree',
         '  testFour',
     ]
     actual = gtest_test_instance.ParseGTestListTests(raw_output)
     expected = [
         'TestCaseOne.testOne',
         'TestCaseOne.testTwo',
         'TestCaseTwo.testThree',
         'TestCaseTwo.testFour',
     ]
     self.assertEqual(expected, actual)
示例#8
0
    def list_tests(dev):
      timeout = 30
      retries = 1
      if self._test_instance.wait_for_java_debugger:
        timeout = None

      flags = [
          f for f in self._test_instance.flags
          if f not in ['--wait-for-debugger', '--wait-for-java-debugger']
      ]
      flags.append('--gtest_list_tests')

      # TODO(crbug.com/726880): Remove retries when no longer necessary.
      for i in range(0, retries+1):
        logging.info('flags:')
        for f in flags:
          logging.info('  %s', f)

        try:
          raw_test_list = crash_handler.RetryOnSystemCrash(
              lambda d: self._delegate.Run(
                  None, d, flags=' '.join(flags), timeout=timeout),
              device=dev)
        except device_errors.AdbCommandFailedError:
          logging.exception('Test listing failed.')
          # Allow subsequent error handling to dump logcat.
          raw_test_list = []

        tests = gtest_test_instance.ParseGTestListTests(raw_test_list)
        if not tests:
          logging.info('No tests found. Output:')
          for l in raw_test_list:
            logging.info('  %s', l)
          logging.info('Logcat:')
          for line in dev.adb.Logcat(dump=True):
            logging.info(line)
          dev.adb.Logcat(clear=True)
          if i < retries:
            logging.info('Retrying...')
        else:
          break
      return tests
示例#9
0
 def _GetTests(self):
     tests = self._delegate.RunWithFlags(self._env.devices[0],
                                         '--gtest_list_tests')
     tests = gtest_test_instance.ParseGTestListTests(tests)
     tests = self._test_instance.FilterTests(tests)
     return tests
示例#10
0
 def list_tests(dev):
   tests = self._delegate.Run(
       None, dev, flags='--gtest_list_tests', timeout=20)
   tests = gtest_test_instance.ParseGTestListTests(tests)
   tests = self._test_instance.FilterTests(tests)
   return tests