Esempio n. 1
0
 def make_port(self, executive=None, with_tests=False, port_name=None, **kwargs):
     host = MockSystemHost()
     if executive:
         host.executive = executive
     if with_tests:
         add_unit_tests_to_mock_filesystem(host.filesystem)
         return TestPort(host, **kwargs)
     return Port(host, port_name or 'baseport', **kwargs)
Esempio n. 2
0
 def make_driver(self, worker_number=0, xorg_running=False, executive=None):
     port = Port(MockSystemHost(log_executive=True, executive=executive), 'waylanddrivertestport', options=MockOptions(configuration='Release'))
     port._config.build_directory = lambda configuration: '/mock-build'
     port._server_process_constructor = MockServerProcess
     driver = WaylandDriver(port, worker_number=worker_number, pixel_tests=True)
     driver._startup_delay_secs = 0
     driver._environment = port.setup_environ_for_server(port.driver_name())
     return driver
Esempio n. 3
0
    def make_driver(self, filesystem=None):
        port = Port(MockSystemHost(log_executive=True, filesystem=filesystem),
                    'westondrivertestport',
                    options=MockOptions(configuration='Release'))
        port._config.build_directory = lambda configuration: "/mock_build"
        port._server_process_constructor = MockServerProcess

        driver = WestonDriver(port, worker_number=0, pixel_tests=True)
        driver._startup_delay_secs = 0
        return driver
    def make_driver(self, worker_number=0, xorg_running=False, executive=None):
        port = Port(MockSystemHost(log_executive=True, executive=executive), 'xvfbdrivertestport', options=MockOptions(configuration='Release'))
        port._config.build_directory = lambda configuration: "/mock-build"
        port._server_process_constructor = MockServerProcess
        if xorg_running:
            port._executive._running_pids['Xorg'] = 108

        driver = XvfbDriver(port, worker_number=worker_number, pixel_tests=True)
        driver._startup_delay_secs = 0
        driver._xvfb_screen_depth = lambda: '24'
        return driver
Esempio n. 5
0
    def test_previously_spawned_instance(self):
        host = MockHost()
        port = Port(host, "test")
        server = WebPlatformTestServer(port, "wpttest", "/mock/output_dir",
                                       "/mock/output_dir/pid.txt")
        server._check_that_all_ports_are_available = lambda: True
        server._is_server_running_on_all_ports = lambda: True

        host.filesystem.write_text_file("/mock_output_dir/pid.txt", "0")
        server.start()
        server.stop()
Esempio n. 6
0
    def make_driver(self):
        port = Port(MockSystemHost(log_executive=True),
                    'westondrivertestport',
                    options=MockOptions(configuration='Release'))
        port._config.build_directory = lambda configuration: "/mock_build"
        port._test_runner_process_constructor = MockServerProcess

        driver = WestonDriver(port, worker_number=0, pixel_tests=True)
        driver._startup_delay_secs = 0
        driver._expected_xvfbdisplay = 23
        driver._xvfbdriver = WestonXvfbDriverDisplayTest(
            driver._expected_xvfbdisplay)
        driver._environment = port.setup_environ_for_server(port.driver_name())
        return driver
Esempio n. 7
0
    def test_stop(self):
        port = Port(MockSystemHost(log_executive=True), 'xvfbdrivertestport', options=MockOptions(configuration='Release'))
        port._executive.kill_process = lambda x: _log.info("MOCK kill_process pid: " + str(x))
        driver = XvfbDriver(port, worker_number=0, pixel_tests=True)

        class FakeXvfbProcess(object):
            pid = 1234

        driver._xvfb_process = FakeXvfbProcess()

        expected_logs = "MOCK kill_process pid: 1234\n"
        OutputCapture().assert_outputs(self, driver.stop, [], expected_logs=expected_logs)

        self.assertIsNone(driver._xvfb_process)
Esempio n. 8
0
    def test_stop(self):
        port = Port(MockSystemHost(log_executive=True), 'xvfbdrivertestport', options=MockOptions(configuration='Release'))
        port._executive.kill_process = lambda x: _log.info("MOCK kill_process pid: " + str(x))
        driver = XvfbDriver(port, worker_number=0, pixel_tests=True)

        class FakeXvfbProcess(object):
            pid = 1234

        driver._xvfb_process = FakeXvfbProcess()

        with OutputCapture(level=logging.INFO) as captured:
            driver.stop()
        self.assertEqual(captured.root.log.getvalue(), "MOCK kill_process pid: 1234\n")

        self.assertIsNone(driver._xvfb_process)
Esempio n. 9
0
    def make_driver(self, worker_number=0, xorg_running=False, executive=None):
        port = Port(MockSystemHost(log_executive=True, executive=executive), 'xvfbdrivertestport', options=MockOptions(configuration='Release'))
        port._config.build_directory = lambda configuration: "/mock-build"
        port._test_runner_process_constructor = MockServerProcess
        if xorg_running:
            port._executive._running_pids['Xorg'] = 108

        driver = XvfbDriver(port, worker_number=worker_number, pixel_tests=True)
        driver._startup_delay_secs = 0
        driver._xvfb_screen_depth = lambda: '24'
        driver._xvfb_pipe = lambda: (3, 4)
        driver._xvfb_read_display_id = lambda x: 1
        driver._xvfb_close_pipe = lambda p: None
        driver._port_server_environment = port.setup_environ_for_server(port.driver_name())
        return driver
