aboutsummaryrefslogtreecommitdiffstats
path: root/asn1c/check-parsing.sh
blob: d4de33971027b12bc53224f4ecffa10248c08a02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh

# Test diff(1) capabilities
diff -a . . 2>/dev/null && diffArgs="-a"		# Assume text files
diff -u . . 2>/dev/null && diffArgs="$diffArgs -u"	# Unified diff output

ec=0

set -e

PROCESSING=""
print_status() {
    echo "Error while processing $PROCESSING"
}

trap print_status EXIT

if [ "x${top_srcdir}" = "x" ]; then
  top_srcdir=".."
fi

for ref in ${top_srcdir}/tests/*.asn1.-*; do
	# Figure out the initial source file used to generate this output.
	src=`echo "$ref" | sed -e 's/\.-[-a-zA-Z0-9=]*$//'`
	# Figure out compiler flags used to create the file.
	flags=`echo "$ref" | sed -e 's/.*\.-//'`
	echo "Checking $src against $ref"
	template=.tmp.check-parsing.$$
	oldversion=${template}.old
	newversion=${template}.new
	PROCESSING="$ref (from $src)"
	cat "$ref" | LANG=C sed -e 's/^found in .*/found in .../' > $oldversion
	(./asn1c -S ${top_srcdir}/skeletons "-$flags" "$src" | LANG=C sed -e 's/^found in .*/found in .../' > "$newversion") || ec=$?
	if [ $? = 0 ]; then
		diff $diffArgs "$oldversion" "$newversion" || ec=$?
	fi
	rm -f $oldversion $newversion
	if [ "$1" = "regenerate" ]; then
		./asn1c -S ${top_srcdir}/skeletons "-$flags" "$src" > "$ref"
	fi
done

if [ $ec = 0 ]; then
    trap '' EXIT
fi

exit $ec