mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-16 15:57:00 +00:00
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:
parent
a768049f3e
commit
d8aae53968
8 changed files with 63 additions and 5 deletions
|
|
@ -1,14 +1,20 @@
|
|||
EXTRA_DIST = \
|
||||
bootp \
|
||||
full-json \
|
||||
confs \
|
||||
expected \
|
||||
leading0 \
|
||||
leases \
|
||||
simple \
|
||||
test.sh
|
||||
same-twice \
|
||||
simple
|
||||
|
||||
TESTS = simple bootp leading0 v6
|
||||
check_SCRIPTS = test.sh
|
||||
TESTS = \
|
||||
bootp \
|
||||
full-json \
|
||||
leading0 \
|
||||
same-twice \
|
||||
simple \
|
||||
v6
|
||||
|
||||
check-local: $(SHELL) $(top_srcdir)/tests/test.sh
|
||||
|
||||
|
|
|
|||
1
tests/confs/same-twice
Symbolic link
1
tests/confs/same-twice
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
simple
|
||||
10
tests/expected/same-twice
Normal file
10
tests/expected/same-twice
Normal 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
|
||||
16
tests/expected/same-twice-json
Normal file
16
tests/expected/same-twice-json
Normal 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
14
tests/full-json
Executable 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
10
tests/leases/same-twice
Normal 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
1
tests/same-twice
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
test.sh
|
||||
|
|
@ -11,5 +11,5 @@ if [ ! -d outputs ]; then
|
|||
fi
|
||||
|
||||
$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 $?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue