Skip to content

Commit

Permalink
tests/parsing: don't create files in the source directories!
Browse files Browse the repository at this point in the history
- this allows regression testing with a read-only source tree
  • Loading branch information
robohack committed Feb 9, 2024
1 parent 6b3fb34 commit 5985616
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
7 changes: 2 additions & 5 deletions test/parsing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ MAN = # empty
# don't install
proginstall:

# XXX N.B.: this currently creates files in the source tree, but it does clean
# them up properly if all goes well and it is not interrupted.
#
regress:
.if defined(USE_ASAN)
if [ -x /usr/sbin/paxctl ]; then /usr/sbin/paxctl +a ${.OBJDIR}/${PROG}; fi
ulimit -v unlimited && cd ${.CURDIR} && testBin=${.OBJDIR}/${PROG} sh ./run_tests.sh
ulimit -v unlimited && cd ${.CURDIR} && testBin=${.OBJDIR}/${PROG} OBJDIR=${.OBJDIR} sh ./run_tests.sh
.else
cd ${.CURDIR} && testBin=${.OBJDIR}/${PROG} sh ./run_tests.sh
cd ${.CURDIR} && testBin=${.OBJDIR}/${PROG} OBJDIR=${.OBJDIR} sh ./run_tests.sh
.endif

.include <bsd.prog.mk>
Expand Down
12 changes: 7 additions & 5 deletions test/parsing/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# XXX this should be a Makefile to facilitate parallel runs!

# xxx there should probably be a trap set to remove the temp files....

# note: this script requires a modern POSIX shell with $(command substitution)
# and $((arithmetic + expressions))
#
Expand Down Expand Up @@ -133,9 +135,9 @@ for file in cases/*.json ; do

# parse with a read buffer size ranging from 1-31 to stress stream parsing
while [ $iter -lt 32 ] && [ $success = "SUCCESS" ] ; do
$testBin $allowPartials $allowComments $allowGarbage $allowMultiple -b $iter < $file > ${file}.test 2>&1
$testBin $allowPartials $allowComments $allowGarbage $allowMultiple -b $iter < $file > ${OBJDIR:-.}/${fileShort}.test 2>&1
if [ $? -eq 0 ] ; then
diff ${DIFF_FLAGS} ${file}.gold ${file}.test > ${file}.out
diff ${DIFF_FLAGS} ${file}.gold ${OBJDIR:-.}/${fileShort}.test > ${OBJDIR:-.}/${fileShort}.out
if [ $? -eq 0 ] ; then
if [ $iter -eq 31 ] ; then
testsSucceeded=$(( $testsSucceeded + 1 ))
Expand All @@ -150,12 +152,12 @@ for file in cases/*.json ; do
success="FAILURE"
iter=32
${echo} "${nl}"
if [ -f ${file}.out ] ; then
cat ${file}.out
if [ -f ${OBJDIR:-.}/${fileShort}.out ] ; then
cat ${OBJDIR:-.}/${fileShort}.out
fi
fi
iter=$(( iter + 1 ))
rm -f ${file}.test ${file}.out
rm -f ${OBJDIR:-.}/${fileShort}.test ${OBJDIR:-.}/${fileShort}.out
done

${echo} "${success}${nl}"
Expand Down

0 comments on commit 5985616

Please sign in to comment.