tests: add json tests, and make fail output loud

Gilles reported the full-json is currently broken, which the new check
demonstrates.  Luckily the issue occurs only when active leases details
are being queried, leaving the count to be correct.  That said bug is a
bug, and that should be corrected.

Reported-by: Gilles Bouthenot <gilles.bouthenot@univ-fcomte.fr>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2012-12-07 20:25:21 +00:00
parent a768049f3e
commit d8aae53968
8 changed files with 63 additions and 5 deletions

View file

@ -1,14 +1,20 @@
EXTRA_DIST = \ EXTRA_DIST = \
bootp \ bootp \
full-json \
confs \ confs \
expected \ expected \
leading0 \ leading0 \
leases \ leases \
simple \ same-twice \
test.sh simple
TESTS = simple bootp leading0 v6 TESTS = \
check_SCRIPTS = test.sh bootp \
full-json \
leading0 \
same-twice \
simple \
v6
check-local: $(SHELL) $(top_srcdir)/tests/test.sh check-local: $(SHELL) $(top_srcdir)/tests/test.sh

1
tests/confs/same-twice Symbolic link
View file

@ -0,0 +1 @@
simple

10
tests/expected/same-twice Normal file
View file

@ -0,0 +1,10 @@
Ranges:
shared net name first ip last ip max cur percent touch t+c t+c perc
All networks 10.0.0.1 - 10.0.0.10 10 1 10.000 0 1 10.000
Shared networks:
name max cur percent touch t+c t+c perc
Sum of all ranges:
name max cur percent touch t+c t+c perc
All networks 10 1 10.000 0 1 10.000

View file

@ -0,0 +1,16 @@
{
"active_leases": [
{ "ip":"10.0.0.5", "macaddress":"00:00:00:00:00:00" }
],
"subnets": [
{ "location":"All networks", "range":"10.0.0.1 - 10.0.0.10", "defined":10, "used":1, "free":9 }
],
"shared-networks": [
],
"summary": {
"location":"All networks",
"defined":10,
"used":1,
"free":9
}
}

14
tests/full-json Executable file
View file

@ -0,0 +1,14 @@
#!/bin/sh
#
# Minimal regression test suite.
TEST_TOPDIR=$(cd $(dirname $0) && pwd)
DHCPD_POOLS=$(readlink -f $TEST_TOPDIR/../src/dhcpd-pools)
if [ ! -d outputs ]; then
mkdir outputs
fi
$DHCPD_POOLS -f J -c confs/same-twice -l leases/same-twice -o outputs/same-twice-json
diff -u expected/same-twice-json outputs/same-twice-json
exit $?

10
tests/leases/same-twice Normal file
View file

@ -0,0 +1,10 @@
lease 10.0.0.5 {
binding state active;
next binding state free;
hardware ethernet be:ef:00:00:co:de;
}
lease 10.0.0.5 {
binding state active;
next binding state free;
hardware ethernet 00:00:00:00:00:00;
}

1
tests/same-twice Symbolic link
View file

@ -0,0 +1 @@
test.sh

View file

@ -11,5 +11,5 @@ if [ ! -d outputs ]; then
fi fi
$DHCPD_POOLS -c confs/$IAM -l leases/$IAM -o outputs/$IAM $DHCPD_POOLS -c confs/$IAM -l leases/$IAM -o outputs/$IAM
diff -q expected/$IAM outputs/$IAM >/dev/null diff -u expected/$IAM outputs/$IAM
exit $? exit $?