tests: add basic tests

The tests can be ran using 'make check'.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2012-11-29 19:58:38 +00:00
parent 6684772550
commit 71bcee14e9
17 changed files with 134 additions and 1 deletions

View file

@ -4,4 +4,4 @@ AUTOMAKE_OPTIONS = gnu
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = m4/gnulib-cache.m4
SUBDIRS = lib src man contrib
SUBDIRS = lib src man tests contrib

View file

@ -127,6 +127,7 @@ AC_CONFIG_FILES([
src/Makefile
man/Makefile
man/dhcpd-pools.1
tests/Makefile
contrib/Makefile
])

3
tests/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
/Makefile
/Makefile.in
/outputs

16
tests/Makefile.am Normal file
View file

@ -0,0 +1,16 @@
EXTRA_DIST = \
bootp \
confs \
expected \
leading0 \
leases \
simple \
test.sh
TESTS = simple bootp leading0
check_SCRIPTS = test.sh
check-local: $(SHELL) $(top_srcdir)/tests/test.sh
clean-local:
rm -rf $(top_builddir)/tests/outputs

1
tests/bootp Symbolic link
View file

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

5
tests/confs/bootp Normal file
View file

@ -0,0 +1,5 @@
subnet 10.0.0.0 netmask 255.255.255.0 {
pool {
range dynamic-bootp 10.0.0.1 10.0.0.10;
}
}

5
tests/confs/leading0 Normal file
View file

@ -0,0 +1,5 @@
subnet 10.0.0.0 netmask 255.255.255.0 {
pool {
range dynamic-bootp 10.0.0.001 10.0.0.010;
}
}

5
tests/confs/simple Normal file
View file

@ -0,0 +1,5 @@
subnet 10.0.0.0 netmask 255.255.255.0 {
pool {
range 10.0.0.1 10.0.0.10;
}
}

10
tests/expected/bootp 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 10 100.000 0 10 100.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 10 100.000 0 10 100.000

10
tests/expected/leading0 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.8 8 8 100.000 0 8 100.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 8 8 100.000 0 8 100.000

10
tests/expected/simple 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 10 100.000 0 10 100.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 10 100.000 0 10 100.000

1
tests/leading0 Symbolic link
View file

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

1
tests/leases/bootp Symbolic link
View file

@ -0,0 +1 @@
simple

1
tests/leases/leading0 Symbolic link
View file

@ -0,0 +1 @@
simple

48
tests/leases/simple Normal file
View file

@ -0,0 +1,48 @@
lease 10.0.0.0 {
binding state active;
hardware ethernet 00:00:00:00:00:00;
}
lease 10.0.0.1 {
binding state active;
hardware ethernet 00:00:00:00:00:01;
}
lease 10.0.0.2 {
binding state active;
hardware ethernet 00:00:00:00:00:02;
}
lease 10.0.0.3 {
binding state active;
hardware ethernet 00:00:00:00:00:03;
}
lease 10.0.0.4 {
binding state active;
hardware ethernet 00:00:00:00:00:04;
}
lease 10.0.0.5 {
binding state active;
hardware ethernet 00:00:00:00:00:05;
}
lease 10.0.0.6 {
binding state active;
hardware ethernet 00:00:00:00:00:06;
}
lease 10.0.0.7 {
binding state active;
hardware ethernet 00:00:00:00:00:07;
}
lease 10.0.0.8 {
binding state active;
hardware ethernet 00:00:00:00:00:08;
}
lease 10.0.0.9 {
binding state active;
hardware ethernet 00:00:00:00:00:09;
}
lease 10.0.0.10 {
binding state active;
hardware ethernet 00:00:00:00:00:10;
}
lease 10.0.0.11 {
binding state active;
hardware ethernet 00:00:00:00:00:11;
}

1
tests/simple Symbolic link
View file

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

15
tests/test.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/sh
#
# Minimal regression test suite.
TEST_TOPDIR=$(cd $(dirname $0) && pwd)
IAM=$(basename $0)
DHCPD_POOLS=$(readlink -f $TEST_TOPDIR/../src/dhcpd-pools)
if [ ! -d outputs ]; then
mkdir outputs
fi
$DHCPD_POOLS -c confs/$IAM -l leases/$IAM -o outputs/$IAM
diff -q expected/$IAM outputs/$IAM >/dev/null
exit $?