Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / native_client_sdk / src / test_all.py
blob6e9b3dd3af30d3d3daa33c0864461773ec962add
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
6 """Top level script for running all python unittests in the NaCl SDK
7 """
9 from __future__ import print_function
11 import argparse
12 import os
13 import subprocess
14 import sys
15 import unittest
17 # add tools folder to sys.path
18 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
19 TOOLS_DIR = os.path.join(SCRIPT_DIR, 'tools')
20 BUILD_TOOLS_DIR = os.path.join(SCRIPT_DIR, 'build_tools')
22 sys.path.append(TOOLS_DIR)
23 sys.path.append(os.path.join(TOOLS_DIR, 'tests'))
24 sys.path.append(os.path.join(TOOLS_DIR, 'lib', 'tests'))
25 sys.path.append(BUILD_TOOLS_DIR)
26 sys.path.append(os.path.join(BUILD_TOOLS_DIR, 'tests'))
28 import build_paths
30 PKG_VER_DIR = os.path.join(build_paths.NACL_DIR, 'build', 'package_version')
31 TAR_DIR = os.path.join(build_paths.NACL_DIR, 'toolchain', '.tars')
33 PKG_VER = os.path.join(PKG_VER_DIR, 'package_version.py')
35 EXTRACT_PACKAGES = ['nacl_x86_glibc']
36 TOOLCHAIN_OUT = os.path.join(build_paths.OUT_DIR, 'sdk_tests', 'toolchain')
38 TEST_MODULES = [
39 'build_artifacts_test',
40 'build_version_test',
41 'create_html_test',
42 'create_nmf_test',
43 'easy_template_test',
44 'elf_test',
45 'fix_deps_test',
46 'getos_test',
47 'get_shared_deps_test',
48 'httpd_test',
49 'nacl_config_test',
50 'oshelpers_test',
51 'parse_dsc_test',
52 'quote_test',
53 'sdktools_commands_test',
54 'sdktools_config_test',
55 'sdktools_test',
56 'sel_ldr_test',
57 'update_nacl_manifest_test',
58 'verify_filelist_test',
59 'verify_ppapi_test',
62 def ExtractToolchains():
63 subprocess.check_output([sys.executable, PKG_VER,
64 '--packages', ','.join(EXTRACT_PACKAGES),
65 '--tar-dir', TAR_DIR,
66 '--dest-dir', TOOLCHAIN_OUT,
67 'extract'])
69 def main(args):
70 parser = argparse.ArgumentParser(description=__doc__)
71 parser.add_argument('-v', '--verbose', action='store_true')
72 options = parser.parse_args(args)
74 # Some of the unit tests use parts of toolchains. Extract to TOOLCHAIN_OUT.
75 print('Extracting toolchains...')
76 ExtractToolchains()
78 suite = unittest.TestSuite()
79 for module_name in TEST_MODULES:
80 module = __import__(module_name)
81 suite.addTests(unittest.defaultTestLoader.loadTestsFromModule(module))
83 if options.verbose:
84 verbosity = 2
85 else:
86 verbosity = 1
88 print('Running unittests...')
89 result = unittest.TextTestRunner(verbosity=verbosity).run(suite)
90 return int(not result.wasSuccessful())
92 if __name__ == '__main__':
93 sys.exit(main(sys.argv[1:]))