OLD | NEW |
1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 driver_file_output=None): | 46 driver_file_output=None): |
47 host = MockSystemHost(os_name=self.os_name, os_version=(os_version or se
lf.os_version)) | 47 host = MockSystemHost(os_name=self.os_name, os_version=(os_version or se
lf.os_version)) |
48 host.filesystem.isfile = lambda x: 'content_shell' in x | 48 host.filesystem.isfile = lambda x: 'content_shell' in x |
49 if driver_file_output: | 49 if driver_file_output: |
50 host.executive = executive_mock.MockExecutive2(driver_file_output) | 50 host.executive = executive_mock.MockExecutive2(driver_file_output) |
51 port = self.make_port(host=host, port_name=port_name, os_version=os_vers
ion) | 51 port = self.make_port(host=host, port_name=port_name, os_version=os_vers
ion) |
52 self.assertEqual(port.name(), expected_name) | 52 self.assertEqual(port.name(), expected_name) |
53 self.assertEqual(port.version(), expected_version) | 53 self.assertEqual(port.version(), expected_version) |
54 | 54 |
55 def test_versions(self): | 55 def test_versions(self): |
56 self.assertTrue(self.make_port().name() in ('linux-precise', 'linux-trus
ty')) | 56 self.assertTrue(self.make_port().name() in ('linux-trusty',)) |
57 | 57 |
58 self.assert_version_properties('linux', 'trusty', 'linux-trusty', 'trust
y') | 58 self.assert_version_properties('linux', 'trusty', 'linux-trusty', 'trust
y') |
59 self.assert_version_properties('linux', 'precise', 'linux-precise', 'pre
cise') | |
60 | |
61 self.assert_version_properties('linux-trusty', None, 'linux-trusty', 'tr
usty') | 59 self.assert_version_properties('linux-trusty', None, 'linux-trusty', 'tr
usty') |
62 self.assert_version_properties('linux-precise', None, 'linux-precise', '
precise') | |
63 self.assertRaises(AssertionError, self.assert_version_properties, | 60 self.assertRaises(AssertionError, self.assert_version_properties, |
64 'linux-utopic', None, 'ignored', 'ignored', 'ignored') | 61 'linux-utopic', None, 'ignored', 'ignored', 'ignored') |
65 | 62 |
66 def assert_baseline_paths(self, port_name, os_version, *expected_paths): | 63 def assert_baseline_paths(self, port_name, os_version, *expected_paths): |
67 port = self.make_port(port_name=port_name, os_version=os_version) | 64 port = self.make_port(port_name=port_name, os_version=os_version) |
68 self.assertEqual( | 65 self.assertEqual( |
69 port.baseline_version_dir(), | 66 port.baseline_version_dir(), |
70 port._absolute_baseline_path(expected_paths[0])) # pylint: disable=
protected-access | 67 port._absolute_baseline_path(expected_paths[0])) # pylint: disable=
protected-access |
71 self.assertEqual(len(port.baseline_search_path()), len(expected_paths)) | 68 self.assertEqual(len(port.baseline_search_path()), len(expected_paths)) |
72 for i, path in enumerate(expected_paths): | 69 for i, path in enumerate(expected_paths): |
73 self.assertTrue(port.baseline_search_path()[i].endswith(path)) | 70 self.assertTrue(port.baseline_search_path()[i].endswith(path)) |
74 | 71 |
75 def test_baseline_paths(self): | 72 def test_baseline_paths(self): |
76 self.assert_baseline_paths('linux', 'trusty', 'linux', '/win') | 73 self.assert_baseline_paths('linux', 'trusty', 'linux', '/win') |
77 self.assert_baseline_paths('linux', 'precise', 'linux-precise', '/linux'
, '/win') | |
78 | |
79 self.assert_baseline_paths('linux-trusty', None, 'linux', '/win') | 74 self.assert_baseline_paths('linux-trusty', None, 'linux', '/win') |
80 self.assert_baseline_paths('linux-precise', None, 'linux-precise', '/lin
ux', '/win') | |
81 | 75 |
82 def test_check_illegal_port_names(self): | 76 def test_check_illegal_port_names(self): |
83 # FIXME: Check that, for now, these are illegal port names. | 77 # FIXME: Check that, for now, these are illegal port names. |
84 # Eventually we should be able to do the right thing here. | 78 # Eventually we should be able to do the right thing here. |
85 self.assertRaises(AssertionError, linux.LinuxPort, MockSystemHost(), por
t_name='linux-x86') | 79 self.assertRaises(AssertionError, linux.LinuxPort, MockSystemHost(), por
t_name='linux-x86') |
86 | 80 |
87 def test_operating_system(self): | 81 def test_operating_system(self): |
88 self.assertEqual('linux', self.make_port().operating_system()) | 82 self.assertEqual('linux', self.make_port().operating_system()) |
89 | 83 |
90 def test_build_path(self): | 84 def test_build_path(self): |
(...skipping 22 matching lines...) Expand all Loading... |
113 port.setup_test_run() | 107 port.setup_test_run() |
114 temp_home_dir = port.host.environ['HOME'] | 108 temp_home_dir = port.host.environ['HOME'] |
115 self.assertNotEqual(temp_home_dir, '/home/user') | 109 self.assertNotEqual(temp_home_dir, '/home/user') |
116 self.assertTrue(port.host.filesystem.isdir(temp_home_dir)) | 110 self.assertTrue(port.host.filesystem.isdir(temp_home_dir)) |
117 self.assertTrue(port.host.filesystem.isfile(port.host.filesystem.join(te
mp_home_dir, '.Xauthority'))) | 111 self.assertTrue(port.host.filesystem.isfile(port.host.filesystem.join(te
mp_home_dir, '.Xauthority'))) |
118 | 112 |
119 # Clean up; HOME should be reset and the temp dir should be cleaned up. | 113 # Clean up; HOME should be reset and the temp dir should be cleaned up. |
120 port.clean_up_test_run() | 114 port.clean_up_test_run() |
121 self.assertEqual(port.host.environ['HOME'], '/home/user') | 115 self.assertEqual(port.host.environ['HOME'], '/home/user') |
122 self.assertFalse(port.host.filesystem.exists(temp_home_dir)) | 116 self.assertFalse(port.host.filesystem.exists(temp_home_dir)) |
OLD | NEW |