simpler makefile generation
diff --git a/tests/tests-c-compiler/Makefile.am b/tests/tests-c-compiler/Makefile.am
index 1eaf911..3102a68 100644
--- a/tests/tests-c-compiler/Makefile.am
+++ b/tests/tests-c-compiler/Makefile.am
@@ -44,7 +44,6 @@
TESTS += check-src/check-41.-fwide-types.c
TESTS += check-src/check-41.c
TESTS += check-src/check-42.c
-TESTS += check-src/check-42.-fwide-types.cc
TESTS += check-src/check-43.c
TESTS += check-src/check-44.c
TESTS += check-src/check-46.c
@@ -72,8 +71,7 @@
data-119 \
data-126 \
check-src/check64-134.-gen-PER.c \
- check-src/check64-136.-gen-OER.c \
- check-src/check-42.-fwide-types.cc
+ check-src/check64-136.-gen-OER.c
clean-local:
rm -rf test-*
diff --git a/tests/tests-c-compiler/check-assembly.sh b/tests/tests-c-compiler/check-assembly.sh
index 55eacd3..299f833 100755
--- a/tests/tests-c-compiler/check-assembly.sh
+++ b/tests/tests-c-compiler/check-assembly.sh
@@ -28,26 +28,10 @@
source_short=$(echo "$source_full" | sed -e 's/.*\///')
testno=$(echo "$source_short" | cut -f2 -d'-' | cut -f1 -d'.')
-CODECS_FLAGS=""
-has_oer=$(echo "$source_short" | grep "gen-OER" || :)
-if [ ! "$has_oer" ]; then
- CODECS_FLAGS="${CODECS_FLAGS} -DASN_DISABLE_OER_SUPPORT"
-fi
-has_per=$(echo "$source_short" | grep "gen-PER" || :)
-if [ ! "$has_per" ]; then
- CODECS_FLAGS="${CODECS_FLAGS} -DASN_DISABLE_PER_SUPPORT"
-fi
-
args=$(echo "$source_short" | sed -E -e 's/\.c+$//')
source_obj=$(echo "$source_short" | sed -E -e 's/\.c+$/.o/')
ext=$(echo "$source_short" | sed -E -e 's/.*\.(c+)$/\1/')
-if [ "$ext" = "cc" ]; then
- COMPILER='$(CXX) $(CXX_CFLAGS)'
-else
- COMPILER='$(CC)'
-fi
-
OFS=$IFS
IFS="."
set $args
@@ -84,25 +68,25 @@
AUTOGENERATED="# This file is autogenerated by $0 ${source_full} ${AFLAGS}"
# Create a common Makefile for the project
-cat <<TARGETS > "${testdir}/Makefile.targets"
+cat <<END_MAKEFILE > "${testdir}/Makefile"
${AUTOGENERATED}
-
COMMON_FLAGS= -I.
CFLAGS = \${COMMON_FLAGS} ${CFLAGS:-} -g -O1
-CFLAGS += -DSRCDIR=../${srcdir} ${CODECS_FLAGS}
+CFLAGS += -DSRCDIR=../${srcdir}
CXXFLAGS = \${CFLAGS} ${CXXFLAGS}
LIBFUZZER_CFLAGS = ${LIBFUZZER_CFLAGS}
LDFLAGS = ${LDFLAGS:-}
+ASN_PROGRAM = check-program
+ASN_PROGRAM_SOURCES = ${source_short}
+
CC ?= ${CC}
CXX ?= ${CXX}
-all: compiled-module
- \$(MAKE) check-executable
+-include Makefile.am.example
-check-executable: \$(OBJS)
- @rm -f *.core
- ${COMPILER} \$(CFLAGS) \$(LDFLAGS) -o check-executable \$(OBJS) -lm
+all: compiled-module
+ \$(MAKE) check-program
# Compile the corresponding .asn1 spec.
compiled-module: ${asn_module} ${abs_top_builddir}/asn1c/asn1c
@@ -113,33 +97,30 @@
rm -f converter-example.c
@touch compiled-module
-TARGETS
+END_MAKEFILE
if [ "${MAKE_FUZZER}" != "yes" ]; then
CHECK_FUZZER="@echo \"No fuzzer defined, skipping.\""
-cat <<TARGETS >> "${testdir}/Makefile.targets"
+cat <<END_MAKEFILE >> "${testdir}/Makefile"
.PHONY: check-fuzzer
check-fuzzer:
-TARGETS
+END_MAKEFILE
else
CHECK_FUZZER="ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1 ./check-fuzzer -timeout=3 -max_total_time=60 -max_len=512 ${OPT_DATA_DIR}"
-cat <<TARGETS >> "${testdir}/Makefile.targets"
-check-fuzzer: \$(OBJS)
- rm -f ${source_obj}
- ${COMPILER} \$(CFLAGS) \$(LIBFUZZER_CFLAGS) -c -o ${source_obj} ${source_short}
- ${COMPILER} \$(CFLAGS) \$(LIBFUZZER_CFLAGS) \$(LDFLAGS) -o check-fuzzer \$(OBJS)
- rm -f ${source_obj}
-TARGETS
+cat <<END_MAKEFILE >> "${testdir}/Makefile"
+check-fuzzer: ${source_short} \$(ASN_LIBRARY)
+ ${CC} \$(CFLAGS) \$(LIBFUZZER_CFLAGS) \$(LDFLAGS) -o check-fuzzer \$^
+END_MAKEFILE
fi
-cat <<TARGETS >> "${testdir}/Makefile.targets"
+cat <<END_MAKEFILE >> "${testdir}/Makefile"
-check-succeeded: compiled-module
- \$(MAKE) check-executable
+check-succeeded: compiled-module \$(ASN_LIBRARY) ${source_short}
+ \$(MAKE) check-program
\$(MAKE) check-fuzzer
@rm -f check-succeeded
- ./check-executable
+ ./check-program
\$(MAKE) fuzz
@touch check-succeeded
@echo "OK: ${source_full}"
@@ -150,43 +131,10 @@
check: check-succeeded
-clean:
- @rm -f *.o check-executable
-TARGETS
-
-# Create a BSD- or GNU-specific Makefile for the project.
-produce_specific_makefile() {
- local make_type=$1
- local make_file="$testdir/${make_type}makefile"
-
- if [ ${make_type} = "BSD" ]; then
- cat <<-OBJECTS > ${make_file}
- ${AUTOGENERATED}
- SRCS_C!=find . -name \*.c
- SRCS_CXX!=find . -name \*.cc
- SRCS=\$(SRCS_C) \$(SRCS_CXX)
- OBJS=\${SRCS_C:.c=.o} \${SRCS_CXX:.cc=.o}
- include Makefile.targets
- OBJECTS
- else
- cat <<-OBJECTS > ${make_file}
- ${AUTOGENERATED}
- SRCS_C := \$(wildcard *.c)
- SRCS_CXX := \$(wildcard *.cc)
- SRCS = \$(SRCS_C) \$(SRCS_CXX)
- OBJS =\$(patsubst %.c,%.o,\$(SRCS_C))
- OBJS+=\$(patsubst %.cc,%.o,\$(SRCS_CXX))
- include Makefile.targets
- OBJECTS
- fi
-
-}
-
-produce_specific_makefile BSD
-produce_specific_makefile GNU
+END_MAKEFILE
# Perform building and checking
-${TEST_DRIVER} make -C "$testdir" check
+${TEST_DRIVER} ${MAKE:-make} -C "${testdir}" check
# Make sure the test is not marked as failed any longer.
rm -f "${testdir}-FAILED"
diff --git a/tests/tests-randomized/Makefile.am b/tests/tests-randomized/Makefile.am
index f367b8d..57090f6 100644
--- a/tests/tests-randomized/Makefile.am
+++ b/tests/tests-randomized/Makefile.am
@@ -16,12 +16,18 @@
ASAN_ENV_FLAGS="@ASAN_ENV_FLAGS@" \
srcdir=${srcdir} \
abs_top_srcdir=${abs_top_srcdir} \
- abs_top_builddir=${abs_top_builddir}
+ abs_top_builddir=${abs_top_builddir} \
+ ${srcdir}/check-bundles.sh
-TESTS = $(dist_check_SCRIPTS)
+TESTS =
+TESTS += bundles/01-1.txt
+TESTS += bundles/01-2.txt
-EXTRA_DIST = bundles random-test-driver.c
+EXTRA_DIST = \
+ random-test-driver.c \
+ $(srcdir)/bundles/README \
+ $(srcdir)/bundles/*.txt
clean-local:
- rm -rf .tmp.random
+ rm -rf .tmp.*
diff --git a/tests/tests-randomized/check-bundles.sh b/tests/tests-randomized/check-bundles.sh
index 48440a5..8a2804d 100755
--- a/tests/tests-randomized/check-bundles.sh
+++ b/tests/tests-randomized/check-bundles.sh
@@ -26,7 +26,7 @@
exit 1
}
-RNDTEMP=.tmp.random
+RNDTEMP="${RNDTEMP:-.tmp.random}"
srcdir="${srcdir:-.}"
abs_top_srcdir="${abs_top_srcdir:-`pwd`/../../}"
@@ -38,7 +38,7 @@
need_clean_before_bundle=1 # Clean before testing a bundle file
need_clean_before_test=0 # Before each line in a bundle file
encodings="" # Default is to verify all supported ASN.1 transfer syntaxes
-parallelism=4
+parallelism=1
asn1c_flags=""
make_clean_before_bundle() {
@@ -229,9 +229,12 @@
fi
rm -f converter-example.c
ln -sf "../${srcdir}/random-test-driver.c" || cp "../${srcdir}/random-test-driver.c" .
- echo "CFLAGS+= -DASN1_TEXT='$short_asn'" > Makefile
- sed -e 's/converter-example/random-test-driver/' \
- < Makefile.am.example >> Makefile
+ {
+ echo "CFLAGS+= -DASN1_TEXT='$short_asn'";
+ echo "ASN_PROGRAM = random-test-driver"
+ echo "ASN_PROGRAM_SOURCES = random-test-driver.c"
+ echo "include Makefile.am.example"
+ } > Makefile
echo "Makefile.am.example -> Makefile"
}
@@ -271,11 +274,26 @@
fi
}
+if echo "$*" | grep ' -- ' > /dev/null; then
+ TEST_DRIVER=`echo "$*" | sed -e 's/ -- .*/ -- /g'`
+ args=`echo "$*" | sed -e 's/.* //g'`
+ set "${args}"
+else
+ TEST_DRIVER=""
+fi
+
# Command line parsing
while :; do
case "$1" in
-h) usage ;;
--asn1c) asn1c_flags="${asn1c_flags} $2"; shift 2; continue ;;
+ --bundle)
+ shift
+ base=`basename "$1" | sed -e 's/.txt$//'`
+ RNDTEMP=".tmp.${base}"
+ test_drive verify_asn_types_in_file "$@"
+ break
+ ;;
--dirty)
need_clean_before_bundle=0
need_clean_before_test=0
@@ -285,7 +303,6 @@
-e) encodings="${encodings} -e $2"; shift 2; continue;;
-j) parallelism="$1"; shift 2; continue;;
-t)
- parallelism=1 # Better for debuggability
test_drive verify_asn_type "$2" "(command line)" || exit 1 ;;
"")
for bundle in `ls -1 ${srcdir}/bundles/*.txt | sort -nr`; do
@@ -293,7 +310,7 @@
done
;;
*)
- test_drive verify_asn_types_in_file "$@"
+ exec ${TEST_DRIVER} $0 --bundle "$@"
;;
esac
break