blob: 54edce334390bc0dda9488dd8628ef9a29ad7631 [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() {
Lev Walkine7bd48a2017-11-13 23:12:49 -080011 rm -rf *.[acho] Makefile.am.* *.txt *.asn
Lev Walkin30566d12017-11-12 15:27:36 -080012 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
Lev Walkin7d5d9302017-11-13 22:17:20 -080033 asncmd="${top_builddir}/asn1c/asn1c -Wdebug-compiler -flink-skeletons -S ${top_srcdir}/skeletons $flags test.asn"
Lev Walkin30566d12017-11-12 15:27:36 -080034
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() {
Lev Walkin7d5d9302017-11-13 22:17:20 -080055 for type in INTEGER "INTEGER(0..1)" "ENUMERATED{foo}" NULL BOOLEAN \
56 "BIT STRING" \
57 "OBJECT IDENTIFIER" "RELATIVE-OID" \
58 "SEQUENCE{f INTEGER}" \
59 "CHOICE{f INTEGER}" \
60 "OCTET STRING" IA5String "IA5String(SIZE(1))" UTF8String \
Lev Walkin30566d12017-11-12 15:27:36 -080061 REAL "SET OF INTEGER" "SEQUENCE OF INTEGER"; do
62 verify_type_with_variants "$type"
Lev Walkin30566d12017-11-12 15:27:36 -080063 done
64}
65
66trap print_state EXIT ERR
67if [ "x$*" = "x" ]; then
68 verify_compile_and_link_variants
69else
70 for type in "$@"; do
71 verify_type_with_variants "$type"
72 done
73fi
Lev Walkin7d5d9302017-11-13 22:17:20 -080074set +x
Lev Walkin30566d12017-11-12 15:27:36 -080075trap '' EXIT ERR
76
77cleanup
Lev Walkin7d5d9302017-11-13 22:17:20 -080078echo "OK"