Chromium Code Reviews| Index: native_client_sdk/src/test_all.py |
| diff --git a/native_client_sdk/src/test_all.py b/native_client_sdk/src/test_all.py |
| index c91e64e59c98eafa0aec8aef9da2c029b367b956..a36694b826ccfa718365389b9bfaf6e9681accf9 100755 |
| --- a/native_client_sdk/src/test_all.py |
| +++ b/native_client_sdk/src/test_all.py |
| @@ -5,13 +5,25 @@ |
| import os |
| import sys |
| +import shutil |
|
binji
2014/04/14 22:17:26
alphabetize
David Yen
2014/04/14 22:31:05
Done.
|
| +import tarfile |
| import unittest |
| # add tools folder to sys.path |
| SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| -sys.path.append(os.path.join(SCRIPT_DIR, 'tools', 'tests')) |
| -sys.path.append(os.path.join(SCRIPT_DIR, 'tools', 'lib', 'tests')) |
| -sys.path.append(os.path.join(SCRIPT_DIR, 'build_tools', 'tests')) |
| +TOOLS_DIR = os.path.join(SCRIPT_DIR, 'tools') |
|
binji
2014/04/14 22:17:26
TODO remove this stuff too (like below)?
David Yen
2014/04/14 22:31:05
These will stay, only sys.path.append(TOOLS_DIR) i
|
| +BUILD_TOOLS_DIR = os.path.join(SCRIPT_DIR, 'build_tools') |
| +sys.path.append(TOOLS_DIR) |
| +sys.path.append(os.path.join(TOOLS_DIR, 'tests')) |
| +sys.path.append(os.path.join(TOOLS_DIR, 'lib', 'tests')) |
| +sys.path.append(BUILD_TOOLS_DIR) |
| +sys.path.append(os.path.join(BUILD_TOOLS_DIR, 'tests')) |
| + |
| +import build_paths |
| +import getos |
| + |
| +TOOLCHAIN_OUT = os.path.join(build_paths.OUT_DIR, 'sdk_tests', 'toolchain') |
|
binji
2014/04/14 22:17:26
move this into build_paths (or does it go away aft
David Yen
2014/04/14 22:31:05
This is the output directory for the nacl_x86_glib
|
| +NACL_X86_GLIBC_TOOLCHAIN = os.path.join(TOOLCHAIN_OUT, 'nacl_x86_glibc') |
| TEST_MODULES = [ |
| 'create_html_test', |
| @@ -35,7 +47,45 @@ TEST_MODULES = [ |
| 'verify_ppapi_test', |
| ] |
| +def ExtractToolchain(): |
| + # TODO(dyen): This function is basically all temporary code. After the DEPS |
|
binji
2014/04/14 22:17:26
Add a bug for this, unless this is all going to ha
David Yen
2014/04/14 22:31:05
This is going to happen very soon, I will add the
|
| + # roll, replace this untar with package_version.py which will do the |
| + # untarring and be able to check whether or not the toolchain is out of date. |
| + platform_name = getos.GetPlatform() |
| + nacl_x86_glibc_tar = os.path.join(build_paths.NACL_DIR, 'toolchain', '.tars', |
| + 'toolchain_%s_x86.tar.bz2' % platform_name) |
| + assert os.path.isfile(nacl_x86_glibc_tar), 'Could not locate toolchain tar' |
| + |
| + stamp_file = os.path.join(NACL_X86_GLIBC_TOOLCHAIN, 'extract.stamp') |
| + if (not os.path.isfile(stamp_file) or |
| + os.path.getmtime(stamp_file) < os.path.getmtime(nacl_x86_glibc_tar)): |
| + |
| + print 'Extracting nacl_x86_glibc...' |
| + temp_dir = os.path.join(TOOLCHAIN_OUT, 'temp') |
| + if os.path.isdir(temp_dir): |
| + shutil.rmtree(temp_dir) |
| + os.makedirs(temp_dir) |
| + with tarfile.open(nacl_x86_glibc_tar) as f: |
| + f.extractall(temp_dir) |
| + |
| + if os.path.isdir(NACL_X86_GLIBC_TOOLCHAIN): |
| + shutil.rmtree(NACL_X86_GLIBC_TOOLCHAIN) |
| + parent_dir = os.path.dirname(NACL_X86_GLIBC_TOOLCHAIN) |
| + if not os.path.isdir(parent_dir): |
| + os.makedirs(parent_dir) |
| + |
| + extracted_path = os.path.join(temp_dir, 'toolchain', |
| + '%s_x86' % platform_name) |
| + os.rename(extracted_path, NACL_X86_GLIBC_TOOLCHAIN) |
| + |
| + with open(stamp_file, 'wt') as f: |
| + f.write(nacl_x86_glibc_tar) |
| + |
| def main(): |
| + # Some of the unit tests utilize nacl_x86_glibc. Untar a copy in the output |
| + # directory for the tests to use. |
| + ExtractToolchain() |
| + |
| suite = unittest.TestSuite() |
| for module_name in TEST_MODULES: |
| module = __import__(module_name) |