| 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 import json | 5 import json |
| 6 import os | 6 import os |
| 7 import posixpath | 7 import posixpath |
| 8 import shutil | 8 import shutil |
| 9 import subprocess | 9 import subprocess |
| 10 import sys | 10 import sys |
| 11 import tempfile | 11 import tempfile |
| 12 import unittest | 12 import unittest |
| 13 | 13 |
| 14 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 14 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 15 TOOLS_DIR = os.path.dirname(SCRIPT_DIR) | 15 TOOLS_DIR = os.path.dirname(SCRIPT_DIR) |
| 16 DATA_DIR = os.path.join(TOOLS_DIR, 'lib', 'tests', 'data') | 16 DATA_DIR = os.path.join(TOOLS_DIR, 'lib', 'tests', 'data') |
| 17 CHROME_SRC = os.path.dirname(os.path.dirname(os.path.dirname(TOOLS_DIR))) | 17 CHROME_SRC = os.path.dirname(os.path.dirname(os.path.dirname(TOOLS_DIR))) |
| 18 MOCK_DIR = os.path.join(CHROME_SRC, "third_party", "pymock") | 18 MOCK_DIR = os.path.join(CHROME_SRC, "third_party", "pymock") |
| 19 | 19 |
| 20 # For the mock library | 20 # For the mock library |
| 21 sys.path.append(MOCK_DIR) | 21 sys.path.append(MOCK_DIR) |
| 22 sys.path.append(TOOLS_DIR) | 22 sys.path.append(TOOLS_DIR) |
| 23 | 23 |
| 24 import build_paths |
| 24 import create_nmf | 25 import create_nmf |
| 25 import getos | |
| 26 import mock | 26 import mock |
| 27 | 27 |
| 28 TOOLCHAIN_OUT = os.path.join(build_paths.OUT_DIR, 'sdk_tests', 'toolchain') |
| 29 NACL_X86_GLIBC_TOOLCHAIN = os.path.join(TOOLCHAIN_OUT, 'nacl_x86_glibc') |
| 30 |
| 28 | 31 |
| 29 PosixRelPath = create_nmf.PosixRelPath | 32 PosixRelPath = create_nmf.PosixRelPath |
| 30 | 33 |
| 31 | 34 |
| 32 def StripSo(name): | 35 def StripSo(name): |
| 33 """Strip trailing hexidecimal characters from the name of a shared object. | 36 """Strip trailing hexidecimal characters from the name of a shared object. |
| 34 | 37 |
| 35 It strips everything after the last '.' in the name, and checks that the new | 38 It strips everything after the last '.' in the name, and checks that the new |
| 36 name ends with .so. | 39 name ends with .so. |
| 37 | 40 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 paths = create_nmf.GetDefaultLibPath('Debug') | 79 paths = create_nmf.GetDefaultLibPath('Debug') |
| 77 self.assertTrue(any(os.path.join('ports', 'lib') in p for p in paths), | 80 self.assertTrue(any(os.path.join('ports', 'lib') in p for p in paths), |
| 78 "naclports libpath missing: %s" % str(paths)) | 81 "naclports libpath missing: %s" % str(paths)) |
| 79 | 82 |
| 80 | 83 |
| 81 class TestNmfUtils(unittest.TestCase): | 84 class TestNmfUtils(unittest.TestCase): |
| 82 """Tests for the main NmfUtils class in create_nmf.""" | 85 """Tests for the main NmfUtils class in create_nmf.""" |
| 83 | 86 |
| 84 def setUp(self): | 87 def setUp(self): |
| 85 self.tempdir = None | 88 self.tempdir = None |
| 86 toolchain = os.path.join(CHROME_SRC, 'native_client', 'toolchain') | 89 self.toolchain = NACL_X86_GLIBC_TOOLCHAIN |
| 87 self.toolchain = os.path.join(toolchain, '%s_x86' % getos.GetPlatform(), | |
| 88 'nacl_x86_glibc') | |
| 89 self.objdump = os.path.join(self.toolchain, 'bin', 'i686-nacl-objdump') | 90 self.objdump = os.path.join(self.toolchain, 'bin', 'i686-nacl-objdump') |
| 90 if os.name == 'nt': | 91 if os.name == 'nt': |
| 91 self.objdump += '.exe' | 92 self.objdump += '.exe' |
| 92 self._Mktemp() | 93 self._Mktemp() |
| 93 | 94 |
| 94 def _CreateTestNexe(self, name, arch): | 95 def _CreateTestNexe(self, name, arch): |
| 95 """Create an empty test .nexe file for use in create_nmf tests. | 96 """Create an empty test .nexe file for use in create_nmf tests. |
| 96 | 97 |
| 97 This is used rather than checking in test binaries since the | 98 This is used rather than checking in test binaries since the |
| 98 checked in binaries depend on .so files that only exist in the | 99 checked in binaries depend on .so files that only exist in the |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 'optlevel': 0, | 595 'optlevel': 0, |
| 595 } | 596 } |
| 596 } | 597 } |
| 597 } | 598 } |
| 598 } | 599 } |
| 599 self.assertManifestEquals(nmf, expected_manifest) | 600 self.assertManifestEquals(nmf, expected_manifest) |
| 600 | 601 |
| 601 | 602 |
| 602 if __name__ == '__main__': | 603 if __name__ == '__main__': |
| 603 unittest.main() | 604 unittest.main() |
| OLD | NEW |