Skip to content
Snippets Groups Projects
Commit e52e2815 authored by Daniel Salzman's avatar Daniel Salzman
Browse files

unittests: add zscanner unittest

parent 9846b94f
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,7 @@ src/unittests
src/unittests-libknot
src/unittests-libknot-realdata
src/unittests-zcompile
src/unittests-zscanner
src/zscanner-tool
src/knotc
src/knotd
src/knot-zcompile
......
......@@ -17,6 +17,7 @@ doc/requirements.texi
doc/running.texi
doc/security.texi
doc/troubleshooting.texi
man/Makefile.am
samples/Makefile.am
src/Makefile.am
src/common/acl.c
......@@ -214,6 +215,8 @@ src/tests/knot/server_tests.c
src/tests/knot/server_tests.h
src/tests/libknot/dname_tests.c
src/tests/libknot/dname_tests.h
src/tests/libknot/rrset_tests.c
src/tests/libknot/rrset_tests.h
src/tests/libknot/sign_tests.c
src/tests/libknot/sign_tests.h
src/tests/libknot/unittests_libknot.c
......@@ -221,8 +224,6 @@ src/tests/libknot/wire_tests.c
src/tests/libknot/wire_tests.h
src/tests/libknot/ztree_tests.c
src/tests/libknot/ztree_tests.h
src/tests/libknot/rrset_tests.c
src/tests/libknot/rrset_tests.h
src/tests/unittests_main.c
src/tests/xfr_tests.c
src/tests/xfr_tests.h
......
ACLOCAL_AMFLAGS = -I ../m4
libexec_PROGRAMS = unittests unittests-xfr unittests-zscanner unittests-libknot
libexec_PROGRAMS = unittests unittests-xfr unittests-libknot zscanner-tool
sbin_PROGRAMS = knotc knotd kdig khost knsupdate
# $(YACC) will generate header file
......@@ -109,6 +109,8 @@ unittests_SOURCES = \
tests/knot/server_tests.h \
tests/knot/rrl_tests.h \
tests/knot/rrl_tests.c \
tests/zscanner/zscanner_tests.h \
tests/zscanner/zscanner_tests.c \
tests/libknot/dname_tests.h \
tests/libknot/dname_tests.c \
tests/libknot/ztree_tests.h \
......@@ -122,7 +124,7 @@ unittests_SOURCES = \
unittests_xfr_SOURCES = \
tests/xfr_tests.c \
tests/xfr_tests.h
unittests_libknot_SOURCES = \
tests/libknot/unittests_libknot.c \
tests/libknot/dname_tests.h \
......@@ -314,13 +316,13 @@ libknotd_la_SOURCES = \
zscanner/scanner.c: zscanner/scanner.rl zscanner/scanner_body.rl
$(RAGEL) $(FSM_TYPE) -s -o zscanner/scanner.c zscanner/scanner.rl
unittests_zscanner_SOURCES = \
zscanner/test/zscanner_test.c \
zscanner_tool_SOURCES = \
zscanner/test/zscanner-tool.c \
zscanner/test/tests.h \
zscanner/test/tests.c \
zscanner/test/processing.h \
zscanner/test/processing.c
libzscanner_la_SOURCES = \
zscanner/file_loader.h \
zscanner/file_loader.c \
......@@ -340,11 +342,10 @@ knsupdate_LDADD = libknotd.la libknot.la libknots.la libzscanner.la @LIBOBJS@
unittests_LDADD = libknotd.la libknots.la @LIBOBJS@
unittests_libknot_LDADD = libknotd.la libknots.la @LIBOBJS@
unittests_xfr_LDADD = libknotd.la libknot.la libknots.la @LIBOBJS@
unittests_zscanner_LDADD = libknots.la libknot.la libknotd.la libzscanner.la @LIBOBJS@
zscanner_tool_LDADD = libknots.la libknot.la libknotd.la libzscanner.la @LIBOBJS@
# automake complains on % rules:
# `%'-style pattern rules are a GNU make extension
tests/sample_conf.rc: tests/files/sample_conf
../resource.sh tests/files/sample_conf >$@
......@@ -32,6 +32,7 @@
#include "tests/knot/server_tests.h"
#include "tests/knot/conf_tests.h"
#include "tests/knot/rrl_tests.h"
#include "tests/zscanner/zscanner_tests.h"
#include "tests/libknot/wire_tests.h"
#include "tests/libknot/dname_tests.h"
#include "tests/libknot/ztree_tests.h"
......@@ -65,6 +66,9 @@ int main(int argc, char *argv[])
&server_tests_api, //! Server unit
&rrl_tests_api, //! RRL tests
/* Zone scanner. */
&zscanner_tests_api, //! Wrapper for external unittests
/* Libknot library. */
&wire_tests_api,
&dname_tests_api,
......
/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tests/zscanner/zscanner_tests.h"
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
static int zscanner_tests_count(int argc, char *argv[]);
static int zscanner_tests_run(int argc, char *argv[]);
unit_api zscanner_tests_api = {
"Zone scanner",
&zscanner_tests_count,
&zscanner_tests_run
};
static int zscanner_tests_count(int argc, char *argv[])
{
return 1;
}
static int zscanner_tests_run(int argc, char *argv[])
{
int ret;
// Run zscanner unittests via external tool.
ret = system("cd ./zscanner/test; ./run_tests.sh brief");
cmp_ok(ret, "==", 0, "zscanner unittests");
return 0;
}
/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _ZSCANNER_TESTS_H_
#define _ZSCANNER_TESTS_H_
#include "common/libtap/tap_unit.h"
/* Unit API. */
unit_api zscanner_tests_api;
#endif /* _ZSCANNER_TESTS_H_ */
......@@ -2,19 +2,43 @@
TESTS_DIR="./tests"
OUTS_DIR="/tmp/zscanner_tests"
TEST_BIN="../../unittests-zscanner -m 2"
TEST_BIN="../../zscanner-tool -m 2"
SEPARATION="========================================================="
# If verbose (default - no parameter) mode.
if [ $# -eq 0 ]; then
echo "Launching zscanner tests"
fi
# Create output directory and copy include zone files.
mkdir -p ${OUTS_DIR}/${TESTS_DIR}
cp -r ${TESTS_DIR}/includes ${OUTS_DIR}
echo ${SEPARATION}
# Run zscanner on all test zone files.
for file in `find ${TESTS_DIR} -name "*.in" | sort`; do
fileout=`echo "${file}" | sed 's/.in/.out/'`
# Run zscanner.
${TEST_BIN} . ${file} > ${OUTS_DIR}/${fileout}
echo ${fileout}
diff ${OUTS_DIR}/${fileout} ${fileout}
echo ${SEPARATION}
# Compare result with a reference one.
cmp ${OUTS_DIR}/${fileout} ${fileout} > /dev/null 2>&1
# Check for differences.
if [ $? -ne 0 ]; then
# If verbose print diff.
if [ $# -eq 0 ]; then
echo "\n=== ${fileout} DIFF ======================"
diff ${OUTS_DIR}/${fileout} ${fileout}
# Return error and exit.
else
return 1
fi
fi
done
if [ $# -eq 0 ]; then
echo "\nFinished"
else
return 0
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment