Esempio n. 1
0
    def SetUp(self):
        """Sets up the test harness and device before all tests are run."""
        super(TestRunner, self).SetUp()
        if not self.adb.IsRootEnabled():
            logging.warning(
                'Unable to enable java asserts for %s, non rooted device',
                self.device)
        else:
            if self.adb.SetJavaAssertsEnabled(
                    enable=not self.disable_assertions):
                self.adb.Reboot(full_reboot=False)

        # We give different default value to launch HTTP server based on shard index
        # because it may have race condition when multiple processes are trying to
        # launch lighttpd with same port at same time.
        http_server_ports = self.LaunchTestHttpServer(
            os.path.join(constants.CHROME_DIR), self._lighttp_port)
        if self.ports_to_forward:
            port_pairs = [(port, port) for port in self.ports_to_forward]
            # We need to remember which ports the HTTP server is using, since the
            # forwarder will stomp on them otherwise.
            port_pairs.append(http_server_ports)
            self.forwarder = forwarder.Forwarder(self.adb, self.build_type)
            self.forwarder.Run(port_pairs, self.tool, '127.0.0.1')
        self.flags.AddFlags(['--enable-test-intents'])
Esempio n. 2
0
 def GlobalSetUp(self):
     os.putenv('TEST_HTTP_PORT', str(ANDROID_TEST_HTTP_PORT))
     os.putenv('TEST_HTTPS_PORT', str(ANDROID_TEST_HTTPS_PORT))
     self._adb = android_commands.AndroidCommands()
     self._forwarder = forwarder.Forwarder(self._adb, 'Debug')
     self._forwarder.Run(
         [(ANDROID_TEST_HTTP_PORT, ANDROID_TEST_HTTP_PORT),
          (ANDROID_TEST_HTTPS_PORT, ANDROID_TEST_HTTPS_PORT)],
         valgrind_tools.BaseTool(), '127.0.0.1')
Esempio n. 3
0
 def GlobalSetUp():
   ChromeDriverTest._http_server = webserver.WebServer(
       chrome_paths.GetTestData())
   if _ANDROID_PACKAGE:
     ChromeDriverTest._adb = android_commands.AndroidCommands()
     ChromeDriverTest._forwarder = forwarder.Forwarder(ChromeDriverTest._adb,
                                                       'Debug')
     host_port = ChromeDriverTest._http_server._server.server_port
     ChromeDriverTest._forwarder.Run(
         [(host_port, host_port)], valgrind_tools.BaseTool(), '127.0.0.1')
Esempio n. 4
0
  def __init__(self, adb, *ports):
    assert HasForwarder(adb)

    port_pairs = [(port, port) for port in ports]
    tool = valgrind_tools.BaseTool()

    self._host_port = ports[0]
    buildtype = 'Debug'
    if HasForwarder(adb, 'Release'):
      buildtype = 'Release'
    self._forwarder = forwarder.Forwarder(
        adb.Adb(), port_pairs,
        tool, '127.0.0.1', buildtype)
Esempio n. 5
0
  def __init__(self, adb, *port_pairs):
    assert HasForwarder()
    tool = valgrind_tools.BaseTool()
    self._host_port = port_pairs[0].local_port

    new_port_pairs = [(port_pair.local_port, port_pair.remote_port)
                      for port_pair in port_pairs]

    buildtype = 'Debug'
    if HasForwarder('Release'):
      buildtype = 'Release'
    self._forwarder = forwarder.Forwarder(adb.Adb(), buildtype)
    self._forwarder.Run(new_port_pairs, tool, '127.0.0.1')
def main(argv):
    parser = optparse.OptionParser(usage='Usage: %prog [options] device_port '
                                   'host_port [device_port_2 host_port_2] ...',
                                   description=__doc__)
    parser.add_option('-v',
                      '--verbose',
                      dest='verbose_count',
                      default=0,
                      action='count',
                      help='Verbose level (multiple times for more)')
    parser.add_option('--device',
                      help='Serial number of device we should use.')
    parser.add_option('--host',
                      help='Host address to forward to from the host machine. '
                      '127.0.0.1 by default',
                      default='127.0.0.1')
    parser.add_option('--debug',
                      action='store_const',
                      const='Debug',
                      dest='build_type',
                      default='Release',
                      help='Use Debug build of host tools instead of Release.')

    options, args = parser.parse_args(argv)
    run_tests_helper.SetLogLevel(options.verbose_count)

    if len(args) < 2 or not len(args) % 2:
        parser.error('Need even number of port pairs')
        sys.exit(1)

    try:
        port_pairs = map(int, args[1:])
        port_pairs = zip(port_pairs[::2], port_pairs[1::2])
    except ValueError:
        parser.error('Bad port number')
        sys.exit(1)

    adb = android_commands.AndroidCommands(options.device)
    tool = CreateTool(None, adb)
    forwarder_instance = forwarder.Forwarder(adb, options.build_type)
    try:
        forwarder_instance.Run(port_pairs, tool, options.host)
        while True:
            time.sleep(60)
    except KeyboardInterrupt:
        sys.exit(0)
    finally:
        forwarder_instance.Close()
    def __init__(self, adb, host_port):
        assert HasForwarder(adb)

        port_pairs = [
            (host_port, host_port),
        ]
        tool = valgrind_tools.BaseTool()

        self._host_port = host_port
        buildtype = 'Debug'
        if HasForwarder(adb, 'Release'):
            buildtype = 'Release'
        self._forwarder = forwarder.Forwarder(adb.Adb(), port_pairs, tool,
                                              '127.0.0.1', buildtype)
        self._device_port = self._forwarder.DevicePortForHostPort(
            self._host_port)
Esempio n. 8
0
    def __init__(self, adb, *port_pairs):
        assert HasForwarder()
        tool = valgrind_tools.BaseTool()
        self._host_port = port_pairs[0][0]

        new_port_pairs = []
        for port_pair in port_pairs:
            if port_pair[1] is None:
                new_port_pairs.append((port_pair[0], port_pair[0]))
            else:
                new_port_pairs.append(port_pair)

        buildtype = 'Debug'
        if HasForwarder('Release'):
            buildtype = 'Release'
        self._forwarder = forwarder.Forwarder(adb.Adb(), buildtype)
        self._forwarder.Run(new_port_pairs, tool, '127.0.0.1')