Skip to content

Commit

Permalink
Run userspace tests in parallel for KCSAN build.
Browse files Browse the repository at this point in the history
  • Loading branch information
cahirwpz committed Aug 1, 2023
1 parent 506826b commit 54e8f9d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
3 changes: 2 additions & 1 deletion action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;;
Expand Down
31 changes: 16 additions & 15 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.')
Expand All @@ -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)

0 comments on commit 54e8f9d

Please sign in to comment.