blob: ee61f3348494f392ff686d13c94b55525d26c07a [file] [log] [blame]
Nicolas Nobleddef2462015-01-06 18:08:25 -08001#!/usr/bin/python
2"""Run tests in parallel."""
3
4import argparse
5import glob
6import itertools
7import multiprocessing
8import sys
9
10import jobset
11
12# flags required for make for each configuration
13_CONFIGS = ['dbg', 'opt', 'tsan', 'msan', 'asan']
14
15# parse command line
16argp = argparse.ArgumentParser(description='Run grpc tests.')
17argp.add_argument('-c', '--config',
18 choices=['all'] + _CONFIGS,
19 nargs='+',
20 default=['all'])
21argp.add_argument('-t', '--test-filter', nargs='*', default=['*'])
22argp.add_argument('-n', '--runs_per_test', default=1, type=int)
23args = argp.parse_args()
24
25# grab config
26configs = [cfg
27 for cfg in itertools.chain.from_iterable(
28 _CONFIGS if x == 'all' else [x]
29 for x in args.config)]
30filters = args.test_filter
31runs_per_test = args.runs_per_test
32
33# build latest, sharing cpu between the various makes
34if not jobset.run(
35 ['make',
36 '-j', '%d' % max(multiprocessing.cpu_count() / len(configs), 1),
37 'buildtests_c',
38 'CONFIG=%s' % cfg]
39 for cfg in configs):
40 sys.exit(1)
41
42# run all the tests
43jobset.run([x]
44 for x in itertools.chain.from_iterable(
45 itertools.chain.from_iterable(itertools.repeat(
46 glob.glob('bins/%s/%s_test' % (config, filt)),
47 runs_per_test))
48 for config in configs
49 for filt in filters))