added fuzzer for XER test 70
diff --git a/tests/tests-c-compiler/check-assembly.sh b/tests/tests-c-compiler/check-assembly.sh
index 29734fa..08420ec 100755
--- a/tests/tests-c-compiler/check-assembly.sh
+++ b/tests/tests-c-compiler/check-assembly.sh
@@ -51,10 +51,24 @@
OFS=$IFS
IFS="."
set $args
+data_dir=$(echo "$1" | sed -e s/check-/data-/)
shift
IFS=$OFS
AFLAGS="$*"
+if [ -d ${data_dir} ]; then
+ OPT_DATA_DIR="../${data_dir}"
+else
+ OPT_DATA_DIR=""
+fi
+
+if test "${LIBFUZZER_CFLAGS}" && grep LLVMFuzzer ${source_full} > /dev/null;
+then
+ MAKE_FUZZER=yes
+else
+ MAKE_FUZZER=no
+fi
+
# Assume the test fails. Will be removed when it passes well.
testdir=test-${args}
if [ -f "${testdir}-FAILED" ]; then
@@ -65,13 +79,6 @@
mkdir -p "${testdir}"
ln -fns "../${source_full}" "${testdir}"
-if test "${LIBFUZZER_CFLAGS}" && grep LLVMFuzzer ${source_full} > /dev/null;
-then
- MAKE_FUZZER=yes
-else
- MAKE_FUZZER=no
-fi
-
asn_module=$(echo "${abs_top_srcdir}/tests/tests-asn1c-compiler/${testno}"-*.asn1)
AUTOGENERATED="# This file is autogenerated by $0 ${source_full} ${AFLAGS}"
@@ -116,7 +123,7 @@
check-fuzzer:
TARGETS
else
- CHECK_FUZZER="UBSAN_OPTIONS=print_stacktrace=1 ./check-fuzzer -timeout=3 -max_total_time=60 -max_len=512 -detect_leaks=1"
+ CHECK_FUZZER="UBSAN_OPTIONS=print_stacktrace=1 ./check-fuzzer -timeout=3 -max_total_time=60 -max_len=512 -detect_leaks=1 ${OPT_DATA_DIR}"
cat <<TARGETS >> "${testdir}/Makefile.targets"
check-fuzzer: \$(OBJS)
rm -f ${source_obj}
diff --git a/tests/tests-c-compiler/check-src/check-70.-fwide-types.c b/tests/tests-c-compiler/check-src/check-70.-fwide-types.c
index 5e450b6..8152346 100644
--- a/tests/tests-c-compiler/check-src/check-70.-fwide-types.c
+++ b/tests/tests-c-compiler/check-src/check-70.-fwide-types.c
@@ -277,6 +277,19 @@
return 1;
}
+#ifdef ENABLE_LIBFUZZER
+
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ PDU_t *st = 0;
+ asn_dec_rval_t rval;
+ rval = asn_decode(0, ATS_BASIC_XER, &asn_DEF_PDU, (void **)&st, Data, Size);
+ assert(rval.consumed <= Size);
+ ASN_STRUCT_FREE(asn_DEF_PDU, st);
+ return 0;
+}
+
+#else
+
int
main() {
DIR *dir;
@@ -309,3 +322,4 @@
return 0;
}
+#endif
diff --git a/tests/tests-c-compiler/check-src/check-70.c b/tests/tests-c-compiler/check-src/check-70.c
index 16e3e2e..8e27799 100644
--- a/tests/tests-c-compiler/check-src/check-70.c
+++ b/tests/tests-c-compiler/check-src/check-70.c
@@ -256,6 +256,19 @@
return 1;
}
+#ifdef ENABLE_LIBFUZZER
+
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ PDU_t *st = 0;
+ asn_dec_rval_t rval;
+ rval = asn_decode(0, ATS_BASIC_XER, &asn_DEF_PDU, (void **)&st, Data, Size);
+ assert(rval.consumed <= Size);
+ ASN_STRUCT_FREE(asn_DEF_PDU, st);
+ return 0;
+}
+
+#else
+
int
main() {
DIR *dir;
@@ -286,3 +299,4 @@
return 0;
}
+#endif