junktesting support

git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@1240 59561ff5-6e30-0410-9f3c-9617f08c8826
This commit is contained in:
vlm 2006-09-24 19:47:07 +00:00
parent d6132a6c98
commit fdf05da725
8 changed files with 279 additions and 52 deletions

View File

@ -38,9 +38,9 @@ if test ! -f Makefile.am.sample ; then
exit 1
fi
EXTRA_CFLAGS=""
EXTRA_CFLAGS="-DJUNKTEST"
if test -f config.h ; then
EXTRA_CFLAGS="-DHAVE_CONFIG_H"
EXTRA_CFLAGS="-DHAVE_CONFIG_H ${EXTRA_CFLAGS}"
fi
set -x
@ -64,7 +64,12 @@ set +x
echo " PROGNAME=${PROGNAME} \\"
echo " $0"
echo
echo 'check: ${TARGET}'
echo 'check: ${TARGET} check-ber check-xer check-per'
echo ' @echo ================'
echo ' @echo All tests passed'
echo ' @echo ================'
echo
echo 'check-ber:'
echo " @if test -f sample-${ASN1PDU}-1.[db]er ; then \\"
echo " for f in sample-${ASN1PDU}-*.[db]er; do \\"
echo ' for b in 1 17 33 980 8192; do \'
@ -73,7 +78,12 @@ set +x
echo ' ./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \'
echo ' diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \'
echo ' rm -f ./.tmp.[12].$$$$; \'
echo ' echo "Test junking $$f (please wait)..."; \'
echo ' ./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 2; \'
echo ' ./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 2; \'
echo ' done; done; fi'
echo
echo 'check-xer:'
echo " @if test -f sample-${ASN1PDU}-1.xer ; then \\"
echo " for f in sample-${ASN1PDU}-*.xer; do \\"
echo ' for b in 1 17 33 980 8192; do \'
@ -82,7 +92,12 @@ set +x
echo ' ./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \'
echo ' diff $$f ./.tmp.2.$$$$ || exit 2; \'
echo ' rm -f ./.tmp.[12].$$$$; \'
echo ' echo "Test junking $$f (please wait)..."; \'
echo ' ./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \'
echo ' ./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \'
echo ' done; done; fi'
echo
echo 'check-per:'
echo " @if test -f sample-${ASN1PDU}-1.per ; then \\"
echo " for f in sample-${ASN1PDU}-[1-9].per; do \\"
echo ' for b in 1 17 33 980 8192; do \'
@ -92,6 +107,9 @@ set +x
echo ' ./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 2; \'
echo ' diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 2; \'
echo ' rm -f ./.tmp.[123].$$$$; \'
echo ' echo "Test junking $$f (please wait)..."; \'
echo ' ./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 2; \'
echo ' ./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 2; \'
echo ' done; done; fi'
echo " @if test -f sample-${ASN1PDU}-1-padded.per ; then \\"
echo " for f in sample-*-[1-9]-padded.per; do \\"
@ -103,10 +121,10 @@ set +x
echo ' ./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \'
echo ' diff $$f ./.tmp.1.$$$$ || exit 2; \'
echo ' rm -f ./.tmp.[12].$$$$; \'
echo ' echo "Test junking $$f (please wait)..."; \'
echo ' ./${TARGET} -J0.0001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \'
echo ' ./${TARGET} -J0.001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \'
echo ' done; done; fi'
echo ' @echo ================'
echo ' @echo All tests passed'
echo ' @echo ================'
echo
echo "distclean: clean"
echo ' rm -f $(ASN_MODULE_SOURCES)'

View File

