NativeEnumerated.c vars NULL init and check
[com/asn1c.git] / tests / tests-asn1c-compiler / check-parsing.sh
1 #!/bin/sh
2
3 # Test diff(1) capabilities
4 diff -a . . 2>/dev/null && diffArgs="-a"                # Assume text files
5 diff -u . . 2>/dev/null && diffArgs="$diffArgs -u"      # Unified diff output
6
7 ec=0
8
9 if [ "$1" != "regenerate" ]; then
10     set -e
11 fi
12
13 PROCESSING=""
14 print_status() {
15     echo "Error while processing $PROCESSING"
16 }
17
18 trap print_status EXIT
19
20 top_srcdir="${top_srcdir:-../..}"
21 top_builddir="${top_builddir:-../..}"
22
23 for ref in ${top_srcdir}/tests/tests-asn1c-compiler/*.asn1.-*; do
24         # Figure out the initial source file used to generate this output.
25         src=$(echo "$ref" | sed -e 's/\.-[-a-zA-Z0-9=]*$//')
26         # Figure out compiler flags used to create the file.
27         flags=$(echo "$ref" | sed -e 's/.*\.-//')
28         echo "Checking $src against $ref"
29         template=.tmp.check-parsing.$$
30         oldversion=${template}.old
31         newversion=${template}.new
32         PROCESSING="$ref (from $src)"
33         LANG=C sed -e 's/^found in .*/found in .../' < "$ref" > "$oldversion"
34         (${top_builddir}/asn1c/asn1c -S ${top_srcdir}/skeletons -no-gen-OER -no-gen-PER "-$flags" "$src" | LANG=C sed -e 's/^found in .*/found in .../' > "$newversion") || ec=$?
35         if [ $? = 0 ]; then
36                 diff $diffArgs "$oldversion" "$newversion" || ec=$?
37         fi
38         rm -f $oldversion $newversion
39         if [ "$1" = "regenerate" ]; then
40                 ${top_builddir}/asn1c/asn1c -S ${top_srcdir}/skeletons -no-gen-OER -no-gen-PER "-$flags" "$src" > "$ref"
41         fi
42 done
43
44 if [ $ec = 0 ]; then
45     trap '' EXIT
46 fi
47
48 exit $ec