blob: d909af2ca5006a9b4504aca7d3dab32b28313490 [file] [log] [blame]
Lev Walkin30566d12017-11-12 15:27:36 -08001#!/usr/bin/env bash
2
3set -x
4set -e
5set -o pipefail
6
7top_builddir=${top_builddir:-../..}
8top_srcdir=${top_srcdir:-../..}
9
10cleanup() {
11 rm -rf *.[cho] Makefile.am.* *.txt *.asn
12 rm -f converter-example
13}
14
15print_state() {
16 local err=$?
17 set +x
18 set +e
19 trap "" EXIT ERR
20 echo "Error $err while processing:"
21 cat test.asn
22 cat status.txt
23 echo "FAILED"
24 exit $err
25}
26
27verify() {
28 local type="$1"
29 local flags="$2"
30
31 cleanup
32
33 asncmd="${top_builddir}/asn1c/asn1c -flink-skeletons -S ${top_srcdir}/skeletons $flags test.asn"
34
35 {
36 echo "$asncmd"
37 echo "${MAKE:-make} -f Makefile.am.example"
38 } > status.txt
39
40 echo "Module DEFINITIONS::=BEGIN T::=$type END" > test.asn
41 $asncmd
42 CFLAGS=-O0 ${MAKE:-make} -f Makefile.am.example | tail -10
43}
44
45verify_type_with_variants() {
46 local type="$1"
47 for flags in "-no-gen-PER" "-no-gen-OER" "-no-gen-PER -no-gen-OER" ""; do
48 for native in "" "-fwide-types"; do
49 verify "$type" "$flags $native"
50 done
51 done
52}
53
54verify_compile_and_link_variants() {
55 for type in INTEGER "ENUMERATED{foo}" NULL BOOLEAN "BIT STRING" \
56 "OBJECT IDENTIFIER" "RELATIVE-OID" "SEQUENCE{f INTEGER}" \
57 "CHOICE{f INTEGER}" "OCTET STRING" IA5String UTF8String \
58 REAL "SET OF INTEGER" "SEQUENCE OF INTEGER"; do
59 verify_type_with_variants "$type"
60
61 done
62}
63
64trap print_state EXIT ERR
65if [ "x$*" = "x" ]; then
66 verify_compile_and_link_variants
67else
68 for type in "$@"; do
69 verify_type_with_variants "$type"
70 done
71fi
72trap '' EXIT ERR
73
74cleanup