# Copyright (C) 2011 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import unittest from webkitpy.common.system import executive_mock from webkitpy.common.system.systemhost_mock import MockSystemHost from webkitpy.layout_tests.port import chromium_linux from webkitpy.layout_tests.port import port_testcase class ChromiumLinuxPortTest(port_testcase.PortTestCase): port_name = 'chromium-linux' port_maker = chromium_linux.ChromiumLinuxPort def assert_architecture(self, port_name=None, file_output=None, expected_architecture=None): host = MockSystemHost() host.filesystem.exists = lambda x: 'DumpRenderTree' in x if file_output: host.executive = executive_mock.MockExecutive2(file_output) port = self.make_port(host, port_name=port_name) self.assertEquals(port.architecture(), expected_architecture) if expected_architecture == 'x86': self.assertTrue(port.baseline_path().endswith('chromium-linux-x86')) self.assertTrue(port.baseline_search_path()[0].endswith('chromium-linux-x86')) self.assertTrue(port.baseline_search_path()[1].endswith('chromium-linux')) else: self.assertTrue(port.baseline_path().endswith('chromium-linux')) self.assertTrue(port.baseline_search_path()[0].endswith('chromium-linux')) def test_architectures(self): self.assert_architecture(port_name='chromium-linux-x86', expected_architecture='x86') self.assert_architecture(port_name='chromium-linux-x86_64', expected_architecture='x86_64') self.assert_architecture(file_output='ELF 32-bit LSB executable', expected_architecture='x86') self.assert_architecture(file_output='ELF 64-bit LSB executable', expected_architecture='x86_64') def test_check_illegal_port_names(self): # FIXME: Check that, for now, these are illegal port names. # Eventually we should be able to do the right thing here. self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, MockSystemHost(), port_name='chromium-x86-linux') def test_determine_architecture_fails(self): # Test that we default to 'x86' if the driver doesn't exist. port = self.make_port() self.assertEquals(port.architecture(), 'x86_64') # Test that we default to 'x86' on an unknown architecture. host = MockSystemHost() host.filesystem.exists = lambda x: True host.executive = executive_mock.MockExecutive2('win32') port = self.make_port(host=host) self.assertEquals(port.architecture(), 'x86_64') # Test that we raise errors if something weird happens. host.executive = executive_mock.MockExecutive2(exception=AssertionError) self.assertRaises(AssertionError, chromium_linux.ChromiumLinuxPort, host, self.port_name) def test_operating_system(self): self.assertEqual('linux', self.make_port().operating_system()) if __name__ == '__main__': port_testcase.main()