missing NULL terminator in set_config_x
[geda-gaf.git] / gnetlist-legacy / tests / run-test
blob2dbd6c9d5b1640ce3f6b9271d00640da1a92b0e8
1 #!/bin/sh
3 ref="$1"
4 tmp="`echo "x$1" | sed -e 's:.*/tests/::' -e 's:\\.out$::' -e 's:^x\\./::'`"
5 stem="`echo "${tmp}" | sed -E -e 's:-spice-.*:@@@:' -e 's:(-[^-@]*|@@@)$::'`"
6 backend="`echo "${tmp}" | sed -e "s:^${stem}-::"`"
8 GNETLIST="${abs_top_builddir}/gnetlist-legacy/src/gnetlist-legacy"
9 GEDADATA="${abs_top_srcdir}/gnetlist-legacy" # HACKHACKHACK
10 GEDADATARC="${abs_top_builddir}/gnetlist-legacy/lib"
11 GEDALOG="."
12 export GEDADATA
13 export GEDADATARC
14 export GEDALOG
16 schematic="${abs_srcdir}/${stem}.sch"
18 rundir="run.$$"
20 # create temporary run directory
21 mkdir -p "${rundir}"
23 # Create the files needed
24 if test -d "${srcdir}/${stem}-extras" ; then
25 for f in "${srcdir}/${stem}-extras"/* ; do
26 cp "${f}" "${rundir}/"
27 done
30 (echo refdes; echo value; echo device) > "${rundir}/attribs"
32 cat > "${rundir}/gafrc" << EOF
33 ;; We want to point at the scheme code that hasn't been installed yet so that
34 ;; 'make check' during development can work correctly.
35 (scheme-directory "${abs_top_srcdir}/gnetlist-legacy/scheme")
36 (scheme-directory "${abs_top_builddir}/gnetlist-legacy/scheme")
37 (scheme-directory "${abs_top_srcdir}/libgeda/scheme")
38 (scheme-directory "${abs_top_builddir}/libgeda/scheme")
40 ;; We want to use the symbols that haven't been installed yet
41 (map (lambda (x)
42 (component-library
43 (string-join (list "${abs_top_srcdir}/symbols/" x) "")))
44 '("io" "74" "analog" "power" "misc" "diode" "linear" "connector" "switch"
45 "asic" "spice" "cascade" "titleblock" "memory"))
47 ;; Rather than checking what m4 and pcb's m4 files do with
48 ;; the output we produce, just see what output gnetlist-legacy produces.
49 (define gsch2pcb:pcb-m4-command-line "cat - >>")
50 EOF
52 if test -d "${srcdir}/${stem}-symbols" ; then
53 cat >> "${rundir}/gafrc" << EOF
54 (component-library "${abs_srcdir}/${stem}-symbols")
55 EOF
57 if test -d "${srcdir}/${stem}-sources" ; then
58 cat >> "${rundir}/gafrc" << EOF
59 (source-library "${abs_srcdir}/${stem}-sources")
60 EOF
63 args=
64 case "${backend}" in
65 spice-sdb-nomunge)
66 backend=spice-sdb
67 args="-O nomunge_mode"
69 spice-sdb-include)
70 backend=spice-sdb
71 args="-O include_mode"
73 spice-sdb-include-nomunge)
74 backend=spice-sdb
75 args="-O include_mode -O nomunge_mode"
77 spice-sdb-sort)
78 backend=spice-sdb
79 args="-O sort_mode"
81 spice-sdb-sort-nomunge)
82 backend=spice-sdb
83 args="-O sort_mode -O nomunge_mode"
85 esac
87 # run gnetlist-legacy
88 echo "${GNETLIST} -g ${backend} ${args} ${schematic}"
89 (cd "${rundir}" && "${GNETLIST}" -g "${backend}" ${args} "${schematic}")
90 rc1=$?
92 echo "${GNETLIST} -g ${backend} -o - ${args} ${schematic} > stdout.net"
93 (cd "${rundir}" && "${GNETLIST}" -g "${backend}" \
94 -o - ${args} "${schematic}" > stdout.net)
95 rc2=$?
97 echo "${GNETLIST} -g ${backend} -v -o verbose.net ${args} ${schematic}"
98 (cd "${rundir}" && "${GNETLIST}" -g "${backend}" -v \
99 -o verbose.net ${args} "${schematic}")
100 rc3=$?
102 # OK, now check results of run.
103 status=99
105 out="${rundir}/output.net"
106 std="${rundir}/stdout.net"
107 vrb="${rundir}/verbose.net"
109 # Hack to help with vams backend
110 if [ -f "${rundir}/default_entity_arc.net" ]; then
111 mv "${rundir}/default_entity_arc.net" "${out}"
112 # vams intentionally outputs data into several files, so checking it with
113 # the option '-o verbose.net' is nonsense
114 cp "${out}" "${vrb}"
117 if test "X${REGEN}" = "X1" ; then
118 # copy output on top of golden output
119 cp "${out}" "${ref}"
120 echo "Regenerated ${ref}"
121 status=0
122 elif test ${rc1} -ne 0 ; then
123 echo "FAILED: gnetlist-legacy -g ${backend} returned ${rc1}"
124 status=1
125 elif test ${rc2} -ne 0 ; then
126 echo "FAILED: gnetlist-legacy -g ${backend} -o - returned ${rc2}"
127 status=1
128 elif test ${rc3} -ne 0 ; then
129 echo "FAILED: gnetlist-legacy -g ${backend} -v returned ${rc3}"
130 status=1
131 else
132 sed '/gnetlist -g/d' "${ref}" > "${out}.tmp1"
133 sed '/gnetlist-legacy -g/d' "${out}" > "${out}.tmp2"
134 sed '/gnetlist-legacy -g/d' "${std}" > "${out}.tmp3"
135 sed '/gnetlist-legacy -g/d' "${vrb}" > "${out}.tmp4"
137 # Hack to help with allegro backend
138 # Device files are ignored as yet
139 if test "X${backend}" = "Xallegro" ; then
140 sed '/gnetlist-legacy -g/d' "${std}" | sed '/^\$END$/ q' > "${out}.tmp3"
143 if ! diff "${out}.tmp1" "${out}.tmp2" >/dev/null; then
144 echo "FAILED: Wrong plain output. See diff ${ref} ${out}"
145 status=1
146 elif ! diff "${out}.tmp1" "${out}.tmp3" >/dev/null; then
147 echo "FAILED: Wrong stdout output. See diff ${ref} ${std}"
148 status=1
149 elif ! diff "${out}.tmp1" "${out}.tmp4" >/dev/null; then
150 echo "FAILED: Wrong verbose output. See diff ${ref} ${vrb}"
151 status=1
152 else
153 echo "PASS"
154 status=0
158 # Delete the run directory in prep for the next test
159 rm -fr "${rundir}"
161 exit ${status}