diff options
author | Eric Smith <brouhaha@fedoraproject.org> | 2016-09-15 02:00:29 -0600 |
---|---|---|
committer | Eric Smith <brouhaha@fedoraproject.org> | 2016-09-22 11:49:29 -0600 |
commit | f4240cc8a4545e4d2e2f926a72aa911d5373ab95 (patch) | |
tree | 079778a42eff4da887b65b46e261fd96a28e62b0 /tests/fsm | |
parent | d8ad889594cb5746d3d0b1f7590eeaf63d13c64a (diff) | |
download | yosys-f4240cc8a4545e4d2e2f926a72aa911d5373ab95.tar.gz yosys-f4240cc8a4545e4d2e2f926a72aa911d5373ab95.tar.bz2 yosys-f4240cc8a4545e4d2e2f926a72aa911d5373ab95.zip |
Add optional SEED=n command line option to Makefile, and -S n command line option to test scripts, for deterministic regression tests.
Diffstat (limited to 'tests/fsm')
-rw-r--r-- | tests/fsm/generate.py | 12 | ||||
-rwxr-xr-x | tests/fsm/run-test.sh | 14 |
2 files changed, 24 insertions, 2 deletions
diff --git a/tests/fsm/generate.py b/tests/fsm/generate.py index 8757d4741..c8eda0cd1 100644 --- a/tests/fsm/generate.py +++ b/tests/fsm/generate.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import argparse import sys import random from contextlib import contextmanager @@ -30,7 +31,16 @@ def random_expr(variables): return "%d'd%s" % (bits, random.randint(0, 2**bits-1)) raise AssertionError -for idx in range(50): +parser = argparse.ArgumentParser(formatter_class = argparse.ArgumentDefaultsHelpFormatter) +parser.add_argument('-S', '--seed', type = int, help = 'seed for PRNG') +parser.add_argument('-c', '--count', type = int, default = 50, help = 'number of test cases to generate') +args = parser.parse_args() + +if args.seed is not None: + print("PRNG seed: %d" % args.seed) + random.seed(args.seed) + +for idx in range(args.count): with open('temp/uut_%05d.v' % idx, 'w') as f: with redirect_stdout(f): rst2 = random.choice([False, True]) diff --git a/tests/fsm/run-test.sh b/tests/fsm/run-test.sh index 423892334..cf506470d 100755 --- a/tests/fsm/run-test.sh +++ b/tests/fsm/run-test.sh @@ -5,10 +5,22 @@ set -e +OPTIND=1 +count=100 +seed="" # default to no seed specified +while getopts "c:S:" opt +do + case "$opt" in + c) count="$OPTARG" ;; + S) seed="-S $OPTARG" ;; + esac +done +shift "$((OPTIND-1))" + rm -rf temp mkdir -p temp echo "generating tests.." -python3 generate.py +python3 generate.py -c $count $seed { all_targets="all_targets:" |