Esempio n. 10
0
    def test_stop(self):
        filesystem = MockFileSystem(files={'/tmp/.X42-lock': '1234\n'})
        port = Port(MockSystemHost(log_executive=True, filesystem=filesystem), 'xvfbdrivertestport', options=MockOptions(configuration='Release'))
        port._executive.kill_process = lambda x: _log.info("MOCK kill_process pid: " + str(x))
        driver = XvfbDriver(port, worker_number=0, pixel_tests=True)

        class FakeXvfbProcess(object):
            pid = 1234

        driver._xvfb_process = FakeXvfbProcess()
        driver._lock_file = '/tmp/.X42-lock'

        expected_logs = "MOCK kill_process pid: 1234\n"
        OutputCapture().assert_outputs(self, driver.stop, [], expected_logs=expected_logs)

        self.assertIsNone(driver._xvfb_process)
        self.assertFalse(port._filesystem.exists(driver._lock_file))
    def test_previously_spawned_instance(self):
        host = MockHost()
        options = optparse.Values()
        options.ensure_value("results_directory", "/mock/output_dir")
        port = Port(host, "test", options)
        server = WebPlatformTestServer(port, "wpttest",
                                       "/mock/output_dir/pid.txt")
        server._check_that_all_ports_are_available = lambda: True
        server._is_server_running_on_all_ports = lambda: True
        host.filesystem.write_text_file(
            "/mock-checkout/LayoutTests/resources/testharness.js", "0")
        host.filesystem.write_text_file(
            "/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/resources/testharness.js",
            "0")

        host.filesystem.write_text_file("/mock_output_dir/pid.txt", "0")
        server.start()
        server.stop()
    def test_corrupted_subserver_files(self):
        host = MockHost()
        options = optparse.Values()
        options.ensure_value("results_directory", "/mock/output_dir")
        port = Port(host, "test", options)
        server = WebPlatformTestServer(port, "wpttest",
                                       "/mock/output_dir/pid.txt")
        server._check_that_all_ports_are_available = lambda: True
        server._is_server_running_on_all_ports = lambda: True
        host.filesystem.write_text_file(
            "/mock-checkout/LayoutTests/resources/testharness.js", "0")
        host.filesystem.write_text_file(
            "/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/resources/testharness.js",
            "0")

        host.filesystem.write_text_file(
            "/mock_output_dir/wpttest_servers.json", "0")
        server.stop()
        self.assertFalse(
            host.filesystem.exists("/mock/output_dir/wpttest_servers.json"))

        host.filesystem.write_text_file(
            "/mock_output_dir/wpttest_servers.json", "[0,")
        server.start()
        self.assertFalse(
            host.filesystem.exists("/mock/output_dir/wpttest_servers.json"))
        server.stop()

        host.filesystem.write_text_file(
            "/mock_output_dir/wpttest_servers.json",
            "[{'protocol': 'http', 'port': 80 }]")
        server.start()
        self.assertFalse(
            host.filesystem.exists("/mock/output_dir/wpttest_servers.json"))
        server.stop()

        host.filesystem.write_text_file(
            "/mock_output_dir/wpttest_servers.json",
            "[{'protocol': 'http', 'port': 80, 'pid': {} }]")
        server.start()
        self.assertFalse(
            host.filesystem.exists("/mock/output_dir/wpttest_servers.json"))
        server.stop()
    def test_server_fails_to_start_throws_exception(self):
        host = MockHost()
        options = optparse.Values()
        options.ensure_value("results_directory", "/mock/output_dir")
        port = Port(host, "test", options)
        server = WebPlatformTestServer(port, "wpttest",
                                       "/mock/output_dir/pid.txt")
        server._check_that_all_ports_are_available = lambda: True
        server._is_server_running_on_all_ports = lambda: True
        host.filesystem.write_text_file(
            "/mock-checkout/LayoutTests/resources/testharness.js", "0")
        host.filesystem.write_text_file(
            "/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/resources/testharness.js",
            "0")

        server.start()
        server.stop()
        server._process.poll = lambda: 1
        self.assertRaises(ServerError, server.start)
Esempio n. 14
0
    def test_corrupted_subserver_files(self):
        host = MockHost()
        port = Port(host, "test")
        server = WebPlatformTestServer(port, "wpttest", "/mock/output_dir",
                                       "/mock/output_dir/pid.txt")
        server._check_that_all_ports_are_available = lambda: True
        server._is_server_running_on_all_ports = lambda: True

        host.filesystem.write_text_file(
            "/mock_output_dir/wpttest_servers.json", "0")
        server.stop()
        self.assertFalse(
            host.filesystem.exists("/mock/output_dir/wpttest_servers.json"))

        host.filesystem.write_text_file(
            "/mock_output_dir/wpttest_servers.json", "[0,")
        server.start()
        self.assertFalse(
            host.filesystem.exists("/mock/output_dir/wpttest_servers.json"))
        server.stop()

        host.filesystem.write_text_file(
            "/mock_output_dir/wpttest_servers.json",
            "[{'protocol': 'http', 'port': 80 }]")
        server.start()
        self.assertFalse(
            host.filesystem.exists("/mock/output_dir/wpttest_servers.json"))
        server.stop()

        host.filesystem.write_text_file(
            "/mock_output_dir/wpttest_servers.json",
            "[{'protocol': 'http', 'port': 80, 'pid': {} }]")
        server.start()
        self.assertFalse(
            host.filesystem.exists("/mock/output_dir/wpttest_servers.json"))
        server.stop()
Esempio n. 15
0
 def make_port(self, host=None, options=None):
     port = Port(host or MockSystemHost(), 'test', options
                 or MockOptions(configuration='Release'))
     port._config.build_directory = lambda configuration: '/mock-build'
     return port
Esempio n. 16
0
 def make_port(self):
     port = Port(MockSystemHost(), 'test',
                 MockOptions(configuration='Release'))
     port._config.build_directory = lambda configuration: '/mock-build'
     return port