Merge pull request #3263 from YosysHQ/micko/clk2ff_init
[yosys.git] / tests / opt_share / run-test.sh
1 #!/bin/bash
2
3 # run this test many times:
4 # time bash -c 'for ((i=0; i<100; i++)); do echo "-- $i --"; bash run-test.sh || exit 1; done'
5
6 set -e
7
8 OPTIND=1
9 count=100
10 seed="" # default to no seed specified
11 while getopts "c:S:" opt
12 do
13 case "$opt" in
14 c) count="$OPTARG" ;;
15 S) seed="-S $OPTARG" ;;
16 esac
17 done
18 shift "$((OPTIND-1))"
19
20 rm -rf temp
21 mkdir -p temp
22 echo "generating tests.."
23 python3 generate.py -c $count $seed
24
25 {
26 echo ".PHONY: all"
27 echo "all:"
28
29 for i in $( ls temp/*.ys | sed 's,[^0-9],,g; s,^0*\(.\),\1,g;' ); do
30 idx=$( printf "%05d" $i )
31 echo ".PHONY: test-$idx"
32 echo "all: test-$idx"
33 echo "test-$idx:"
34 printf "\t@%s\n" \
35 "echo -n [$i]" \
36 "../../yosys -ql temp/uut_${idx}.log temp/uut_${idx}.ys"
37 done
38 } > temp/makefile
39
40 echo "running tests.."
41 ${MAKE:-make} -f temp/makefile
42 echo
43
44 failed_share=$( echo $( gawk '/^#job#/ { j=$2; db[j]=0; } /^Removing [246] cells/ { delete db[j]; } END { for (j in db) print(j); }' temp/all_share_log.txt ) )
45 if [ -n "$failed_share" ]; then
46 echo "Resource sharing failed for the following test cases: $failed_share"
47 false
48 fi
49
50 exit 0