aboutsummaryrefslogtreecommitdiffstats
path: root/asn1c/tests/check-assembly.sh
blob: a1756b4d65be6ed6ec2b3f26d0cfbd33c88f857e (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
48
49
50
51
52
53
54
55
56
#!/bin/sh

#
# This script is designed to quickly create lots of files in underlying
# test-* directories, do lots of other magic stuff and exit cleanly.
#

# Compute the .asn1 spec name by the given file name.
source=$(echo "$1" | sed -e 's/.*\///')
testno=`echo "$source" | cut -f2 -d'-' | cut -f1 -d'.'`

args=$(echo "$source" | sed -e 's/\.c$//')
testdir=test-${args}

OFS=$IFS
IFS="."
set $args
shift
IFS=$OFS

if [ ! -d $testdir ]; then
	mkdir $testdir		|| exit $?
fi
cd $testdir			|| exit $?
ln -fs ../$source		|| exit $?
# Compile the corresponding .asn1 spec.
set -x
../../asn1c	\
	-S ../../../skeletons	\
	-Wdebug-compiler "$@"	\
	../../../tests/${testno}-*.asn1 || exit $?
set +x

# Create a Makefile for the project.
cat > Makefile <<EOM
CFLAGS=-I. -Wall -g ${CFLAGS} -DEMIT_ASN_DEBUG
SRCS=`echo *.c`
OBJS=\${SRCS:.c=.o}
check-executable: \${OBJS}
	\${CC} \${CFLAGS} -o check-executable \${OBJS}
.SUFFIXES:
.SUFFIXES: .c .o
.c.o:
	\${CC} \${CFLAGS} -o \$@ -c \$<
check: check-executable
	./check-executable
clean:
	@rm -f *.o
EOM

# Perform building and checking 
make check	|| exit $?

# Uncomment this to jeopardize debugging
# make clean