Commit cabc3143 authored by Jan Včelák's avatar Jan Včelák 🚀

build: separate libtap, separate tests

parent 86036086
......@@ -15,8 +15,6 @@
/Makefile.in
/src/Makefile
/src/Makefile.in
/src/tests/Makefile
/src/tests/Makefile.in
/src/zscanner/Makefile
/src/zscanner/Makefile.in
/patches/Makefile
......@@ -57,12 +55,12 @@
/src/knot/conf/libknotd_la-cf-lex.c
/src/knot/conf/libknotd_la-cf-parse.c
/src/knot/conf/libknotd_la-cf-parse.h
/tests/sample_conf.c
/src/zscanner/scanner.c
/src/zscanner/tests/tap/libtap.a
/tests/tap/libtap.a
/tests/tmp/
# zscanner
/src/zscanner/tests/tmp/
/src/zscanner/tests/runtests
/src/zscanner/tests/zscanner-tool
# Binaries
/src/knotc
......@@ -71,31 +69,3 @@
/src/khost
/src/knsupdate
/src/knsec3hash
/src/zscanner/tests/runtests
/src/zscanner/tests/zscanner-tool
/tests/runtests
/tests/acl
/tests/base32hex
/tests/base64
/tests/conf
/tests/descriptor
/tests/dname
/tests/dnssec_keys
/tests/dnssec_nsec3
/tests/dnssec_sign
/tests/dnssec_zone_nsec
/tests/dthreads
/tests/events
/tests/fdset
/tests/hattrie
/tests/hhash
/tests/journal
/tests/pkt
/tests/process_query
/tests/rrl
/tests/rrset
/tests/server
/tests/slab
/tests/wire
/tests/zonedb
/tests/ztree
......@@ -15,6 +15,7 @@ doc/requirements.texi
doc/running.texi
doc/security.texi
doc/troubleshooting.texi
libtap/Makefile.am
man/Makefile.am
patches/Makefile.am
samples/Makefile.am
......@@ -249,15 +250,11 @@ src/zscanner/scanner_functions.h
src/zscanner/tests/processing.c
src/zscanner/tests/processing.h
src/zscanner/tests/runtests.c
src/zscanner/tests/tap/basic.c
src/zscanner/tests/tap/basic.h
src/zscanner/tests/tap/float.c
src/zscanner/tests/tap/float.h
src/zscanner/tests/tap/macros.h
src/zscanner/tests/tests.c
src/zscanner/tests/tests.h
src/zscanner/tests/zscanner-tool.c
src/zscanner/zscanner.h
tests/Makefile.am
tests/acl.c
tests/base32hex.c
tests/base64.c
......@@ -277,15 +274,9 @@ tests/pkt.c
tests/process_query.c
tests/rrl.c
tests/rrset.c
tests/runtests.c
tests/sample_conf.h
tests/server.c
tests/slab.c
tests/tap/basic.c
tests/tap/basic.h
tests/tap/float.c
tests/tap/float.h
tests/tap/macros.h
tests/wire.c
tests/zonedb.c
tests/ztree.c
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src samples doc man patches
include $(srcdir)/tests/Makefile.inc
SUBDIRS = libtap src tests samples doc man patches
......@@ -324,7 +324,7 @@ AC_CHECK_FUNCS([clock_gettime gettimeofday fgetln getline madvise malloc_trim po
# Check for be64toh function
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <endian.h>]], [[return be64toh(0);]])],
[AC_DEFINE(HAVE_BE64TOH, 1, [Define to 1 if you have the `be64toh' function.])])
[AC_DEFINE(HAVE_BE64TOH, 1, [Define to 1 if you have the 'be64toh' function.])])
# Check for cpu_set_t/cpuset_t compatibility
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[cpu_set_t set; CPU_ZERO(&set);]])],
......@@ -342,9 +342,11 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sched.h>]], [[cpuset_t* set = cpuset
AC_CONFIG_FILES([Makefile
doc/Makefile
man/Makefile
src/Makefile
samples/Makefile
patches/Makefile
libtap/Makefile
src/Makefile
tests/Makefile
src/zscanner/Makefile
man/khost.1
man/knotc.8
......
Makefile
Makefile.in
runtests
libtap.a
libtap_a_SOURCES = \
tap/basic.c tap/basic.h \
tap/float.c tap/float.h \
tap/macros.h
check_LIBRARIES = libtap.a
check_PROGRAMS = \
runtests
......@@ -48,7 +48,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <tests/tap/basic.h>
#include "basic.h"
/* Windows provides mkdir and rmdir under different names. */
#ifdef _WIN32
......
......@@ -30,7 +30,7 @@
#ifndef TAP_BASIC_H
#define TAP_BASIC_H 1
#include <tests/tap/macros.h>
#include "macros.h"
#include <stdarg.h> /* va_list */
#include <sys/types.h> /* size_t */
......
......@@ -42,8 +42,8 @@
#include <stdarg.h>
#include <stdio.h>
#include <tests/tap/basic.h>
#include <tests/tap/float.h>
#include "basic.h"
#include "float.h"
/*
* Takes an expected double and a seen double and assumes the test passes if
......
......@@ -28,7 +28,7 @@
#ifndef TAP_FLOAT_H
#define TAP_FLOAT_H 1
#include <tests/tap/macros.h>
#include "macros.h"
BEGIN_DECLS
......
journal
slab
hattrie
hhash
dthreads
Makefile
Makefile.in
sample_conf.c
# Test binaries:
acl
fdset
base64
base32hex
descriptor
server
base64
conf
rrl
wire
descriptor
dname
ztree
zonedb
dnssec_keys
dnssec_nsec3
dnssec_sign
dnssec_zone_nsec
rrset
dthreads
events
fdset
hattrie
hhash
journal
pkt
process_query
rrl
rrset
server
slab
wire
zonedb
ztree
AM_CPPFLAGS = \
-I$(top_srcdir)/libtap \
-I$(top_srcdir)/src
LDADD = \
$(top_srcdir)/libtap/libtap.a \
$(top_srcdir)/src/libknotd.la \
$(top_srcdir)/src/libknots.la
check_PROGRAMS = \
journal \
slab \
hattrie \
hhash \
dthreads \
acl \
fdset \
base64 \
base32hex \
descriptor \
server \
conf \
rrl \
wire \
dname \
ztree \
zonedb \
dnssec_keys \
dnssec_nsec3 \
dnssec_sign \
dnssec_zone_nsec \
rrset \
pkt \
process_query
check-compile-only: $(check_PROGRAMS)
check-local: $(check_PROGRAMS)
$(top_srcdir)/libtap/runtests \
-s $(abs_top_srcdir)/tests -b $(abs_top_srcdir)/tests \
$(check_PROGRAMS)
EXTRA_DIST = data
dist_check_SCRIPTS = resource.sh
conf_SOURCES = conf.c sample_conf.h
nodist_conf_SOURCES = sample_conf.c
CLEANFILES = sample_conf.c
sample_conf.c: data/sample_conf
$(abs_srcdir)/resource.sh $(abs_srcdir)/data/sample_conf >$@
# -*- mode: makefile; -*-
check_PROGRAMS = \
tests/runtests \
tests/journal \
tests/slab \
tests/hattrie \
tests/hhash \
tests/dthreads \
tests/acl \
tests/fdset \
tests/base64 \
tests/base32hex \
tests/descriptor \
tests/server \
tests/conf \
tests/rrl \
tests/wire \
tests/dname \
tests/ztree \
tests/zonedb \
tests/dnssec_keys \
tests/dnssec_nsec3 \
tests/dnssec_sign \
tests/dnssec_zone_nsec \
tests/rrset \
tests/pkt \
tests/process_query
check_LIBRARIES = tests/tap/libtap.a
AM_CPPFLAGS = \
-I$(top_srcdir)/src \
-I$(top_srcdir)/tests
tests_runtests_CPPFLAGS = \
-DSOURCE='"$(abs_top_srcdir)/tests"' \
-DBUILD='"$(abs_top_builddir)/tests"'
tests_tap_libtap_a_CPPFLAGS = -I$(abs_top_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-compile-only: $(check_PROGRAMS)
check-local: $(check_PROGRAMS)
cd tests && ./runtests -l $(abs_top_srcdir)/tests/TESTS
LDADD = \
tests/tap/libtap.a \
src/libknotd.la src/libknots.la \
@LIBOBJS@
tests_conf_SOURCES = tests/conf.c tests/sample_conf.h
nodist_tests_conf_SOURCES = tests/sample_conf.c
CLEANFILES = tests/sample_conf.c
EXTRA_DIST = tests/data tests/TESTS
dist_check_SCRIPTS = tests/resource.sh
tests/sample_conf.c: tests/data/sample_conf
$(abs_top_srcdir)/tests/resource.sh $(abs_top_srcdir)/tests/data/sample_conf >$@
The MIT/X11 License
Copyright (c) 2005-2008 Ricardo Signes
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import TAP
import re
builder = TAP.Builder()
def plan(plan, plan_param=None):
builder.set_plan(plan, plan_param)
ok = builder.ok
def diag(comment):
print(("# %s" % re.compile("\n(.)").sub(comment, '\n#\1')))
def eq_ok(have, want, comment):
okness = have == want
ok(okness, comment)
if not okness:
diag("want: %s" % want)
diag("have: %s" % have)
return okness
def is_ok(have, want, comment):
okness = have is want
ok(okness, comment)
if not okness:
diag("want id: %s" % id(want))
diag("have id: %s" % id(have))
return okness
def isa_ok(object, cls, object_name="the object"):
okness = isinstance(object, cls)
ok(okness, object_name + " is a " + repr(cls))
# if not okness:
# diag("want id: %s" % id(want))
# diag("have id: %s" % id(have))
return okness
import sys
import atexit
# todo: make written-to stream passable
class Plan(object):
def __init__(self, plan, param=None):
self.counter = 0
self.expected_tests = None
self.ended = False
if isinstance(plan, int):
self.expected_tests = plan
print(("1..%u" % self.expected_tests))
elif plan == "no_plan" or plan == None: 1
elif plan == "skip_all":
print(("1..0 # skip %s" % param))
raise SystemExit(0) # ??? this is what T::B does, but sucks
else:
raise TestBadPlan(plan)
def increment_counter(self):
self.counter += 1
def __del__(self):
if self.ended: return
self.ended = True
if self.expected_tests is None:
print(("1..%u" % self.counter))
elif self.counter != self.expected_tests:
print(("# Looks like you planned %u tests but ran %u." \
% (self.expected_tests, self.counter)))
class Builder(object):
global_defaults = {
"_plan": None,
"current": 1,
"has_plan": False,
}
global_test_builder = global_defaults.copy()
def __init__(self, plan=None, plan_param=None):
self.__dict__ = self.global_test_builder
if plan: self.set_plan(plan, plan_param)
@classmethod # XXX: why did this fail?
def create(cls, plan=None, plan_param=None):
# self = new.instance(cls) # ? this sucks, too
self = Builder()
self.__dict__ = self.global_defaults.copy()
if plan: self.set_plan(plan, plan_param)
return self
def set_plan(self, plan, plan_param=None):
if self.get_plan(): raise TestPlannedAlready(plan, plan_param)
self._plan = Plan(plan, plan_param)
atexit.register(self._plan.__del__)
def get_plan(self): return self._plan
def ok(self, is_ok, desc=None, skip=None, todo=None):
self.get_plan().increment_counter()
if skip and todo: raise TestBadDirective(self)
if is_ok: report = "ok"
else: report = "not ok"
sys.stdout.write("%s %u" % (report, self.current))
if desc: sys.stdout.write(" - %s" % desc)
if skip: sys.stdout.write(" # SKIP %s" % skip)
if todo: sys.stdout.write(" # TODO %s" % todo)
print("")
self.current += 1
return is_ok
def reset(self):
self.__dict__.clear()
for key in list(self.global_defaults.keys()):
self.__dict__[key] = self.global_defaults[key]
class TestPlannedAlready(Exception):
def __init__(self, plan, param=None):
self.plan = plan
self.param = param
def __str__(self):
return "tried to plan twice; second plan: %s, %s" % self.plan, self.param
class TestWithoutPlan(Exception):
def __str__(self):
return "tried running tests without a plan"
class TestBadPlan(Exception):
def __init__(self, plan):
self.plan = plan
def __str__(self):
return "didn't understand plan '%s'" % self.plan
class TestBadDirective(Exception):
def __str__(self):
return "tried running a test with more than one directive"
......@@ -21,7 +21,7 @@
#include "knot/conf/conf.h"
/* Resources. */
#include "tests/sample_conf.h"
#include "sample_conf.h"
/*! Run all scheduled tests for given parameters.
*/
......
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