Commit 4a76305b authored by Daniel Salzman's avatar Daniel Salzman

tests: move zscanner tests and libtap + improvements

parent 47ffd266
......@@ -69,9 +69,6 @@
# zscanner
/src/zscanner/libzscanner.pc
/src/zscanner/scanner.c
/src/zscanner/tests/tmp/
/src/zscanner/tests/unittests
/src/zscanner/tests/zscanner-tool
/src/zscanner/version.h
# Binaries
......@@ -84,14 +81,9 @@
/src/knsec3hash
/src/knsupdate
/src/kzonecheck
/src/rosedb_tool
/src/utils/pykeymgr/pykeymgr
# Plugin binaries
/src/rosedb_tool
# Generated tarballs
/knot-*.tar.gz
/knot-*.tar.xz
# Code coverage
......
libtap/runtests.c
libtap/tap/basic.c
libtap/tap/basic.h
libtap/tap/files.c
libtap/tap/files.h
libtap/tap/float.c
libtap/tap/float.h
libtap/tap/macros.h
src/contrib/asan.h
src/contrib/base32hex.c
src/contrib/base32hex.h
......@@ -430,11 +422,6 @@ src/zscanner/functions.h
src/zscanner/scanner.h
src/zscanner/scanner.rl
src/zscanner/scanner_body.rl
src/zscanner/tests/processing.c
src/zscanner/tests/processing.h
src/zscanner/tests/tests.c
src/zscanner/tests/tests.h
src/zscanner/tests/zscanner-tool.c
tests-fuzz/fuzz_packet.c
tests-fuzz/fuzz_zscanner.c
tests-fuzz/knotd_wrap/afl-loop.h
......@@ -442,6 +429,14 @@ tests-fuzz/knotd_wrap/server.c
tests-fuzz/knotd_wrap/tcp-handler.c
tests-fuzz/knotd_wrap/udp-handler.c
tests-fuzz/main.c
tests/_libtap/runtests.c
tests/_libtap/tap/basic.c
tests/_libtap/tap/basic.h
tests/_libtap/tap/files.c
tests/_libtap/tap/files.h
tests/_libtap/tap/float.c
tests/_libtap/tap/float.h
tests/_libtap/tap/macros.h
tests/contrib/test_base32hex.c
tests/contrib/test_base64.c
tests/contrib/test_dynarray.c
......@@ -523,3 +518,6 @@ tests/modules/test_onlinesign.c
tests/modules/test_rrl.c
tests/utils/test_cert.c
tests/utils/test_lookup.c
tests/zscanner/processing.c
tests/zscanner/processing.h
tests/zscanner/zscanner-tool.c
libtap
src
src/contrib
src/dnssec
......@@ -8,4 +7,4 @@ src/dnssec/shared
src/zscanner
tests
tests-fuzz
tests-fuzz/wrap
tests-fuzz/knotd_wrap
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = libtap src tests tests-fuzz python samples doc
SUBDIRS = src tests tests-fuzz python samples doc
.PHONY: singlehtml install-singlehtml
singlehtml install-singlehtml:
......@@ -7,8 +7,7 @@ singlehtml install-singlehtml:
.PHONY: check-compile
check-compile:
$(MAKE) $(AM_MAKEFLAGS) -C libtap $@
$(MAKE) $(AM_MAKEFLAGS) -C src $@
$(MAKE) $(AM_MAKEFLAGS) -C tests/_libtap $@
$(MAKE) $(AM_MAKEFLAGS) -C tests $@
$(MAKE) $(AM_MAKEFLAGS) -C tests-fuzz $@
......
......@@ -581,8 +581,8 @@ AC_DEFINE_UNQUOTED([CONFIGURE_SUMMARY],["$result_msg_esc"],[Configure summary])
AC_CONFIG_FILES([Makefile
Doxyfile
doc/Makefile
libtap/Makefile
tests/Makefile
tests/_libtap/Makefile
tests-fuzz/Makefile
samples/Makefile
python/Makefile
......
......@@ -5,10 +5,9 @@
#
SOURCES = [
"src/*.c", "src/*.h", "src/*.rl", "src/*.l",
"src/*.y", "tests/*.c", "tests/*.h",
"src/*.c", "src/*.h", "src/*.rl",
"tests/*.c", "tests/*.h",
"tests-fuzz/*.c", "tests-fuzz/*.h",
"libtap/*.c", "libtap/*.h",
]
OUTPUT_FILE = "Knot.files"
......
ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
SUBDIRS = zscanner dnssec contrib/dnstap .
.PHONY: check-compile
check-compile:
$(MAKE) $(AM_MAKEFLAGS) -C zscanner $@
$(MAKE) $(AM_MAKEFLAGS) -C dnssec $@
lib_LTLIBRARIES = \
libknot.la
noinst_LTLIBRARIES = \
......
......@@ -44,5 +44,3 @@ nodist_libzscanner_la_SOURCES = \
libzscanner_la_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAG_VISIBILITY)
libzscanner_la_LDFLAGS = \
$(libzscanner_VERSION_INFO)
include $(srcdir)/tests/Makefile.inc
LDADD = \
$(top_builddir)/src/zscanner/libzscanner.la
tests_zscanner_tool_SOURCES = \
tests/zscanner-tool.c \
tests/tests.h \
tests/tests.c \
tests/processing.h \
tests/processing.c
check_PROGRAMS = \
tests/zscanner-tool
check_SCRIPTS = \
tests/unittests
CLEANFILES += $(check_SCRIPTS) tests/runtests.log
edit = sed \
-e 's|@top_srcdir[@]|$(abs_top_srcdir)|g' \
-e 's|@top_builddir[@]|$(abs_top_builddir)|g'
tests/unittests:
@$(edit) < $(top_srcdir)/src/zscanner/$@.in > $(top_builddir)/src/zscanner/$@
@chmod +x $(top_builddir)/src/zscanner/$@
check-compile: $(check_SCRIPTS) $(check_PROGRAMS)
AM_V_RUNTESTS = $(am__v_RUNTESTS_@AM_V@)
am__v_RUNTESTS_ = $(am__v_RUNTESTS_@AM_DEFAULT_V@)
am__v_RUNTESTS_0 =
am__v_RUNTESTS_1 = RET=$$?; if [ "$$RET" != "0" ]; then cat "$(top_builddir)/src/zscanner/tests/runtests.log"; exit $$RET; fi
check-local: $(check_PROGRAMS)
@$(top_builddir)/libtap/runtests \
-s $(top_srcdir)/src/zscanner/tests \
-b $(top_builddir)/src/zscanner/tests \
-L $(top_builddir)/src/zscanner/tests/runtests.log \
$(top_builddir)/src/zscanner/tests/unittests; \
$(AM_V_RUNTESTS)
EXTRA_DIST += \
tests/unittests.in \
tests/TESTS \
tests/data
/* 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 <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "tests/tests.h"
#include "functions.c"
int test__date_to_timestamp(void)
{
time_t ref_timestamp, max_timestamp;
uint32_t test_timestamp;
uint8_t buffer[16];
uint64_t val1, val2; // For time_t type unification.
struct tm tm;
// Set UTC for strftime.
putenv("TZ=UTC");
tzset();
// Get maximal allowed timestamp.
strptime("21051231235959", "%Y%m%d%H%M%S", &tm);
max_timestamp = mktime(&tm);
// Testing loop over whole input interval.
for (ref_timestamp = 0;
ref_timestamp < max_timestamp;
ref_timestamp += 1) {
struct tm result;
// Get reference (correct) timestamp.
strftime((char*)buffer, sizeof(buffer), "%Y%m%d%H%M%S",
gmtime_r(&ref_timestamp, &result));
// Get testing timestamp.
test_timestamp = 0U; // prevents Wunitialized
date_to_timestamp(buffer, &test_timestamp);
// Some continuous loging.
if (ref_timestamp % 10000000 == 0) {
val1 = ref_timestamp;
printf("%s = %"PRIu64"\n", buffer, val1);
}
// Comparing results.
if (ref_timestamp != test_timestamp) {
val1 = ref_timestamp;
if (ref_timestamp > test_timestamp) {
val2 = ref_timestamp - test_timestamp;
printf("%s = %"PRIu64", in - out = %"PRIu64"\n",
buffer, val1, val2);
} else {
val2 = test_timestamp - ref_timestamp;
printf("%s = %"PRIu64", out - in = %"PRIu64"\n",
buffer, val1, val2);
}
return -1;
}
}
return 0;
}
/* Copyright (C) 2017 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/>.
*/
/*!
* \file
*
* \brief Zone scanner test functions.
*
* \addtogroup zone_scanner_test
* @{
*/
#pragma once
int test__date_to_timestamp(void);
/*! @} */
......@@ -87,3 +87,7 @@
/utils/test_cert
/utils/test_lookup
/zscanner/tmp
/zscanner/test_zscanner
/zscanner/zscanner-tool
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = _libtap .
AM_CPPFLAGS = \
-include $(top_builddir)/src/config.h \
-I$(top_srcdir)/libtap \
-I$(top_srcdir)/tests/_libtap \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/dnssec/lib \
-I$(top_srcdir)/src/dnssec/shared \
......@@ -8,13 +11,20 @@ AM_CPPFLAGS = \
$(gnutls_CFLAGS)
LDADD = \
$(top_builddir)/libtap/libtap.la \
$(top_builddir)/tests/_libtap/libtap.la \
$(top_builddir)/src/dnssec/libdnssec.la \
$(top_builddir)/src/libknot.la \
$(top_builddir)/src/libknotd.la \
$(top_builddir)/src/libcontrib.la
$(top_builddir)/src/libcontrib.la \
$(top_builddir)/src/zscanner/libzscanner.la
EXTRA_DIST = dnssec/sample_keys.h
EXTRA_DIST = \
dnssec/sample_keys.h \
knot/semantic_check_data \
knot/test_semantic_check.in \
zscanner/data \
zscanner/test_zscanner.in \
zscanner/TESTS
check_PROGRAMS = \
contrib/test_base32hex \
......@@ -122,7 +132,7 @@ check_PROGRAMS += \
endif
endif
dnssec_keystore_pkcs11_CPPFLAGS = \
dnssec_test_keystore_pkcs11_CPPFLAGS = \
$(AM_CPPFLAGS) \
-DLIBDIR='"$(libdir)"'
......@@ -131,7 +141,7 @@ utils_test_lookup_CPPFLAGS = \
$(libedit_CFLAGS)
utils_test_lookup_LDADD = \
$(top_builddir)/libtap/libtap.la \
$(top_builddir)/tests/_libtap/libtap.la \
$(top_builddir)/src/libknotus.la \
$(libedit_LIBS)
......@@ -140,13 +150,35 @@ utils_test_cert_CPPFLAGS = \
$(libedit_CFLAGS)
utils_test_cert_LDADD = \
$(top_builddir)/libtap/libtap.la \
$(top_builddir)/tests/_libtap/libtap.la \
$(top_builddir)/src/libknotus.la \
$(libedit_LIBS)
CLEANFILES = runtests.log
EXTRA_PROGRAMS = \
zscanner/zscanner-tool
zscanner_zscanner_tool_SOURCES = \
zscanner/zscanner-tool.c \
zscanner/processing.h \
zscanner/processing.c
check_SCRIPTS = \
knot/test_semantic_check \
zscanner/test_zscanner
edit = $(SED) \
-e 's|@top_srcdir[@]|$(abs_top_srcdir)|g' \
-e 's|@top_builddir[@]|$(abs_top_builddir)|g'
knot/test_semantic_check:
@$(edit) < $(top_srcdir)/tests/$@.in > $(top_builddir)/tests/$@
@chmod +x $(top_builddir)/tests/$@
zscanner/test_zscanner: zscanner/zscanner-tool
@$(edit) < $(top_srcdir)/tests/$@.in > $(top_builddir)/tests/$@
@chmod +x $(top_builddir)/tests/$@
include $(srcdir)/knot/semantic_check_data/Makefile.inc
CLEANFILES = $(check_SCRIPTS) $(EXTRA_PROGRAMS) runtests.log
check-compile: $(check_PROGRAMS) $(check_SCRIPTS)
......@@ -155,10 +187,8 @@ am__v_RUNTESTS_ = $(am__v_RUNTESTS_@AM_DEFAULT_V@)
am__v_RUNTESTS_0 =
am__v_RUNTESTS_1 = RET=$$?; if [ "$$RET" != "0" ]; then cat "$(builddir)/runtests.log"; exit $$RET; fi
check-local: $(check_PROGRAMS) $(check_SCRIPTS)
@$(top_builddir)/libtap/runtests -s $(srcdir) \
-b $(builddir) \
-L $(builddir)/runtests.log \
$(check_PROGRAMS) $(check_SCRIPTS); \
@$(top_builddir)/tests/_libtap/runtests -s $(srcdir) -b $(builddir) \
-L $(builddir)/runtests.log $(check_PROGRAMS) $(check_SCRIPTS); \
$(AM_V_RUNTESTS)
knot_test_acl_SOURCES = knot/test_acl.c knot/test_conf.h
......
......@@ -3,9 +3,12 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src
libtap_la_SOURCES = \
tap/basic.c tap/basic.h \
tap/files.c tap/files.h \
tap/float.c tap/float.h \
tap/basic.c \
tap/basic.h \
tap/files.c \
tap/files.h \
tap/float.c \
tap/float.h \
tap/macros.h
check_LTLIBRARIES = libtap.la
......
check_SCRIPTS = \
knot/test_semantic_check
CLEANFILES += $(check_SCRIPTS)
edit = $(SED) \
-e 's|@top_srcdir[@]|$(abs_top_srcdir)|g' \
-e 's|@top_builddir[@]|$(abs_top_builddir)|g'
knot/test_semantic_check: $(top_srcdir)/tests/knot/test_semantic_check.in
@$(edit) < $(top_srcdir)/tests/knot/test_semantic_check.in > $(top_builddir)/tests/knot/test_semantic_check
@chmod +x $(top_builddir)/tests/knot/test_semantic_check
EXTRA_DIST += \
knot/test_semantic_check.in \
knot/semantic_check_data
......@@ -3,7 +3,7 @@
KZONECHECK="@top_builddir@/src/kzonecheck"
DATA="@top_srcdir@/tests/knot/semantic_check_data"
. "@top_srcdir@/libtap/tap/libtap.sh"
. "@top_srcdir@/tests/_libtap/tap/libtap.sh"
TMPDIR=$(test_tmpdir)
LOG="$TMPDIR/log"
......