3 # This script runs the tests called out for in test.list
11 $0 -- Testsuite program for various backends
16 $0 [-r | --regen] <backend> [test1 [test2 [....]]]
20 -h | --help Prints this help message and exits.
22 -r | --regen Regenerates the reference files. If you use
23 this option, YOU MUST HAND VERIFY THE RESULTS
24 BEFORE COMMITTING to the repository.
28 $0 reads a file, tests.list, describing tests to run on <backend>.
29 If no specific test is specified on the $0 command line, then all
35 $0 --regen new_test spice-sdb
50 # regenerate the 'golden' output files. Use this with caution.
51 # In particular, all differences should be noted and understood.
57 echo "unknown option: $1"
77 echo "********USING BACKEND ${backend}*********"
79 # make sure we have the right paths when running this from inside the
80 # source tree and also from outside the source tree.
82 srcdir
=${srcdir:-$here}
83 srcdir
=`cd $srcdir && pwd`
85 GNETLIST
=..
/..
/..
/src
/gnetlist
89 GOLDEN_DIR
=${srcdir}/outputs
/${backend}
90 INPUT_DIR
=${srcdir}/inputs
92 TESTLIST
=${srcdir}/tests.list
93 ALWAYSCOPYLIST
=${srcdir}/always-copy.list
95 if test ! -f $TESTLIST ; then
96 echo "ERROR: ($0) Test list $TESTLIST does not exist"
100 # fail/pass/total counts
106 # here's where we look at the test.list file and extract the names of all
107 # the tests we want to run.
108 if test -z "$1" ; then
109 all_tests
=`awk 'BEGIN{FS="|"} /^#/{next} /^[ \t]*$/{next} {print $1}' $TESTLIST | sed 's; ;;g'`
113 echo All tests
= $all_tests
115 # here's where we look at always-copy.list file and extract the names of all
116 # the extra files we want to copy for every test
117 always_copy
=`cat $ALWAYSCOPYLIST | sed '/^#/d'`
121 Starting tests in $here
123 INPUT_DIR: ${INPUT_DIR}
124 GOLDEN_DIR: ${GOLDEN_DIR}
125 GNETLIST: ${GNETLIST}
132 # Now run through all tests in test.list, prepare the $rundir,
133 # then run the tests.
134 for t
in $all_tests ; do
136 # strip any leading garbage
137 t
=`echo $t | sed 's;^\*;;g'`
139 # figure out what files we need to copy for this test and what
140 # arguments to feed gnetlist
141 schematics
=`grep "^[ \t]*${t}[ \t]*|" $TESTLIST | awk 'BEGIN{FS="|"} {print $2}'`
142 auxfiles
=`grep "^[ \t]*${t}[ \t]*|" $TESTLIST | awk 'BEGIN{FS="|"} {print $3}'`
143 args
=`grep "^[ \t]*${t}[ \t]*|" $TESTLIST | awk 'BEGIN{FS="|"} {print $4}'`
144 condition
=`grep "^[ \t]*${t}[ \t]*|" $TESTLIST | awk 'BEGIN{FS="|"} {print $5}' | sed 's; ;;g'`
146 refcode
=${GOLDEN_DIR}/${t}.retcode
147 if test -f $refcode; then
148 code
=`grep -v "^#" $refcode | sed 's; ;;g;'`
152 if test "X$code" = "X" ; then
156 echo "Schematics to copy = $schematics"
157 echo "Args to copy = $args"
158 echo "Always copying = $always_copy"
159 echo "Expected return code = \"$code\""
160 if test "X$condition" != "X" ; then
161 eval "ctest=\`echo \$$condition\`"
162 if test X
$ctest = "Xyes" ; then
163 echo "Running test because $condition = yes"
165 echo "Skipping test because $condition = $ctest"
172 # create temporary run directory and required subdirs
173 if test ! -d $rundir ; then
176 mkdir
-p $rundir/models
179 # Create the files needed
180 # Note that we need to include not only the .sch files,
181 # but also the contents of the sym and model directories.
182 if test ! -z "$schematics" ; then
183 echo "Copying over schematics to run dir"
184 for f
in $schematics ; do
185 echo "cp ${INPUT_DIR}/${f} ${rundir}/${f}"
186 cp ${INPUT_DIR}/${f} ${rundir}/${f}
187 chmod 644 ${rundir}/${f}
190 if test ! -z "$auxfiles" ; then
191 echo "Copying over aux files to run dir"
192 for f
in $auxfiles ; do
193 echo "cp ${INPUT_DIR}/${f} ${rundir}/${f}"
194 cp ${INPUT_DIR}/${f} ${rundir}/${f}
195 chmod 644 ${rundir}/${f}
198 if test ! -z "$always_copy" ; then
199 echo "Copying over always copied files to run dir"
200 for f
in $always_copy ; do
201 echo "cp ${INPUT_DIR}/${f} ${rundir}/${f}"
202 cp ${INPUT_DIR}/${f} ${rundir}/${f}
203 chmod 644 ${rundir}/${f}
207 # run gnetlist -g $backend
208 echo "${GNETLIST} -g $backend $args $schematics"
209 cd ${rundir} && ${GNETLIST} -g $backend $args $schematics
212 # OK, now check results of run.
217 ref
=${GOLDEN_DIR}/${t}-output.net
218 out
=${rundir}/output.net
220 # Hack to help with vams backend
221 if [ -f ${rundir}/default_entity_arc.net
]; then
222 mv ${rundir}/default_entity_arc.net
$out
225 if test "X$regen" = "Xyes" ; then
227 echo "$rc" > $refcode
228 echo "Regenerated ${ref}"
230 elif test $rc -ne $code ; then
231 echo "FAILED: gnetlist -g $backend returned $rc which did not match the expected $code"
233 elif test -f ${ref} ; then
235 sed '/gnetlist -g/d' ${ref} > ${out}.tmp1
236 sed '/gnetlist -g/d' ${out} > ${out}.tmp2
238 if diff -w ${out}.tmp1
${out}.tmp2
>/dev
/null
; then
242 echo "FAILED: See diff -w ${ref} ${out}"
245 elif test ! -f $out ; then
246 # No output file, but this is expected since there was no reference file
249 echo "No reference file. Skipping"
253 pass
=`expr $pass + $good`
254 fail
=`expr $fail + $bad`
255 skip
=`expr $skip + $soso`
259 # Delete the run directory in prep for the next test
264 echo "Passed $pass, failed $fail, skipped $skip out of $tot tests."
267 if test $pass -ne $tot ; then
268 rc
=`expr $tot - $pass`