OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2011 The Native Client 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 """Unit tests for set_nacl_env.py.""" | 6 """Unit tests for set_nacl_env.py.""" |
7 | 7 |
8 import glob | 8 import glob |
9 import os | 9 import os |
10 import shutil | 10 import shutil |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 # Can't use make on Windows | 86 # Can't use make on Windows |
87 if sys.platform == 'win32': | 87 if sys.platform == 'win32': |
88 return | 88 return |
89 | 89 |
90 # The test directories are not generally writable. To be able to run make, | 90 # The test directories are not generally writable. To be able to run make, |
91 # we copy the files to a temp directory instead. | 91 # we copy the files to a temp directory instead. |
92 self.assertTrue(self._temp_dir) | 92 self.assertTrue(self._temp_dir) |
93 src_dir = os.path.join(SCRIPT_DIR, 'set_nacl_env_test_archive') | 93 src_dir = os.path.join(SCRIPT_DIR, 'set_nacl_env_test_archive') |
94 for file in glob.iglob(os.path.join(src_dir, '*')): | 94 for file in glob.iglob(os.path.join(src_dir, '*')): |
95 shutil.copy2(file, self._temp_dir) | 95 shutil.copy2(file, self._temp_dir) |
| 96 shutil.copy2(os.path.join(SDK_ROOT_DIR, 'examples', 'hello_world_c', |
| 97 'hello_world_c.c'), |
| 98 self._temp_dir) |
96 | 99 |
97 script = os.path.join(SDK_ROOT_DIR, 'build_tools', 'sdk_tools', | 100 script = os.path.join(SDK_ROOT_DIR, 'build_tools', 'sdk_tools', |
98 'set_nacl_env.py') | 101 'set_nacl_env.py') |
99 nexe_path = os.path.join(self._temp_dir, 'hello_world_c.nexe') | 102 nexe_path = os.path.join(self._temp_dir, 'hello_world_c.nexe') |
100 | 103 |
101 # Build and verify the 32-bit version. | 104 # Build and verify the 32-bit version. |
102 options = ['--platform=.', '--arch=x86-32'] | 105 options = ['--platform=.', '--arch=x86-32'] |
103 cmd = [script] + options + ['make hello_world_c.nexe'] | 106 cmd = [script] + options + ['make hello_world_c.nexe'] |
104 self.assertEqual(0, subprocess.call(cmd, env=self._env, shell=False, | 107 self.assertEqual(0, subprocess.call(cmd, env=self._env, shell=False, |
105 cwd=self._temp_dir)) | 108 cwd=self._temp_dir)) |
(...skipping 16 matching lines...) Expand all Loading... |
122 | 125 |
123 def main(): | 126 def main(): |
124 suite = unittest.TestLoader().loadTestsFromTestCase(TestSetNaclEnv) | 127 suite = unittest.TestLoader().loadTestsFromTestCase(TestSetNaclEnv) |
125 result = unittest.TextTestRunner(verbosity=2).run(suite) | 128 result = unittest.TextTestRunner(verbosity=2).run(suite) |
126 | 129 |
127 return int(not result.wasSuccessful()) | 130 return int(not result.wasSuccessful()) |
128 | 131 |
129 | 132 |
130 if __name__ == '__main__': | 133 if __name__ == '__main__': |
131 sys.exit(main()) | 134 sys.exit(main()) |
OLD | NEW |