@ -163,7 +163,7 @@ libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
# This file may be used as an input for make(3)
# Remove the lines below to convert it into a pure .am file
TARGET = ldap3dump
CFLAGS += -DHAVE_CONFIG_H -DPDU=LDAPMessage -I.
CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -DPDU=LDAPMessage -I.
OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}
all: LDAPMessage.c $(TARGET)
@ -199,7 +199,12 @@ regen-makefile:
PROGNAME=ldap3dump \
../sample.makefile.regen
check: ${TARGET}
check: ${TARGET} check-ber check-xer check-per
@echo ================
@echo All tests passed
@echo ================
check-ber:
@if test -f sample-LDAPMessage-1.[db]er ; then \
for f in sample-LDAPMessage-*.[db]er; do \
for b in 1 17 33 980 8192; do \
@ -208,7 +213,12 @@ check: ${TARGET}
./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 2; \
done; done; fi
check-xer:
@if test -f sample-LDAPMessage-1.xer ; then \
for f in sample-LDAPMessage-*.xer; do \
for b in 1 17 33 980 8192; do \
@ -217,7 +227,12 @@ check: ${TARGET}
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
diff $$f ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \
done; done; fi
check-per:
@if test -f sample-LDAPMessage-1.per ; then \
for f in sample-LDAPMessage-[1-9].per; do \
for b in 1 17 33 980 8192; do \
@ -227,6 +242,9 @@ check: ${TARGET}
./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 2; \
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 2; \
rm -f ./.tmp.[123].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 2; \
done; done; fi
@if test -f sample-LDAPMessage-1-padded.per ; then \
for f in sample-*-[1-9]-padded.per; do \
@ -238,10 +256,10 @@ check: ${TARGET}
./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \
diff $$f ./.tmp.1.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \
done; done; fi
@echo ================
@echo All tests passed
@echo ================
distclean: clean
rm -f $(ASN_MODULE_SOURCES)

View File

@ -285,7 +285,7 @@ libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
# This file may be used as an input for make(3)
# Remove the lines below to convert it into a pure .am file
TARGET = megacoDump
CFLAGS += -DHAVE_CONFIG_H -DPDU=MegacoMessage -I.
CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -DPDU=MegacoMessage -I.
OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}
all: MegacoMessage.c $(TARGET)
@ -321,7 +321,12 @@ regen-makefile:
PROGNAME=megacoDump \
../sample.makefile.regen
check: ${TARGET}
check: ${TARGET} check-ber check-xer check-per
@echo ================
@echo All tests passed
@echo ================
check-ber:
@if test -f sample-MegacoMessage-1.[db]er ; then \
for f in sample-MegacoMessage-*.[db]er; do \
for b in 1 17 33 980 8192; do \
@ -330,7 +335,12 @@ check: ${TARGET}
./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 2; \
done; done; fi
check-xer:
@if test -f sample-MegacoMessage-1.xer ; then \
for f in sample-MegacoMessage-*.xer; do \
for b in 1 17 33 980 8192; do \
@ -339,7 +349,12 @@ check: ${TARGET}
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
diff $$f ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \
done; done; fi
check-per:
@if test -f sample-MegacoMessage-1.per ; then \
for f in sample-MegacoMessage-[1-9].per; do \
for b in 1 17 33 980 8192; do \
@ -349,6 +364,9 @@ check: ${TARGET}
./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 2; \
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 2; \
rm -f ./.tmp.[123].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 2; \
done; done; fi
@if test -f sample-MegacoMessage-1-padded.per ; then \
for f in sample-*-[1-9]-padded.per; do \
@ -360,10 +378,10 @@ check: ${TARGET}
./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \
diff $$f ./.tmp.1.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \
done; done; fi
@echo ================
@echo All tests passed
@echo ================
distclean: clean
rm -f $(ASN_MODULE_SOURCES)

View File

