Chromium Code Reviews| 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 | 5 |
| 6 """Script for a testing an existing SDK. | 6 """Script for a testing an existing SDK. |
| 7 | 7 |
| 8 This script is normally run immediately after build_sdk.py. | 8 This script is normally run immediately after build_sdk.py. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 toolchains=toolchains) | 56 toolchains=toolchains) |
| 57 | 57 |
| 58 | 58 |
| 59 def StepBuildTests(pepperdir): | 59 def StepBuildTests(pepperdir): |
| 60 for config in ('Debug', 'Release'): | 60 for config in ('Debug', 'Release'): |
| 61 build_sdk.BuildStepMakeAll(pepperdir, 'tests', | 61 build_sdk.BuildStepMakeAll(pepperdir, 'tests', |
| 62 'Build Tests (%s)' % config, | 62 'Build Tests (%s)' % config, |
| 63 deps=False, config=config) | 63 deps=False, config=config) |
| 64 | 64 |
| 65 | 65 |
| 66 def StepRunSelLdrTests(pepperdir): | 66 def StepRunSelLdrTests(pepperdir, sanitiser): |
| 67 filters = { | 67 filters = { |
| 68 'SEL_LDR': True | 68 'SEL_LDR': True |
| 69 } | 69 } |
| 70 | 70 |
| 71 tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters) | 71 tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=filters) |
| 72 | 72 |
| 73 def RunTest(test, toolchain, config, arch=None): | 73 def RunTest(test, toolchain, config, arch=None): |
| 74 args = ['run', 'STANDALONE=1', 'TOOLCHAIN=%s' % toolchain] | 74 args = ['STANDALONE=1', 'TOOLCHAIN=%s' % toolchain] |
| 75 if arch is not None: | 75 if arch is not None: |
| 76 args.append('NACL_ARCH=%s' % arch) | 76 args.append('NACL_ARCH=%s' % arch) |
| 77 deps = False | |
| 78 | |
| 79 if sanitiser is not None: | |
| 80 # For sanitizer builds we pass extra argument for make, and do | |
| 81 # full clean build to make sure everything is rebuilt with the | |
| 82 # correct flags | |
| 83 deps = True | |
| 84 if sanitiser == 'valgrind': | |
| 85 args += ['RUN_UNDER=valgrind'] | |
| 86 else: | |
| 87 args += ['CC=clang', 'CXX=clang++', | |
| 88 'LDFLAGS=-pie -fsanitize=' + sanitiser, | |
| 89 'CFLAGS=-fPIC -fsanitize=' + sanitiser] | |
| 90 build_projects.BuildProjectsBranch(pepperdir, 'src', clean=False, | |
| 91 deps=deps, config=config, | |
| 92 args=args + ['clean']) | |
| 93 build_projects.BuildProjectsBranch(pepperdir, 'tests', clean=False, | |
| 94 deps=deps, config=config, | |
| 95 args=args + ['clean']) | |
| 96 | |
| 77 build_projects.BuildProjectsBranch(pepperdir, test, clean=False, | 97 build_projects.BuildProjectsBranch(pepperdir, test, clean=False, |
| 78 deps=False, config=config, | 98 deps=deps, config=config, |
| 79 args=args) | 99 args=args + ['run']) |
| 80 | 100 |
| 81 if getos.GetPlatform() == 'win': | 101 if getos.GetPlatform() == 'win': |
| 82 # On win32 we only support running on the system | 102 # On win32 we only support running on the system |
| 83 # arch | 103 # arch |
| 84 archs = (getos.GetSystemArch('win'),) | 104 archs = (getos.GetSystemArch('win'),) |
| 85 elif getos.GetPlatform() == 'mac': | 105 elif getos.GetPlatform() == 'mac': |
| 86 # We only ship 32-bit version of sel_ldr on mac. | 106 # We only ship 32-bit version of sel_ldr on mac. |
| 87 archs = ('x86_32',) | 107 archs = ('x86_32',) |
| 88 else: | 108 else: |
| 89 # On linux we can run both 32 and 64-bit | 109 # On linux we can run both 32 and 64-bit |
| 90 archs = ('x86_64', 'x86_32') | 110 archs = ('x86_64', 'x86_32') |
| 91 | 111 |
| 92 for root, projects in tree.iteritems(): | 112 for root, projects in tree.iteritems(): |
| 93 for project in projects: | 113 for project in projects: |
| 94 title = 'sel_ldr tests: %s' % os.path.basename(project['NAME']) | 114 if sanitiser: |
| 115 sanitiser_name = '[sanitiser=%s]' % sanitiser | |
| 116 else: | |
| 117 sanitiser_name = '' | |
| 118 title = 'standalone test%s: %s' % (sanitiser_name, | |
| 119 os.path.basename(project['NAME'])) | |
| 95 location = os.path.join(root, project['NAME']) | 120 location = os.path.join(root, project['NAME']) |
| 96 buildbot_common.BuildStep(title) | 121 buildbot_common.BuildStep(title) |
| 122 configs = ('Debug', 'Release') | |
| 97 | 123 |
| 98 # On linux we can run the standalone tests natively using the host | 124 # On linux we can run the standalone tests natively using the host |
| 99 # compiler. | 125 # compiler. |
| 100 if getos.GetPlatform() == 'linux': | 126 if getos.GetPlatform() == 'linux': |
| 101 for config in ('Debug', 'Release'): | 127 if sanitiser: |
| 128 configs = ('Debug',) | |
| 129 for config in configs: | |
| 102 RunTest(location, 'linux', config) | 130 RunTest(location, 'linux', config) |
| 103 | 131 |
| 132 if sanitiser: | |
| 133 continue | |
| 134 | |
| 104 for toolchain in ('newlib', 'glibc'): | 135 for toolchain in ('newlib', 'glibc'): |
| 105 for arch in archs: | 136 for arch in archs: |
| 106 for config in ('Debug', 'Release'): | 137 for config in configs: |
| 107 RunTest(location, toolchain, config, arch) | 138 RunTest(location, toolchain, config, arch) |
| 108 | 139 |
| 109 | 140 |
| 110 def StepRunBrowserTests(toolchains, experimental): | 141 def StepRunBrowserTests(toolchains, experimental): |
| 111 buildbot_common.BuildStep('Run Tests') | 142 buildbot_common.BuildStep('Run Tests') |
| 112 | 143 |
| 113 args = [ | 144 args = [ |
| 114 sys.executable, | 145 sys.executable, |
| 115 os.path.join(SCRIPT_DIR, 'test_projects.py'), | 146 os.path.join(SCRIPT_DIR, 'test_projects.py'), |
| 116 '--retry-times=3', | 147 '--retry-times=3', |
| 117 ] | 148 ] |
| 118 | 149 |
| 119 if experimental: | 150 if experimental: |
| 120 args.append('-x') | 151 args.append('-x') |
| 121 for toolchain in toolchains: | 152 for toolchain in toolchains: |
| 122 args.extend(['-t', toolchain]) | 153 args.extend(['-t', toolchain]) |
| 123 | 154 |
| 124 try: | 155 try: |
| 125 subprocess.check_call(args) | 156 subprocess.check_call(args) |
| 126 except subprocess.CalledProcessError: | 157 except subprocess.CalledProcessError: |
| 127 buildbot_common.ErrorExit('Error running tests.') | 158 buildbot_common.ErrorExit('Error running tests.') |
| 128 | 159 |
| 129 | 160 |
| 130 def main(args): | 161 def main(args): |
| 131 usage = '%prog [<options>] [<phase...>]' | 162 usage = '%prog [<options>] [<phase...>]' |
| 132 parser = optparse.OptionParser(description=__doc__, usage=usage) | 163 parser = optparse.OptionParser(description=__doc__, usage=usage) |
| 133 parser.add_option('--experimental', help='build experimental tests', | 164 parser.add_option('--experimental', help='build experimental tests', |
| 134 action='store_true') | 165 action='store_true') |
| 166 parser.add_option('--sanitiser', | |
|
binji
2014/06/04 23:28:10
include american spelling too? :) (it matches clan
Sam Clegg
2014/06/04 23:46:16
Done.
| |
| 167 help='Run sanitiser (asan/tsan/valgrind) tests', | |
| 168 action='store_true') | |
| 135 parser.add_option('--verbose', '-v', help='Verbose output', | 169 parser.add_option('--verbose', '-v', help='Verbose output', |
| 136 action='store_true') | 170 action='store_true') |
| 137 | 171 |
| 138 if 'NACL_SDK_ROOT' in os.environ: | 172 if 'NACL_SDK_ROOT' in os.environ: |
| 139 # We don't want the currently configured NACL_SDK_ROOT to have any effect | 173 # We don't want the currently configured NACL_SDK_ROOT to have any effect |
| 140 # of the build. | 174 # of the build. |
| 141 del os.environ['NACL_SDK_ROOT'] | 175 del os.environ['NACL_SDK_ROOT'] |
| 142 | 176 |
| 143 # To setup bash completion for this command first install optcomplete | 177 # To setup bash completion for this command first install optcomplete |
| 144 # and then add this line to your .bashrc: | 178 # and then add this line to your .bashrc: |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 156 toolchains = ['newlib', 'glibc', 'pnacl'] | 190 toolchains = ['newlib', 'glibc', 'pnacl'] |
| 157 toolchains.append(getos.GetPlatform()) | 191 toolchains.append(getos.GetPlatform()) |
| 158 | 192 |
| 159 if options.verbose: | 193 if options.verbose: |
| 160 build_projects.verbose = True | 194 build_projects.verbose = True |
| 161 | 195 |
| 162 phases = [ | 196 phases = [ |
| 163 ('build_examples', StepBuildExamples, pepperdir), | 197 ('build_examples', StepBuildExamples, pepperdir), |
| 164 ('copy_tests', StepCopyTests, pepperdir, toolchains, options.experimental), | 198 ('copy_tests', StepCopyTests, pepperdir, toolchains, options.experimental), |
| 165 ('build_tests', StepBuildTests, pepperdir), | 199 ('build_tests', StepBuildTests, pepperdir), |
| 166 ('sel_ldr_tests', StepRunSelLdrTests, pepperdir), | 200 ('sel_ldr_tests', StepRunSelLdrTests, pepperdir, False), |
|
binji
2014/06/04 23:28:10
StepRunSelLdrTests checks for None above
Sam Clegg
2014/06/04 23:46:16
Done.
| |
| 167 ('browser_tests', StepRunBrowserTests, toolchains, options.experimental), | 201 ('browser_tests', StepRunBrowserTests, toolchains, options.experimental), |
| 168 ] | 202 ] |
| 169 | 203 |
| 204 if options.sanitiser: | |
| 205 if getos.GetPlatform() != 'linux': | |
| 206 buildbot_common.ErrorExit('sanitiser tests only run on linux.') | |
| 207 phases = [ | |
| 208 ('copy_tests', StepCopyTests, pepperdir, toolchains, options.experimental), | |
|
binji
2014/06/04 23:28:10
nit: indent
Sam Clegg
2014/06/04 23:46:16
Done.
| |
| 209 ('sel_ldr_tests_asan', StepRunSelLdrTests, pepperdir, 'address'), | |
| 210 ('sel_ldr_tests_tsan', StepRunSelLdrTests, pepperdir, 'thread'), | |
| 211 ('sel_ldr_tests_valgrind', StepRunSelLdrTests, pepperdir, 'valgrind') | |
| 212 ] | |
| 213 | |
| 170 if args: | 214 if args: |
| 171 phase_names = [p[0] for p in phases] | 215 phase_names = [p[0] for p in phases] |
| 172 for arg in args: | 216 for arg in args: |
| 173 if arg not in phase_names: | 217 if arg not in phase_names: |
| 174 msg = 'Invalid argument: %s\n' % arg | 218 msg = 'Invalid argument: %s\n' % arg |
| 175 msg += 'Possible arguments:\n' | 219 msg += 'Possible arguments:\n' |
| 176 for name in phase_names: | 220 for name in phase_names: |
| 177 msg += ' %s\n' % name | 221 msg += ' %s\n' % name |
| 178 parser.error(msg.strip()) | 222 parser.error(msg.strip()) |
| 179 | 223 |
| 180 for phase in phases: | 224 for phase in phases: |
| 181 phase_name = phase[0] | 225 phase_name = phase[0] |
| 182 if args and phase_name not in args: | 226 if args and phase_name not in args: |
| 183 continue | 227 continue |
| 184 phase_func = phase[1] | 228 phase_func = phase[1] |
| 185 phase_args = phase[2:] | 229 phase_args = phase[2:] |
| 186 phase_func(*phase_args) | 230 phase_func(*phase_args) |
| 187 | 231 |
| 188 return 0 | 232 return 0 |
| 189 | 233 |
| 190 | 234 |
| 191 if __name__ == '__main__': | 235 if __name__ == '__main__': |
| 192 try: | 236 try: |
| 193 sys.exit(main(sys.argv)) | 237 sys.exit(main(sys.argv)) |
| 194 except KeyboardInterrupt: | 238 except KeyboardInterrupt: |
| 195 buildbot_common.ErrorExit('test_sdk: interrupted') | 239 buildbot_common.ErrorExit('test_sdk: interrupted') |
| OLD | NEW |