diff --git a/action.sh b/action.sh index 198f278b5..fc35ea781 100755 --- a/action.sh +++ b/action.sh @@ -28,7 +28,8 @@ case $cmd in kasan) ./run_tests.py --board $board --timeout=100 --times=50 --suite=$1 ;; kcsan) - ./run_tests.py --board $board --timeout=100 --times=50 --suite=$1 + ./run_tests.py --board $board --timeout=100 --times=50 --suite=$1 \ + --parallel=5 # do not report it as failed because we have no people working on # fixing concurrency issues exit 0 ;; diff --git a/run_tests.py b/run_tests.py index fae371f0b..4b29e8368 100755 --- a/run_tests.py +++ b/run_tests.py @@ -24,17 +24,19 @@ def setup_terminal(): subprocess.run(['stty', 'cols', str(cols), 'rows', str(rows)]) -def run_test(seed, board, timeout, suite=None): - print("Testing seed %u..." % seed) +def run_test(seed, board, timeout, parallel, suite=None): + print('Testing seed %u...' % seed) + + args = ['%s=all' % suite, 'seed=%u' % seed, 'repeat=%d' % REPEAT, + 'parallel=%d' % parallel] try: launch = subprocess.Popen( - ['./launch', '--board', board, '-t', '--timeout=%d' % timeout, - '%s=all' % suite, 'seed=%u' % seed, 'repeat=%d' % REPEAT]) + ['./launch', '-b', board, '-t', '-T', str(timeout)] + args) rc = launch.wait() if rc: - print("Run `launch -d -b %s %s=all seed=%u repeat=%u` " - "to reproduce the failure." % (board, suite, seed, REPEAT)) + print('Run `launch -d -b %s %s` to reproduce the failure.' % + (board, ' '.join(args))) sys.exit(rc) except KeyboardInterrupt: launch.send_signal(signal.SIGINT) @@ -51,6 +53,8 @@ def run_test(seed, board, timeout, suite=None): parser.add_argument('-b', '--board', default='rpi3', choices=['malta', 'rpi3', 'sifive_u'], help='Emulated board.') + parser.add_argument('-p', '--parallel', type=int, default=1, + help='Run at most N tests in parallel.') parser.add_argument('-s', '--suite', default='all', choices=['all', 'user', 'kernel'], help='Test suite to run.') @@ -61,13 +65,10 @@ def run_test(seed, board, timeout, suite=None): # Run tests using n random seeds for _ in range(0, args.times): rand = random.randint(0, 2**32) - if args.suite == 'all': - run_test(rand, args.board, args.timeout, 'ktest') - run_test(rand, args.board, args.timeout, 'utest') - elif args.suite == 'kernel': - run_test(rand, args.board, args.timeout, 'ktest') - elif args.suite == 'user': - run_test(rand, args.board, args.timeout, 'utest') - - print("Tests successful!") + if args.suite in ['all', 'kernel']: + run_test(rand, args.board, args.timeout, args.parallel, 'ktest') + if args.suite in ['all', 'user']: + run_test(rand, args.board, args.timeout, args.parallel, 'utest') + + print('Tests successful!') sys.exit(0)