@ -453,7 +453,7 @@ libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
# This file may be used as an input for make(3)
# Remove the lines below to convert it into a pure .am file
TARGET = mheg5dump
CFLAGS += -DHAVE_CONFIG_H -DPDU=InterchangedObject -I.
CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -DPDU=InterchangedObject -I.
OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}
all: InterchangedObject.c $(TARGET)
@ -489,7 +489,12 @@ regen-makefile:
PROGNAME=mheg5dump \
../sample.makefile.regen
check: ${TARGET}
check: ${TARGET} check-ber check-xer check-per
@echo ================
@echo All tests passed
@echo ================
check-ber:
@if test -f sample-InterchangedObject-1.[db]er ; then \
for f in sample-InterchangedObject-*.[db]er; do \
for b in 1 17 33 980 8192; do \
@ -498,7 +503,12 @@ check: ${TARGET}
./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 2; \
done; done; fi
check-xer:
@if test -f sample-InterchangedObject-1.xer ; then \
for f in sample-InterchangedObject-*.xer; do \
for b in 1 17 33 980 8192; do \
@ -507,7 +517,12 @@ check: ${TARGET}
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
diff $$f ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \
done; done; fi
check-per:
@if test -f sample-InterchangedObject-1.per ; then \
for f in sample-InterchangedObject-[1-9].per; do \
for b in 1 17 33 980 8192; do \
@ -517,6 +532,9 @@ check: ${TARGET}
./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 2; \
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 2; \
rm -f ./.tmp.[123].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 2; \
done; done; fi
@if test -f sample-InterchangedObject-1-padded.per ; then \
for f in sample-*-[1-9]-padded.per; do \
@ -528,10 +546,10 @@ check: ${TARGET}
./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \
diff $$f ./.tmp.1.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \
done; done; fi
@echo ================
@echo All tests passed
@echo ================
distclean: clean
rm -f $(ASN_MODULE_SOURCES)

View File

@ -345,7 +345,7 @@ libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
# This file may be used as an input for make(3)
# Remove the lines below to convert it into a pure .am file
TARGET = x509dump
CFLAGS += -DHAVE_CONFIG_H -DPDU=Certificate -I.
CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -DPDU=Certificate -I.
OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}
all: Certificate.c $(TARGET)
@ -381,7 +381,12 @@ regen-makefile:
PROGNAME=x509dump \
../sample.makefile.regen
check: ${TARGET}
check: ${TARGET} check-ber check-xer check-per
@echo ================
@echo All tests passed
@echo ================
check-ber:
@if test -f sample-Certificate-1.[db]er ; then \
for f in sample-Certificate-*.[db]er; do \
for b in 1 17 33 980 8192; do \
@ -390,7 +395,12 @@ check: ${TARGET}
./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 2; \
done; done; fi
check-xer:
@if test -f sample-Certificate-1.xer ; then \
for f in sample-Certificate-*.xer; do \
for b in 1 17 33 980 8192; do \
@ -399,7 +409,12 @@ check: ${TARGET}
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
diff $$f ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \
done; done; fi
check-per:
@if test -f sample-Certificate-1.per ; then \
for f in sample-Certificate-[1-9].per; do \
for b in 1 17 33 980 8192; do \
@ -409,6 +424,9 @@ check: ${TARGET}
./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 2; \
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 2; \
rm -f ./.tmp.[123].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 2; \
done; done; fi
@if test -f sample-Certificate-1-padded.per ; then \
for f in sample-*-[1-9]-padded.per; do \
@ -420,10 +438,10 @@ check: ${TARGET}
./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \
diff $$f ./.tmp.1.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \
done; done; fi
@echo ================
@echo All tests passed
@echo ================
distclean: clean
rm -f $(ASN_MODULE_SOURCES)

View File

@ -4740,7 +4740,7 @@ libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
# This file may be used as an input for make(3)
# Remove the lines below to convert it into a pure .am file
TARGET = rrc-dump
CFLAGS += -DHAVE_CONFIG_H -DPDU=DL_DCCH_Message -DASN_PDU_COLLECTION -I.
CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -DPDU=DL_DCCH_Message -DASN_PDU_COLLECTION -I.
OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}
all: DL-DCCH-Message.c $(TARGET)
@ -4776,7 +4776,12 @@ regen-makefile:
PROGNAME=rrc-dump \
../sample.makefile.regen
check: ${TARGET}
check: ${TARGET} check-ber check-xer check-per
@echo ================
@echo All tests passed
@echo ================
check-ber:
@if test -f sample-DL-DCCH-Message-1.[db]er ; then \
for f in sample-DL-DCCH-Message-*.[db]er; do \
for b in 1 17 33 980 8192; do \
@ -4785,7 +4790,12 @@ check: ${TARGET}
./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 2; \
done; done; fi
check-xer:
@if test -f sample-DL-DCCH-Message-1.xer ; then \
for f in sample-DL-DCCH-Message-*.xer; do \
for b in 1 17 33 980 8192; do \
@ -4794,7 +4804,12 @@ check: ${TARGET}
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
diff $$f ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \
done; done; fi
check-per:
@if test -f sample-DL-DCCH-Message-1.per ; then \
for f in sample-DL-DCCH-Message-[1-9].per; do \
for b in 1 17 33 980 8192; do \
@ -4804,6 +4819,9 @@ check: ${TARGET}
./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 2; \
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 2; \
rm -f ./.tmp.[123].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 2; \
done; done; fi
@if test -f sample-DL-DCCH-Message-1-padded.per ; then \
for f in sample-*-[1-9]-padded.per; do \
@ -4815,10 +4833,10 @@ check: ${TARGET}
./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \
diff $$f ./.tmp.1.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \
done; done; fi
@echo ================
@echo All tests passed
@echo ================
distclean: clean
rm -f $(ASN_MODULE_SOURCES)

