blob: d3c7247b8a29ca90d0cd0c1264bb3eb90963bdbb [file] [log] [blame]
Lev Walkincb523912017-09-30 19:33:23 -07001#!/bin/sh
2
3#
4# Create an ASN.1 source code project for each line in each of the
5# bundles/*.txt files, compile and run that it can be encoded, decoded,
6# and fuzzed (if fuzzing is available).
7#
8
9set -e
10
Lev Walkincb523912017-09-30 19:33:23 -070011usage() {
12 echo "Usage:"
13 echo " $0 -h"
Lev Walkin93f372b2017-10-03 16:39:38 -070014 echo " $0 [--dirty] -t \"<ASN.1 text defining type T, in string form>\""
15 echo " $0 [--dirty] bundles/<bundle-name.txt> [<line>]"
Lev Walkin8cec5232017-10-03 15:05:54 -070016 echo "Where options are:"
Lev Walkin43292722017-10-05 00:33:32 -070017 echo " -h Show this help screen"
18 echo " -e <syntax> Verify a given encoding explicitly (default is ALL)"
19 echo " --asn1c <flag> Add this flag to asn1c"
20 echo " --dirty Reuse compile results from the previous run(s)"
21 echo " -t <ASN.1> Run this particular typel"
Lev Walkincb523912017-09-30 19:33:23 -070022 echo "Examples:"
23 echo " $0 -t UTF8String"
24 echo " $0 -t \"T ::= INTEGER (0..1)\""
25 echo " $0 bundles/01-INTEGER-bundle.txt 3"
26 exit 1
27}
28
Lev Walkin40b8a7a2017-10-08 22:36:29 -070029RNDTEMP="${RNDTEMP:-.tmp.random}"
Lev Walkind3cce462017-10-01 13:43:36 -070030
31srcdir="${srcdir:-.}"
Lev Walkin39936ce2017-10-05 23:56:39 -070032abs_top_srcdir="${abs_top_srcdir:-`pwd`/../../}"
33abs_top_builddir="${abs_top_builddir:-`pwd`/../../}"
Lev Walkind0d63922017-10-10 01:27:37 -070034MAKE="${MAKE:-make}"
35FUZZ_TIME="${FUZZ_TIME:-10}"
Lev Walkind3cce462017-10-01 13:43:36 -070036
Lev Walkincb523912017-09-30 19:33:23 -070037tests_succeeded=0
38tests_failed=0
Lev Walkind3cce462017-10-01 13:43:36 -070039stop_after_failed=1 # We stop after 3 failures.
Lev Walkin8cec5232017-10-03 15:05:54 -070040need_clean_before_bundle=1 # Clean before testing a bundle file
Lev Walkin7c470c72017-10-08 04:01:45 -070041need_clean_before_test=0 # Before each line in a bundle file
Lev Walkin68619bf2017-10-03 18:40:36 -070042encodings="" # Default is to verify all supported ASN.1 transfer syntaxes
Lev Walkin40b8a7a2017-10-08 22:36:29 -070043parallelism=1
Lev Walkin43292722017-10-05 00:33:32 -070044asn1c_flags=""
Lev Walkin8cec5232017-10-03 15:05:54 -070045
46make_clean_before_bundle() {
Lev Walkinab25f192017-10-08 12:50:43 -070047 if [ "${need_clean_before_bundle}" = "1" ] ; then
Lev Walkinac6db172017-10-10 00:31:06 -070048 (cd "${RNDTEMP}" && Make clean) || :
Lev Walkinab25f192017-10-08 12:50:43 -070049 fi
Lev Walkin8cec5232017-10-03 15:05:54 -070050}
51
52make_clean_before_test() {
Lev Walkin60d62672017-10-08 03:16:10 -070053 if [ "${need_clean_before_test}" = "1" ] ; then
54 Make clean
Lev Walkinf22184d2017-10-27 18:40:32 -070055 else
56 # Low resolution file system mtime prevents rapid testing
57 # without recompilation. We have to clean at least the most
58 # critical portion of the objects. This will reach our objective
59 # of fast compile times (since most of skeletons are not recompiled),
60 # but won't yield a stale T.o object where newer T.c source exists.
61 rm -f T.o || :
Lev Walkin60d62672017-10-08 03:16:10 -070062 fi
Lev Walkin8cec5232017-10-03 15:05:54 -070063}
Lev Walkincb523912017-09-30 19:33:23 -070064
65# Get all the type-bearding lines in file and process them individually
66verify_asn_types_in_file() {
Lev Walkin39936ce2017-10-05 23:56:39 -070067 filename="$1"
68 need_line="$2"
Lev Walkincb523912017-09-30 19:33:23 -070069 test "x$filename" != "x" || usage
Lev Walkin8cec5232017-10-03 15:05:54 -070070
71 make_clean_before_bundle
72
Lev Walkincb523912017-09-30 19:33:23 -070073 echo "Open [$filename]"
Lev Walkina460cbd2017-10-20 02:18:04 -070074 for mode in syntax full; do
75 if [ "x${mode}" = "xsyntax" ]; then
76 max_failures=1
77 else
78 max_failures="${stop_after_failed}"
79 fi
80
81 line=0
82 while read asn; do
Lev Walkin61b4be02017-10-18 16:37:51 -070083 line=`expr ${line} + 1`
Lev Walkin39936ce2017-10-05 23:56:39 -070084 if echo "$asn" | sed -e 's/--.*//;' | grep -vi "[A-Z]" > /dev/null; then
Lev Walkincb523912017-09-30 19:33:23 -070085 # Ignore lines consisting of just comments.
86 continue;
87 fi
Lev Walkind28b45f2017-10-05 22:09:19 -070088 if [ "x$need_line" != "x" ] && [ "$need_line" != "$line" ]; then
Lev Walkincb523912017-09-30 19:33:23 -070089 # We need a different line.
90 continue;
91 fi
Lev Walkina460cbd2017-10-20 02:18:04 -070092 verify_asn_type "$mode" "$asn" "in $filename $line"
93 if [ "${tests_failed}" = "${max_failures}" ]; then
Lev Walkind3cce462017-10-01 13:43:36 -070094 echo "STOP after ${tests_failed} failures, OK ${tests_succeeded}"
95 exit 1
96 fi
Lev Walkina460cbd2017-10-20 02:18:04 -070097 done < "$filename"
98 done
Lev Walkincb523912017-09-30 19:33:23 -070099}
100
101verify_asn_type() {
Lev Walkina460cbd2017-10-20 02:18:04 -0700102 mode="$1"
103 asn="$2"
104 where="$3"
105 shift 3
Lev Walkincb523912017-09-30 19:33:23 -0700106 test "x$asn" != "x" || usage
Lev Walkin8cec5232017-10-03 15:05:54 -0700107
Lev Walkin39936ce2017-10-05 23:56:39 -0700108 if echo "$asn" | grep -v "::=" > /dev/null; then
Lev Walkincb523912017-09-30 19:33:23 -0700109 asn="T ::= $asn"
110 fi
111 echo "Testing [$asn] ${where}"
112
Lev Walkind3cce462017-10-01 13:43:36 -0700113 mkdir -p ${RNDTEMP}
Lev Walkina460cbd2017-10-20 02:18:04 -0700114
115 if [ "x${mode}" = "xsyntax" ]; then
116 if asn1c_invoke "${RNDTEMP}/test.asn1" "$asn" "$where" -P 2>&1 >/dev/null; then
117 return 0
118 else
119 tests_failed=`expr ${tests_failed} + 1`
120 echo "FAIL: ASN.1 ERROR ${where}"
121 return 1
122 fi
123 fi
124
Lev Walkinac6db172017-10-10 00:31:06 -0700125 if (set -e && cd "${RNDTEMP}" && compile_and_test "$asn" "${where}"); then
Lev Walkincb523912017-09-30 19:33:23 -0700126 echo "OK [$asn] ${where}"
Lev Walkin61b4be02017-10-18 16:37:51 -0700127 tests_succeeded=`expr ${tests_succeeded} + 1`
Lev Walkincb523912017-09-30 19:33:23 -0700128 else
Lev Walkin61b4be02017-10-18 16:37:51 -0700129 tests_failed=`expr ${tests_failed} + 1`
Lev Walkincb523912017-09-30 19:33:23 -0700130 echo "FAIL [$asn] ${where}"
131 fi
132}
133
Lev Walkin39936ce2017-10-05 23:56:39 -0700134Make() {
Lev Walkind0d63922017-10-10 01:27:37 -0700135 ${MAKE} -j "${parallelism}" "$@" || return $?
Lev Walkin39936ce2017-10-05 23:56:39 -0700136}
137
138get_param() {
139 param="$1"
140 default="$2"
Lev Walkinebeb4012017-10-09 19:51:26 -0700141 asn="$3"
Lev Walkin39936ce2017-10-05 23:56:39 -0700142
Lev Walkinebeb4012017-10-09 19:51:26 -0700143 if nawk '' >/dev/null 2>&1 ; then
144 AWK=nawk
145 else
146 AWK=awk
147 fi
Lev Walkin39936ce2017-10-05 23:56:39 -0700148
Lev Walkinebeb4012017-10-09 19:51:26 -0700149 echo "$asn" | ${AWK} "BEGIN{FS=\"[^${param}=0-9]+\"};/$param=/{for(i=1;i<=NF;i++)if(substr(\$i,0,length(\"${param}=\"))==\"${param}=\")PARAM=substr(\$i,length(\"${param}=\")+1)}END{if(PARAM)print PARAM;else print \"${default}\";}"
Lev Walkin39936ce2017-10-05 23:56:39 -0700150}
151
Lev Walkin7c470c72017-10-08 04:01:45 -0700152# compile_and_test "<text>" "<where found>"
Lev Walkinac6db172017-10-10 00:31:06 -0700153# This function is executed in the temporary test directory ${RNDTEMP}.
Lev Walkin7c470c72017-10-08 04:01:45 -0700154compile_and_test() {
Lev Walkin39936ce2017-10-05 23:56:39 -0700155 asn="$1"
156 where="$2"
Lev Walkin43292722017-10-05 00:33:32 -0700157
Lev Walkinac6db172017-10-10 00:31:06 -0700158 if [ "x$CC" = "x" ]; then CCSTR=""; else CCSTR="CC=${CC} "; fi
Lev Walkind0d63922017-10-10 01:27:37 -0700159 reproduce_make="cd \"${RNDTEMP}\" && ${CCSTR}CFLAGS=\"${CFLAGS}\" ${MAKE}"
Lev Walkinac6db172017-10-10 00:31:06 -0700160
161 env > .test-environment
162 set > .test-set
163
Lev Walkin43292722017-10-05 00:33:32 -0700164 make_clean_before_test
165
Lev Walkin7c470c72017-10-08 04:01:45 -0700166 asn_compile "$asn" "$where"
Lev Walkin39936ce2017-10-05 23:56:39 -0700167 if [ $? -ne 0 ]; then
Lev Walkincb523912017-09-30 19:33:23 -0700168 echo "Cannot compile ASN.1 $asn"
169 return 1
170 fi
171
172 rm -f random-test-driver.o
173 rm -f random-test-driver
Lev Walkin60d62672017-10-08 03:16:10 -0700174 CFLAGS="${CFLAGS}" Make
Lev Walkin39936ce2017-10-05 23:56:39 -0700175 if [ $? -ne 0 ] ; then
Lev Walkind3cce462017-10-01 13:43:36 -0700176 echo "Cannot compile C for $asn in ${RNDTEMP}"
Lev Walkincb523912017-09-30 19:33:23 -0700177 return 2
178 fi
179
Lev Walkin791d3b72017-10-02 16:24:28 -0700180 # Maximum size of the random data
Lev Walkin39936ce2017-10-05 23:56:39 -0700181 rmax=`get_param RMAX 128 "$asn"`
Lev Walkin791d3b72017-10-02 16:24:28 -0700182 if [ "0${rmax}" -lt 1 ]; then rmax=128; fi
183
Lev Walkincb523912017-09-30 19:33:23 -0700184 echo "Checking random data encode-decode"
Lev Walkin39936ce2017-10-05 23:56:39 -0700185 round_trip_check_cmd="${ASAN_ENV_FLAGS} ./random-test-driver -s ${rmax} ${encodings} -c"
Lev Walkinac6db172017-10-10 00:31:06 -0700186 echo "(${reproduce_make} && ${round_trip_check_cmd})" > .test-reproduce
Lev Walkin39936ce2017-10-05 23:56:39 -0700187 if eval "$round_trip_check_cmd"; then
188 echo "Random test OK"
189 else
Lev Walkinac6db172017-10-10 00:31:06 -0700190 { echo "RETRY:"; cat .test-reproduce ; }
Lev Walkincb523912017-09-30 19:33:23 -0700191 return 3
192 fi
193
Lev Walkind3cce462017-10-01 13:43:36 -0700194 echo "Generating new random data"
195 rm -rf random-data
196 cmd="${ASAN_ENV_FLAGS} UBSAN_OPTIONS=print_stacktrace=1"
Lev Walkind28b45f2017-10-05 22:09:19 -0700197 cmd="${cmd} ./random-test-driver -s ${rmax} ${encodings} -g random-data"
Lev Walkinac6db172017-10-10 00:31:06 -0700198 echo "(${reproduce_make} && ${cmd})" > .test-reproduce
Lev Walkin39936ce2017-10-05 23:56:39 -0700199 if eval "$cmd" ; then
200 echo "Random data generated OK"
201 else
Lev Walkinac6db172017-10-10 00:31:06 -0700202 { echo "RETRY:"; cat .test-reproduce ; }
Lev Walkind3cce462017-10-01 13:43:36 -0700203 return 4
204 fi
205
Lev Walkin233d14d2017-10-02 01:09:01 -0700206 # Do a LibFuzzer based testing
Lev Walkin39936ce2017-10-05 23:56:39 -0700207 fuzz_cmd="${ASAN_ENV_FLAGS} UBSAN_OPTIONS=print_stacktrace=1"
Lev Walkind28b45f2017-10-05 22:09:19 -0700208 fuzz_cmd="${fuzz_cmd} ./random-test-driver"
Lev Walkine5f0d942017-10-24 00:59:32 -0700209 fuzz_cmd="${fuzz_cmd} -timeout=3 -max_total_time=${FUZZ_TIME} -max_len=${rmax}"
Lev Walkin233d14d2017-10-02 01:09:01 -0700210
Lev Walkin39936ce2017-10-05 23:56:39 -0700211 if grep "^fuzz:" Makefile >/dev/null ; then
212 echo "No fuzzer defined, skipping fuzzing"
213 else
214 fuzz_targets=`echo random-data/* | sed -e 's/random-data./fuzz-/g'`
Lev Walkind28b45f2017-10-05 22:09:19 -0700215 {
216 echo "fuzz: $fuzz_targets"
217 echo "fuzz-%: random-data/% random-test-driver"
218 echo " ASN1_DATA_DIR=\$< ${fuzz_cmd} \$<"
219 } >> Makefile
Lev Walkin233d14d2017-10-02 01:09:01 -0700220 fi
221
Lev Walkincb523912017-09-30 19:33:23 -0700222 # If LIBFUZZER_CFLAGS are properly defined, do the fuzz test as well
Lev Walkin39936ce2017-10-05 23:56:39 -0700223 if echo "${LIBFUZZER_CFLAGS}" | grep -i "[a-z]" > /dev/null; then
Lev Walkincb523912017-09-30 19:33:23 -0700224
225 echo "Recompiling for fuzzing..."
226 rm -f random-test-driver.o
227 rm -f random-test-driver
Lev Walkind0d63922017-10-10 01:27:37 -0700228 reproduce_make="cd \"${RNDTEMP}\" && ${CCSTR}CFLAGS=\"${LIBFUZZER_CFLAGS} ${CFLAGS}\" ${MAKE}"
Lev Walkinac6db172017-10-10 00:31:06 -0700229 echo "(${reproduce_make})" > .test-reproduce
Lev Walkin39936ce2017-10-05 23:56:39 -0700230 CFLAGS="${LIBFUZZER_CFLAGS} ${CFLAGS}" Make
231 if [ $? -ne 0 ]; then
232 echo "Recompile failed"
233 return 4
234 fi
Lev Walkincb523912017-09-30 19:33:23 -0700235
Lev Walkind0d63922017-10-10 01:27:37 -0700236 echo "Fuzzing will take a multiple of ${FUZZ_TIME} seconds..."
Lev Walkinac6db172017-10-10 00:31:06 -0700237 echo "(${reproduce_make} fuzz)" > .test-reproduce
238 CFLAGS="${LIBFUZZER_CFLAGS} ${CFLAGS}" Make fuzz
Lev Walkin39936ce2017-10-05 23:56:39 -0700239 if [ $? -ne 0 ]; then
Lev Walkinac6db172017-10-10 00:31:06 -0700240 { echo "RETRY:"; cat .test-reproduce ; }
Lev Walkin233d14d2017-10-02 01:09:01 -0700241 return 5
242 fi
Lev Walkincb523912017-09-30 19:33:23 -0700243 fi
244
Lev Walkina5b02882017-10-01 22:48:44 -0700245 return 0
Lev Walkincb523912017-09-30 19:33:23 -0700246}
247
Lev Walkina460cbd2017-10-20 02:18:04 -0700248asn1c_invoke() {
249 tmpfile="$1"
250 asn="$2"
251 where="$3"
252 shift 3
253
254 {
255 echo "Test DEFINITIONS ::= BEGIN $asn"
256 echo "-- ${where}"
257 echo "END"
258 } > ${tmpfile}
259 echo "${abs_top_builddir}/asn1c/asn1c -S ${abs_top_srcdir}/skeletons"
260 if "${abs_top_builddir}/asn1c/asn1c" -S "${abs_top_srcdir}/skeletons" \
261 -gen-OER -gen-PER ${asn1c_flags} $@ ${tmpfile}
262 then
263 echo "ASN.1 compiled OK"
264 else
265 return 1
266 fi
267}
268
Lev Walkincb523912017-09-30 19:33:23 -0700269asn_compile() {
Lev Walkin39936ce2017-10-05 23:56:39 -0700270 asn="$1"
271 where="$2"
Lev Walkind3cce462017-10-01 13:43:36 -0700272
Lev Walkin5d947a82017-10-03 01:04:03 -0700273 # Create "INTEGER (1..2)" from "T ::= INTEGER (1..2) -- RMAX=5"
Lev Walkinebeb4012017-10-09 19:51:26 -0700274 short_asn=`echo "$asn" | sed -e 's/ *--.*//;s/RMAX=[0-9]//;'`
Lev Walkin39936ce2017-10-05 23:56:39 -0700275 if [ `echo "$short_asn" | grep -c "::="` = 1 ]; then
276 short_asn=`echo "$short_asn" | sed -e 's/.*::= *//'`
Lev Walkind3cce462017-10-01 13:43:36 -0700277 fi
278
Lev Walkincb523912017-09-30 19:33:23 -0700279 test ! -f Makefile.am # Protection from accidental clobbering
Lev Walkina460cbd2017-10-20 02:18:04 -0700280
281 asn1c_invoke "test.asn1" "$asn" "$where" "-flink-skeletons"
282 if [ $? != 0 ]; then
Lev Walkina5b02882017-10-01 22:48:44 -0700283 return 1
284 fi
Lev Walkina460cbd2017-10-20 02:18:04 -0700285
Lev Walkincb523912017-09-30 19:33:23 -0700286 rm -f converter-example.c
Lev Walkin09be69c2017-10-08 16:28:11 -0700287 ln -sf "../${srcdir}/random-test-driver.c" || cp "../${srcdir}/random-test-driver.c" .
Lev Walkin40b8a7a2017-10-08 22:36:29 -0700288 {
289 echo "CFLAGS+= -DASN1_TEXT='$short_asn'";
290 echo "ASN_PROGRAM = random-test-driver"
291 echo "ASN_PROGRAM_SOURCES = random-test-driver.c"
Lev Walkinac6db172017-10-10 00:31:06 -0700292 echo
Lev Walkin40b8a7a2017-10-08 22:36:29 -0700293 echo "include Makefile.am.example"
Lev Walkinac6db172017-10-10 00:31:06 -0700294 echo
295 echo "all-tests-succeeded: ${abs_top_builddir}/asn1c/asn1c \$(ASN_PROGRAM_SOURCES) \$(ASN_MODULE_SOURCES) \$(ASN_MODULE_HEADERS)"
296 echo " @rm -f \$@"
297 echo " @echo Previous try did not go correctly. To reproduce:"
298 echo " @cat .test-reproduce"
299 echo " @exit 1"
300 echo
Lev Walkin40b8a7a2017-10-08 22:36:29 -0700301 } > Makefile
Lev Walkincb523912017-09-30 19:33:23 -0700302 echo "Makefile.am.example -> Makefile"
303}
304
Lev Walkin7c470c72017-10-08 04:01:45 -0700305# Make up to four different passes:
306# CFLAGS: | asn1c_flags:
307# -m64 | -fnative-types
308# -m32 | -fnative-types
309# -m64 | -fwide-types
310# -m32 | -fwide-types
311# *) Of course, -m64 and -fnative-types are just implied.
312test_drive() {
313 func="$1"
314 shift
315
316 if [ "x${asn1c_flags}" = "x" ] ; then
317 # Test for native types and wide types
318 asn1c_flags=" " test_drive "${func}" "$@"
319 asn1c_flags="-fnative-types" test_drive "${func}" "$@"
320 return 0
321 fi
322
Lev Walkinac6db172017-10-10 00:31:06 -0700323 # Can't reuse object code.
324 rm -rf ${RNDTEMP}
325
Lev Walkin7c470c72017-10-08 04:01:45 -0700326 echo "MODE: default"
327 # Default (likely 64-bit) mode
328 ${func} "$@"
329
330 # 32-bit mode, if available
331 if echo "${CFLAGS_M32}" | grep -i '[a-z]' > /dev/null ; then
332 echo "MODE: 32-bit"
Lev Walkinac6db172017-10-10 00:31:06 -0700333
334 # Can't reuse object code between modes.
335 rm -rf ${RNDTEMP}
336
Lev Walkin7c470c72017-10-08 04:01:45 -0700337 # -m32 doesn't support fuzzing (no such library), so we remove fuzzer.
338 # -m32 doesn't support leak sanitizing (it hangs), so we remove
Lev Walkinac6db172017-10-10 00:31:06 -0700339 # ASAN_ENV_FLAGS which enable leak check in runtime.
Lev Walkin7c470c72017-10-08 04:01:45 -0700340 CFLAGS="${CFLAGS} ${CFLAGS_M32}" CFLAGS_M32="" \
341 LIBFUZZER_CFLAGS="" ASAN_ENV_FLAGS="" \
342 ${func} "$@"
343 fi
344}
345
Lev Walkin40b8a7a2017-10-08 22:36:29 -0700346if echo "$*" | grep ' -- ' > /dev/null; then
347 TEST_DRIVER=`echo "$*" | sed -e 's/ -- .*/ -- /g'`
348 args=`echo "$*" | sed -e 's/.* //g'`
349 set "${args}"
350else
351 TEST_DRIVER=""
352fi
353
Lev Walkincb523912017-09-30 19:33:23 -0700354# Command line parsing
Lev Walkin68619bf2017-10-03 18:40:36 -0700355while :; do
356 case "$1" in
357 -h) usage ;;
Lev Walkind28b45f2017-10-05 22:09:19 -0700358 --asn1c) asn1c_flags="${asn1c_flags} $2"; shift 2; continue ;;
Lev Walkin40b8a7a2017-10-08 22:36:29 -0700359 --bundle)
360 shift
Lev Walkinac6db172017-10-10 00:31:06 -0700361
362 # Look for the transcript in bundles/NN-*-bundles.txt.log
363 set -x
364
Lev Walkin40b8a7a2017-10-08 22:36:29 -0700365 base=`basename "$1" | sed -e 's/.txt$//'`
366 RNDTEMP=".tmp.${base}"
Lev Walkinac6db172017-10-10 00:31:06 -0700367
368 if Make -C "${RNDTEMP}" all-tests-succeeded >/dev/null 2>&1 ; then
369 echo "Test succeeded before. Not rechecking."
370 tests_succeeded=1
371 break
372 fi
373
Lev Walkin40b8a7a2017-10-08 22:36:29 -0700374 test_drive verify_asn_types_in_file "$@"
Lev Walkinac6db172017-10-10 00:31:06 -0700375
376 touch "${RNDTEMP}/all-tests-succeeded"
377
Lev Walkin40b8a7a2017-10-08 22:36:29 -0700378 break
379 ;;
Lev Walkin68619bf2017-10-03 18:40:36 -0700380 --dirty)
381 need_clean_before_bundle=0
382 need_clean_before_test=0
383 shift
384 continue
385 ;;
Lev Walkind28b45f2017-10-05 22:09:19 -0700386 -e) encodings="${encodings} -e $2"; shift 2; continue;;
Lev Walkin68619bf2017-10-03 18:40:36 -0700387 -j) parallelism="$1"; shift 2; continue;;
388 -t)
Lev Walkina460cbd2017-10-20 02:18:04 -0700389 test_drive verify_asn_type "full" "$2" "(command line)" || exit 1 ;;
Lev Walkin68619bf2017-10-03 18:40:36 -0700390 "")
Lev Walkin09be69c2017-10-08 16:28:11 -0700391 for bundle in `ls -1 ${srcdir}/bundles/*.txt | sort -nr`; do
Lev Walkin7c470c72017-10-08 04:01:45 -0700392 test_drive verify_asn_types_in_file "$bundle"
Lev Walkin68619bf2017-10-03 18:40:36 -0700393 done
394 ;;
395 *)
Lev Walkin40b8a7a2017-10-08 22:36:29 -0700396 exec ${TEST_DRIVER} $0 --bundle "$@"
Lev Walkin68619bf2017-10-03 18:40:36 -0700397 ;;
398 esac
399 break
400done
Lev Walkincb523912017-09-30 19:33:23 -0700401
Lev Walkind28b45f2017-10-05 22:09:19 -0700402if [ "$tests_succeeded" != "0" ] && [ "$tests_failed" = "0" ]; then
Lev Walkincb523912017-09-30 19:33:23 -0700403 echo "OK $tests_succeeded tests"
404else
405 echo "FAILED $tests_failed tests, OK $tests_succeeded tests"
406 exit 1
407fi