[chromedriver] Release ChromeDriver 2.18.
[chromium-blink-merge.git] / native_client_sdk / src / test_all.py
blob5062c40ea2e2a503b66f8b168882abb0415f8d78
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 # List of modules containing unittests. The goal is to keep the total
39 # runtime of these tests under 2 seconds. Any slower tests should go
40 # in TEST_MODULES_BIG.
41 TEST_MODULES = [
42 'build_artifacts_test',
43 'build_version_test',
44 'create_html_test',
45 'create_nmf_test',
46 'easy_template_test',
47 'elf_test',
48 'fix_deps_test',
49 'getos_test',
50 'get_shared_deps_test',
51 'httpd_test',
52 'nacl_config_test',
53 'oshelpers_test',
54 'parse_dsc_test',
55 'quote_test',
56 'sdktools_config_test',
57 'sel_ldr_test',
58 'test_projects_test',
59 'update_nacl_manifest_test',
60 'verify_filelist_test',
61 'verify_ppapi_test',
65 # Slower tests. For example the 'sdktools' are mostly slower system tests
66 # that longer to run. If --quick is passed then we don't run these.
67 TEST_MODULES_BIG = [
68 'sdktools_commands_test',
69 'sdktools_test',
73 def ExtractToolchains():
74 cmd = [sys.executable, PKG_VER,
75 '--packages', ','.join(EXTRACT_PACKAGES),
76 '--tar-dir', TAR_DIR,
77 '--dest-dir', TOOLCHAIN_OUT,
78 'extract']
79 subprocess.check_call(cmd)
82 def main(args):
83 parser = argparse.ArgumentParser(description=__doc__)
84 parser.add_argument('-v', '--verbose', action='store_true')
85 parser.add_argument('--quick', action='store_true')
86 options = parser.parse_args(args)
88 # Some of the unit tests use parts of toolchains. Extract to TOOLCHAIN_OUT.
89 print('Extracting toolchains...')
90 ExtractToolchains()
92 suite = unittest.TestSuite()
93 modules = TEST_MODULES
94 if not options.quick:
95 modules += TEST_MODULES_BIG
97 for module_name in modules:
98 module = __import__(module_name)
99 suite.addTests(unittest.defaultTestLoader.loadTestsFromModule(module))
101 if options.verbose:
102 verbosity = 2
103 else:
104 verbosity = 1
106 print('Running unittests...')
107 result = unittest.TextTestRunner(verbosity=verbosity).run(suite)
108 return int(not result.wasSuccessful())
111 if __name__ == '__main__':
112 sys.exit(main(sys.argv[1:]))