View File

@ -679,7 +679,7 @@ libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
# This file may be used as an input for make(3)
# Remove the lines below to convert it into a pure .am file
TARGET = tap3dump
CFLAGS += -DHAVE_CONFIG_H -DPDU=DataInterChange -I.
CFLAGS += -DHAVE_CONFIG_H -DJUNKTEST -DPDU=DataInterChange -I.
OBJS=${ASN_MODULE_SOURCES:.c=.o} ${ASN_CONVERTER_SOURCES:.c=.o}
all: DataInterChange.c $(TARGET)
@ -715,7 +715,12 @@ regen-makefile:
PROGNAME=tap3dump \
../sample.makefile.regen
check: ${TARGET}
check: ${TARGET} check-ber check-xer check-per
@echo ================
@echo All tests passed
@echo ================
check-ber:
@if test -f sample-DataInterChange-1.[db]er ; then \
for f in sample-DataInterChange-*.[db]er; do \
for b in 1 17 33 980 8192; do \
@ -724,7 +729,12 @@ check: ${TARGET}
./${TARGET} -b $$b -ixer -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
diff ./.tmp.1.$$$$ ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -iber -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -iber -onull $$f || exit 2; \
done; done; fi
check-xer:
@if test -f sample-DataInterChange-1.xer ; then \
for f in sample-DataInterChange-*.xer; do \
for b in 1 17 33 980 8192; do \
@ -733,7 +743,12 @@ check: ${TARGET}
./${TARGET} -b $$b -iber -oxer ./.tmp.1.$$$$ > ./.tmp.2.$$$$ || exit 2; \
diff $$f ./.tmp.2.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -ixer -onull $$f || exit 2; \
done; done; fi
check-per:
@if test -f sample-DataInterChange-1.per ; then \
for f in sample-DataInterChange-[1-9].per; do \
for b in 1 17 33 980 8192; do \
@ -743,6 +758,9 @@ check: ${TARGET}
./${TARGET} -b $$b -ixer -oder ./.tmp.2.$$$$ > ./.tmp.3.$$$$ || exit 2; \
diff ./.tmp.1.$$$$ ./.tmp.3.$$$$ || exit 2; \
rm -f ./.tmp.[123].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -iper -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -iper -onull $$f || exit 2; \
done; done; fi
@if test -f sample-DataInterChange-1-padded.per ; then \
for f in sample-*-[1-9]-padded.per; do \
@ -754,10 +772,10 @@ check: ${TARGET}
./${TARGET} -b $$b -p $$pdu -ixer -oper ./.tmp.2.$$$$ > ./.tmp.1.$$$$ || exit 2; \
diff $$f ./.tmp.1.$$$$ || exit 2; \
rm -f ./.tmp.[12].$$$$; \
echo "Test junking $$f (please wait)..."; \
./${TARGET} -J0.0001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \
./${TARGET} -J0.001 -n 1000 -b $$b -per-padded -iper -onull $$f || exit 2; \
done; done; fi
@echo ================
@echo All tests passed
@echo ================
distclean: clean
rm -f $(ASN_MODULE_SOURCES)

View File

