summaryrefslogtreecommitdiff
path: root/tests/share
diff options
context:
space:
mode:
Diffstat (limited to 'tests/share')
-rw-r--r--tests/share/generate.py12
-rwxr-xr-xtests/share/run-test.sh14
2 files changed, 24 insertions, 2 deletions
diff --git a/tests/share/generate.py b/tests/share/generate.py
index 01a19a8d..7e87bd64 100644
--- a/tests/share/generate.py
+++ b/tests/share/generate.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
+import argparse
import sys
import random
from contextlib import contextmanager
@@ -21,7 +22,16 @@ def maybe_plus_x(expr):
else:
return expr
-for idx in range(100):
+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 = 100, 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):
if random.choice(['bin', 'uni']) == 'bin':
diff --git a/tests/share/run-test.sh b/tests/share/run-test.sh
index 18dbbc27..1bcd8e42 100755
--- a/tests/share/run-test.sh
+++ b/tests/share/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
echo "running tests.."
for i in $( ls temp/*.ys | sed 's,[^0-9],,g; s,^0*\(.\),\1,g;' ); do