Commit a8530705 authored by Ondřej Surý's avatar Ondřej Surý

Convert zscanner tests to C TAP Harness

parent 2f15ea87
......@@ -50,8 +50,9 @@
/m4/ltversion.m4
/m4/lt~obsolete.m4
# Binaries
/src/tests/unittests
/src/zscanner/zscanner-tool
/tests/runtests
/src/zscanner/tests/runtests
/src/zscanner/tests/zscanner-tool
/src/knotc
/src/knotd
/src/kdig
......@@ -61,16 +62,11 @@
/src/knot/conf/libknotd_la-cf-lex.c
/src/knot/conf/libknotd_la-cf-parse.c
/src/knot/conf/libknotd_la-cf-parse.h
/src/tests/libknot/parsed_data.rc
/src/tests/libknot/parsed_data_queries.rc
/src/tests/libknot/raw_data.rc
/src/tests/libknot/raw_data_queries.rc
/src/tests/libknot/realdata/
/src/tests/sample_conf.rc
src/zscanner/descriptor.h
src/zscanner/descriptor.c
src/zscanner/scanner.c.in
src/zscanner/test/cases/06-0_INCLUDE.in
src/zscanner/test/cases/06-3_INCLUDE.in
src/zscanner/test/cases/06-4_INCLUDE.in
src/zscanner/test/run_tests.sh
/tests/sample_conf.rc
/src/zscanner/descriptor.h
/src/zscanner/descriptor.c
/src/zscanner/scanner.c.in
/src/zscanner/tests/tap/libtap.a
/tests/tap/libtap.a
/tests/tmp/
/src/zscanner/tests/tmp/
......@@ -319,9 +319,6 @@ AC_CONFIG_FILES([Makefile
src/Makefile
samples/Makefile
src/zscanner/Makefile
src/zscanner/test/cases/06-3_INCLUDE.in:src/zscanner/test/cases/06-3_INCLUDE.inin
src/zscanner/test/cases/06-4_INCLUDE.in:src/zscanner/test/cases/06-4_INCLUDE.inin
src/zscanner/test/cases/06-0_INCLUDE.in:src/zscanner/test/cases/06-0_INCLUDE.inin
man/khost.1
man/knotc.8
man/knotd.8
......@@ -331,6 +328,4 @@ AC_CONFIG_FILES([Makefile
man/knsec3hash.1
])
AC_CONFIG_FILES([src/zscanner/test/run_tests.sh], [chmod a+x src/zscanner/test/run_tests.sh])
AC_OUTPUT
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
AM_CFLAGS = -I$(top_srcdir)/src
noinst_PROGRAMS = zscanner-tool
noinst_LTLIBRARIES = libzscanner.la
TESTS = test/run_tests.sh
EXTRA_DIST = \
scanner.rl \
scanner_body.rl \
test/run_tests.sh \
test/cases
scanner_body.rl
BUILT_SOURCES = descriptor.h descriptor.c
CLEANFILES = descriptor.h descriptor.c
......@@ -31,13 +26,6 @@ scanner.c: scanner.rl scanner_body.rl
sed '/#line/d' $@.in > $@
endif
zscanner_tool_SOURCES = \
test/zscanner-tool.c \
test/tests.h \
test/tests.c \
test/processing.h \
test/processing.c
libzscanner_la_SOURCES = \
zscanner.h \
error.h \
......@@ -50,4 +38,5 @@ libzscanner_la_SOURCES = \
scanner_functions.c
libzscanner_la_LIBADD = @LIBOBJS@
zscanner_tool_LDADD = libzscanner.la @LIBOBJS@
include $(srcdir)/tests/Makefile.inc
$ORIGIN .
$TTL 1
; KO
$INCLUDE @abs_builddir@/ ; Given file is a directory
$ORIGIN .
$TTL 1
; KO
$INCLUDE @abs_builddir@/zscanner_tests/file-doesnt-exist ; File doesn't exist
#!/bin/sh
TESTS_DIR="@abs_srcdir@/cases"
OUTS_DIR="@abs_builddir@/.out"
TEST_BIN="@builddir@/zscanner-tool -m 2"
# Delete temporary output directory at exit.
trap "chmod -R u+rw ${OUTS_DIR} && rm -rf ${OUTS_DIR}" EXIT
# If an argument -> verbose mode (stores result in /tmp).
if [ $# -ne 0 ]; then
RESULT_DIR=`mktemp -d /tmp/zscanner_test.XXXX`
echo "ZSCANNER TEST ${RESULT_DIR}"
fi
# Create output directory.
mkdir -p "${OUTS_DIR}"
# Run zscanner on all test zone files.
for file in $(find "${TESTS_DIR}" -name "*.in" | sort -n); do
fileout="$(basename "${file}" .in).out"
# Run zscanner.
${TEST_BIN} . "${file}" > "${OUTS_DIR}/${fileout}"
# Compare result with the reference one.
cmp -s "${OUTS_DIR}/${fileout}" "${TESTS_DIR}/${fileout}"
RET=$?
# Check for differences.
if [ $RET -ne 0 ]; then
# If verbose print diff.
if [ $# -ne 0 ]; then
echo "\n=== ${fileout} DIFF ======================"
diff "${OUTS_DIR}/${fileout}" "${TESTS_DIR}/${fileout}"
else
exit $RET
fi
fi
done
# Store test result.
if [ $# -ne 0 ]; then
cp -a "${OUTS_DIR}/." "${RESULT_DIR}/"
echo "\nFINISHED ${RESULT_DIR}"
fi
# -*- mode: makefile; -*-
check_PROGRAMS = \
tests/runtests \
tests/zscanner-tool
check_LIBRARIES = tests/tap/libtap.a
AM_CPPFLAGS = \
-I$(top_srcdir)/src \
-DSYSCONFDIR='"$(sysconfdir)"' \
-DSBINDIR='"$(sbindir)"'
tests_runtests_CPPFLAGS = \
-DSOURCE='"$(abs_srcdir)/tests"' \
-DBUILD='"$(abs_builddir)/tests"'
tests_tap_libtap_a_CPPFLAGS = -I$(abs_srcdir)/tests
tests_tap_libtap_a_SOURCES = \
tests/tap/basic.c tests/tap/basic.h \
tests/tap/float.c tests/tap/float.h \
tests/tap/macros.h
check-local: $(check_PROGRAMS)
cd tests && ./runtests -l $(abs_srcdir)/tests/TESTS
tests_zscanner_tool_SOURCES = \
tests/zscanner-tool.c \
tests/tests.h \
tests/tests.c \
tests/processing.h \
tests/processing.c
tests_zscanner_tool_LDADD = libzscanner.la @LIBOBJS@
......@@ -19,10 +19,10 @@ $INCLUDE \./includes/include2 _a_.-b-c-./d/. ; Slashed character in file name,
$INCLUDE ./includes/include2 \0320\ \\\"\.\@\*.tld. ; Origin with special chars
5. NS @
$INCLUDE @abs_builddir@/includes/include2 ; Absolute path without origin
$INCLUDE @BUILD@/includes/include2 ; Absolute path without origin
6. NS @
$INCLUDE @abs_builddir@/includes/include2 tld. ; Absolute path with origin
$INCLUDE @BUILD@/includes/include2 tld. ; Absolute path with origin
7. NS @
; KO
......
$ORIGIN .
$TTL 1
; KO
$INCLUDE @BUILD@/ ; Given file is a directory
$ORIGIN .
$TTL 1
; KO
$INCLUDE @BUILD@/zscanner_tests/file-doesnt-exist ; File doesn't exist
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment