asn1c/asn1c/tests/check-assembly.sh

77 lines
1.5 KiB
Bash
Raw Normal View History

2004-06-03 03:38:44 +00:00
#!/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.
#
2004-08-22 03:08:23 +00:00
if [ "x$1" = "x" ]; then
echo "Usage: $0 <check-NN.c>"
exit
fi
2004-06-03 03:38:44 +00:00
# Compute the .asn1 spec name by the given file name.
source=`echo "$1" | sed -e 's/.*\///'`
2004-06-03 03:38:44 +00:00
testno=`echo "$source" | cut -f2 -d'-' | cut -f1 -d'.'`
args=`echo "$source" | sed -e 's/\.c[c]*$//'`
2004-06-03 03:38:44 +00:00
testdir=test-${args}
OFS=$IFS
IFS="."
set $args
shift
IFS=$OFS
2004-08-22 03:08:23 +00:00
AFLAGS="$@"
touch ${testdir}-FAILED # Create this file to ease post mortem analysis
2004-06-03 03:38:44 +00:00
if [ ! -d $testdir ]; then
mkdir $testdir || exit $?
fi
cd $testdir || exit $?
rm -f ./$source 2>/dev/null
ln -fns ../$source || exit $?
2004-08-22 03:08:23 +00:00
asn_module=`echo ../../../tests/${testno}-*.asn1`
2004-06-03 03:38:44 +00:00
# Create a Makefile for the project.
cat > Makefile <<EOM
2004-08-22 03:08:23 +00:00
# This file is autogenerated by ../$0
2004-08-11 05:48:02 +00:00
COMMON_FLAGS= -I. -DEMIT_ASN_DEBUG
2004-08-11 05:26:29 +00:00
CFLAGS=\${COMMON_FLAGS} ${CFLAGS}
CXXFLAGS=\${COMMON_FLAGS} ${CXXFLAGS}
2004-08-22 03:08:23 +00:00
2005-11-07 15:19:05 +00:00
CC ?= ${CC}
2004-08-22 03:08:23 +00:00
all: check-executable
check-executable: compiled-module *.c*
2004-09-14 14:19:53 +00:00
@rm -f *.core
2004-09-14 14:14:58 +00:00
\$(CC) \$(CFLAGS) -o check-executable -lm *.c*
2004-08-22 03:08:23 +00:00
# Compile the corresponding .asn1 spec.
compiled-module: ${asn_module} ../../asn1c
../../asn1c -S ../../../skeletons -Wdebug-compiler \\
${AFLAGS} ${asn_module}
2006-09-13 00:21:58 +00:00
rm -f converter-sample.c
2004-08-22 03:08:23 +00:00
@touch compiled-module
check-succeeded: check-executable
@rm -f check-succeeded
2004-06-03 03:38:44 +00:00
./check-executable
2004-08-22 03:08:23 +00:00
@touch check-succeeded
check: check-succeeded
2004-06-03 03:38:44 +00:00
clean:
@rm -f *.o check-executable
2004-06-03 03:38:44 +00:00
EOM
2004-08-22 03:08:23 +00:00
# Perform building and checking
make check || exit $?
2004-06-03 03:38:44 +00:00
2004-08-22 03:08:23 +00:00
rm -f ../${testdir}-FAILED
2004-06-03 03:38:44 +00:00
2004-08-22 03:08:23 +00:00
exit 0