@ -62,6 +62,15 @@ static enum output_format {
OUT_NULL /* -onull: No pretty-printing */
} oform; /* -o<format> */
#ifdef JUNKTEST /* Enable -J <probability> */
#define JUNKOPT "J:"
static double opt_jprob; /* Junk bit probability */
static int junk_failures;
static void junk_bytes_with_probability(uint8_t *, size_t, double prob);
#else
#define JUNKOPT
#endif
/* Debug output function */
static inline void
DEBUG(const char *fmt, ...) {
@ -89,7 +98,7 @@ main(int ac, char *av[]) {
/*
* Pocess the command-line argments.
*/
while((ch = getopt(ac, av, "i:o:1b:cdn:p:hs:")) != -1)
while((ch = getopt(ac, av, "i:o:1b:cdn:p:hs:" JUNKOPT)) != -1)
switch(ch) {
case 'i':
if(optarg[0] == 'b') { iform = INP_BER; break; }
@ -165,6 +174,17 @@ main(int ac, char *av[]) {
exit(EX_UNAVAILABLE);
}
break;
#ifdef JUNKTEST
case 'J':
opt_jprob = strtod(optarg, 0);
if(opt_jprob <= 0.0 || opt_jprob > 1.0) {
fprintf(stderr,
"-J %s: Probability range 0..1 expected \n",
optarg);
exit(EX_UNAVAILABLE);
}
break;
#endif /* JUNKTEST */
case 'h':
default:
fprintf(stderr, "Usage: %s [options] <data.ber> ...\n", av[0]);
@ -200,6 +220,9 @@ main(int ac, char *av[]) {
" -d Enable debugging (-dd is even better)\n"
" -n <num> Process files <num> times\n"
" -s <size> Set the stack usage limit (default is %d)\n"
#ifdef JUNKTEST
" -J <prob> Set random junk test bit garbaging probability\n"
#endif
, (long)suggested_bufsize, _ASN_DEFAULT_STACK_MAX);
exit(EX_USAGE);
}
@ -258,6 +281,9 @@ main(int ac, char *av[]) {
switch(oform) {
case OUT_NULL:
#ifdef JUNKTEST
if(opt_jprob == 0.0)
#endif
fprintf(stderr, "%s: decoded successfully\n", name);
break;
case OUT_TEXT: /* -otext */
@ -301,6 +327,13 @@ main(int ac, char *av[]) {
}
}
#ifdef JUNKTEST
if(opt_jprob > 0.0) {
fprintf(stderr, "Junked %f OK (%d/%d)\n",
opt_jprob, junk_failures, number_of_iterations);
}
#endif /* JUNKTEST */
return 0;
}
@ -338,12 +371,13 @@ buffer_dump() {
((*p >> 0) & 1) ? '1' : '0');
}
if(DynamicBuffer.unbits) {
int shift;
unsigned int shift;
fprintf(stderr, " ");
for(shift = 7; shift >= DynamicBuffer.unbits; shift--)
fprintf(stderr, "%c", ((*p >> shift) & 1) ? '1' : '0');
fprintf(stderr, " %d:%d\n",
DynamicBuffer.length - 1, 8 - DynamicBuffer.unbits);
fprintf(stderr, " %ld:%ld\n",
(long)DynamicBuffer.length - 1,
(long)8 - DynamicBuffer.unbits);
} else {
fprintf(stderr, " %d\n", DynamicBuffer.length);
}
@ -482,7 +516,7 @@ static void add_bytes_to_buffer(const void *data2add, size_t bytes) {
DynamicBuffer.data + DynamicBuffer.offset,
DynamicBuffer.length);
FREEMEM(DynamicBuffer.data);
DynamicBuffer.data = (char *)p;
DynamicBuffer.data = (uint8_t *)p;
DynamicBuffer.offset = 0;
DynamicBuffer.allocated = newsize;
DynamicBuffer.nreallocs++;
@ -536,7 +570,7 @@ data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, const char *na
/* prepare the file buffer */
if(fbuf_size != suggested_bufsize) {
fbuf = (char *)REALLOC(fbuf, suggested_bufsize);
fbuf = (uint8_t *)REALLOC(fbuf, suggested_bufsize);
if(!fbuf) {
perror("realloc()");
exit(EX_OSERR);
@ -564,9 +598,9 @@ data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, const char *na
|| feof(file) == 0
|| (tolerate_eof && DynamicBuffer.length)
;) {
int ecbits = 0; /* Extra consumed bits in case of PER */
char *i_bptr;
size_t i_size;
int ecbits = 0; /* Extra consumed bits in case of PER */
uint8_t *i_bptr;
size_t i_size;
/*
* Copy the data over, or use the original buffer.
@ -583,6 +617,10 @@ data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, const char *na
DEBUG("Decoding %ld bytes", (long)i_size);
#ifdef JUNKTEST
junk_bytes_with_probability(i_bptr, i_size, opt_jprob);
#endif
switch(iform) {
case INP_BER:
rval = ber_decode(opt_codec_ctx, pduType,
@ -596,12 +634,28 @@ data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, const char *na
rval = uper_decode(opt_codec_ctx, pduType,
(void **)&structure, i_bptr, i_size, 0,
DynamicBuffer.unbits);
ecbits = rval.consumed % 8; /* Extra bits */
rval.consumed /= 8; /* Convert to value in bytes! */
/* Check if input is byte-padded at the end */
if(opt_ippad && ecbits && rval.code == RC_OK) {
rval.consumed++;
ecbits = 0;
/* PER requires returns number of bits, but a catch! */
switch(rval.code) {
case RC_OK:
/* Check if input is byte-padded at the end */
if(opt_ippad && (rval.consumed % 8)) {
rval.consumed /= 8;
rval.consumed++;
ecbits = 0;
break;
}
/* Fall through */
case RC_FAIL:
ecbits = rval.consumed % 8; /* Extra bits */
rval.consumed /= 8; /* Convert into bytes! */
break;
case RC_WMORE:
/* PER does not support restartability */
ASN_STRUCT_FREE(*pduType, structure);
structure = 0;
rval.consumed = 0;
/* Continue accumulating data */
break;
}
break;
}
@ -657,7 +711,7 @@ data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, const char *na
break;
}
/* Clean up partially decoded structure */
DEBUG("Clean up partially decoded structure");
ASN_STRUCT_FREE(*pduType, structure);
new_offset = DynamicBuffer.bytes_shifted + DynamicBuffer.offset;
@ -670,6 +724,17 @@ data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, const char *na
|| DynamicBuffer.length
|| new_offset - old_offset > ((iform == INP_XER)?sizeof("\r\n")-1:0)
) {
#ifdef JUNKTEST
/*
* Nothing's wrong with being unable to decode junk.
* Simulate EOF.
*/
junk_failures++;
errno = 0;
return 0;
#endif
DEBUG("ofp %d, no=%ld, oo=%ld, dbl=%ld",
on_first_pdu, (long)new_offset, (long)old_offset,
(long)DynamicBuffer.length);
@ -723,3 +788,39 @@ static char *argument_to_name(char *av[], int idx) {
? "standard input"
: av[idx];
}
#ifdef JUNKTEST
/*
* Fill bytes with some garbage with specified probability (more or less).
*/
static void
junk_bytes_with_probability(uint8_t *buf, size_t size, double prob) {
static int junkmode;
uint8_t *ptr;
uint8_t *end;
if(opt_jprob <= 0.0) return;
for(ptr = buf, end = ptr + size; ptr < end; ptr++) {
int byte = *ptr;
if(junkmode++ & 1) {
if((((double)random() / RAND_MAX) < prob))
byte = random() & 0xff;
} else {
#define BPROB(b) ((((double)random() / RAND_MAX) < prob) ? b : 0)
byte ^= BPROB(0x80);
byte ^= BPROB(0x40);
byte ^= BPROB(0x20);
byte ^= BPROB(0x10);
byte ^= BPROB(0x08);
byte ^= BPROB(0x04);
byte ^= BPROB(0x02);
byte ^= BPROB(0x01);
}
if(byte != *ptr) {
DEBUG("Junk buf[%d] %02x -> %02x",
ptr - buf, *ptr, byte);
*ptr = byte;
}
}
}
#endif /* JUNKTEST */