2 # xorn.geda.netlist - gEDA Netlist Extraction and Generation
3 # Copyright (C) 1998-2010 Ales Hvezda
4 # Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
5 # Copyright (C) 2013-2017 Roland Lutz
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 srcsubdir
=`dirname "${reference}"`
23 basename=`basename "${reference}"`
24 stem
="${basename%%-*.out}"
25 rel_subdir
="${srcsubdir#${srcdir%/}}"
26 if [ "${rel_subdir}" = "${srcsubdir}" ]
28 echo "ERROR: Test is not in source directory"
31 buildsubdir
="${builddir}${rel_subdir}"
34 input
="${srcsubdir}/${stem}.sch"
35 source_library
="${srcsubdir}/${stem}-sources"
36 symbol_library
="${srcsubdir}/${stem}-symbols"
37 extradir
="${srcsubdir}/${stem}-extras"
40 output
="${buildsubdir}/${basename%.out}.new"
42 backend_tmp
="${basename#*-}"
43 backend
="${backend_tmp%.out}"
49 backend_options
="-O foo -O bar"
59 backend_options
="-O nomunge_mode"
63 backend_options
="-O include_mode"
65 spice_sdb-include-nomunge
)
67 backend_options
="-O include_mode -O nomunge_mode"
71 backend_options
="-O sort_mode"
73 spice_sdb-sort-nomunge
)
75 backend_options
="-O sort_mode -O nomunge_mode"
78 # The vams backend will always write to this file regardless of
79 # the `-o' setting. This is not thread-safe.
80 output
=default_entity_arc.net
84 # Create symlink to directory with auxiliary files
85 [ -d "${extradir}" ] && ln -s "${extradir}" .
2>/dev
/null
87 # Write configuration file
88 pre_backend_scm
="${buildsubdir}/${basename%.out}.scm"
90 [ -d "${source_library}" ] &&
91 echo "(source-library \"${source_library}\")"
92 [ -d "${symbol_library}" ] &&
93 echo "(component-library \"${symbol_library}\")"
94 } > "${pre_backend_scm}"
96 gnetlist
-l "${pre_backend_scm}" \
97 -o "${output}" -g "${backend}" ${backend_options} "${input}"
99 rm "${pre_backend_scm}"
100 [ "$status" = 0 ] ||
exit 1
102 # Compare netlist with reference file
104 spice-noqsi|spice-sdb
)
105 # Strip invocation line
106 reference_filtered
="${buildsubdir}/${basename}.filtered"
107 sed '/netlist.*-g/d' "${reference}" > "${reference_filtered}"
108 sed '/netlist.*-g/d' "${output}" > "${output}.filtered"
109 diff "${reference_filtered}" "${output}.filtered"
111 rm "${reference_filtered}" "${output}.filtered"
114 diff "${reference}" "${output}"
118 [ "$status" = 0 ] ||
exit 2