OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os | 6 import os |
7 import shutil | 7 import shutil |
8 import sys | 8 import sys |
9 import tempfile | 9 import tempfile |
10 import unittest | 10 import unittest |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 mock_location = '/bin/ls' | 84 mock_location = '/bin/ls' |
85 platform = getos.GetPlatform() | 85 platform = getos.GetPlatform() |
86 if platform == 'win': | 86 if platform == 'win': |
87 mock_location = 'c:\\nowhere' | 87 mock_location = 'c:\\nowhere' |
88 with mock.patch.dict('os.environ', {'CHROME_PATH': mock_location}): | 88 with mock.patch.dict('os.environ', {'CHROME_PATH': mock_location}): |
89 with mock.patch('os.path.exists') as mock_exists: | 89 with mock.patch('os.path.exists') as mock_exists: |
90 chrome = getos.GetChromePath(platform) | 90 chrome = getos.GetChromePath(platform) |
91 self.assertEqual(chrome, mock_location) | 91 self.assertEqual(chrome, mock_location) |
92 mock_exists.assert_called_with(chrome) | 92 mock_exists.assert_called_with(chrome) |
93 | 93 |
94 def testGetHelperPath(self): | |
95 """GetHelperPath checks that helper exists.""" | |
96 platform = getos.GetPlatform() | |
97 # The helper is only needed on linux. On other platforms | |
98 # GetHelperPath() simply return empty string. | |
99 if platform == 'linux': | |
100 with mock.patch('os.path.exists') as mock_exists: | |
101 helper = getos.GetHelperPath(platform) | |
102 mock_exists.assert_called_with(helper) | |
103 else: | |
104 helper = getos.GetHelperPath(platform) | |
105 self.assertEqual(helper, '') | |
106 | |
107 def testGetIrtBinPath(self): | |
108 """GetIrtBinPath checks that irtbin exists.""" | |
109 platform = getos.GetPlatform() | |
110 with mock.patch('os.path.exists') as mock_exists: | |
111 irt = getos.GetIrtBinPath(platform) | |
112 mock_exists.assert_called_with(irt) | |
113 | |
114 def testGetLoaderPath(self): | |
115 """checks that loader exists.""" | |
116 platform = getos.GetPlatform() | |
117 with mock.patch('os.path.exists') as mock_exists: | |
118 loader = getos.GetLoaderPath(platform) | |
119 mock_exists.assert_called_with(loader) | |
120 | |
121 def testGetNaClArch(self): | 94 def testGetNaClArch(self): |
122 """returns a valid architecture.""" | 95 """returns a valid architecture.""" |
123 platform = getos.GetPlatform() | 96 platform = getos.GetPlatform() |
124 # Since the unix implementation of GetNaClArch will run objdump on the | 97 # Since the unix implementation of GetNaClArch will run objdump on the |
125 # chrome binary, and we want to be able to run this test without chrome | 98 # chrome binary, and we want to be able to run this test without chrome |
126 # installed we mock the GetChromePath call to return a known system binary, | 99 # installed we mock the GetChromePath call to return a known system binary, |
127 # which objdump will work with. | 100 # which objdump will work with. |
128 with mock.patch('getos.GetChromePath') as mock_chrome_path: | 101 with mock.patch('getos.GetChromePath') as mock_chrome_path: |
129 mock_chrome_path.return_value = '/bin/ls' | 102 mock_chrome_path.return_value = '/bin/ls' |
130 arch = getos.GetNaClArch(platform) | 103 arch = getos.GetNaClArch(platform) |
(...skipping 17 matching lines...) Expand all Loading... |
148 with open(os.path.join(self.tempdir, 'README'), 'w') as out: | 121 with open(os.path.join(self.tempdir, 'README'), 'w') as out: |
149 out.write('Version: %s\n' % expected_version[0]) | 122 out.write('Version: %s\n' % expected_version[0]) |
150 out.write('Chrome Revision: %s\n' % expected_version[1]) | 123 out.write('Chrome Revision: %s\n' % expected_version[1]) |
151 | 124 |
152 version = getos.GetSDKVersion() | 125 version = getos.GetSDKVersion() |
153 self.assertEqual(version, expected_version) | 126 self.assertEqual(version, expected_version) |
154 | 127 |
155 | 128 |
156 if __name__ == '__main__': | 129 if __name__ == '__main__': |
157 unittest.main() | 130 unittest.main() |
OLD | NEW |