From 71bcee14e9db16b8fe805c53612285bcae6e1102 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Thu, 29 Nov 2012 19:58:38 +0000 Subject: [PATCH] tests: add basic tests The tests can be ran using 'make check'. Signed-off-by: Sami Kerola --- Makefile.am | 2 +- configure.ac | 1 + tests/.gitignore | 3 +++ tests/Makefile.am | 16 ++++++++++++++ tests/bootp | 1 + tests/confs/bootp | 5 +++++ tests/confs/leading0 | 5 +++++ tests/confs/simple | 5 +++++ tests/expected/bootp | 10 +++++++++ tests/expected/leading0 | 10 +++++++++ tests/expected/simple | 10 +++++++++ tests/leading0 | 1 + tests/leases/bootp | 1 + tests/leases/leading0 | 1 + tests/leases/simple | 48 +++++++++++++++++++++++++++++++++++++++++ tests/simple | 1 + tests/test.sh | 15 +++++++++++++ 17 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 tests/.gitignore create mode 100644 tests/Makefile.am create mode 120000 tests/bootp create mode 100644 tests/confs/bootp create mode 100644 tests/confs/leading0 create mode 100644 tests/confs/simple create mode 100644 tests/expected/bootp create mode 100644 tests/expected/leading0 create mode 100644 tests/expected/simple create mode 120000 tests/leading0 create mode 120000 tests/leases/bootp create mode 120000 tests/leases/leading0 create mode 100644 tests/leases/simple create mode 120000 tests/simple create mode 100755 tests/test.sh diff --git a/Makefile.am b/Makefile.am index 22158cb..9618448 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index 269889c..e75498e 100644 --- a/configure.ac +++ b/configure.ac @@ -127,6 +127,7 @@ AC_CONFIG_FILES([ src/Makefile man/Makefile man/dhcpd-pools.1 + tests/Makefile contrib/Makefile ]) diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..c831351 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,3 @@ +/Makefile +/Makefile.in +/outputs diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..d51cec1 --- /dev/null +++ b/tests/Makefile.am @@ -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 diff --git a/tests/bootp b/tests/bootp new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/tests/bootp @@ -0,0 +1 @@ +test.sh \ No newline at end of file diff --git a/tests/confs/bootp b/tests/confs/bootp new file mode 100644 index 0000000..7e4564e --- /dev/null +++ b/tests/confs/bootp @@ -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; + } +} diff --git a/tests/confs/leading0 b/tests/confs/leading0 new file mode 100644 index 0000000..6d4deb8 --- /dev/null +++ b/tests/confs/leading0 @@ -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; + } +} diff --git a/tests/confs/simple b/tests/confs/simple new file mode 100644 index 0000000..56881c6 --- /dev/null +++ b/tests/confs/simple @@ -0,0 +1,5 @@ +subnet 10.0.0.0 netmask 255.255.255.0 { + pool { + range 10.0.0.1 10.0.0.10; + } +} diff --git a/tests/expected/bootp b/tests/expected/bootp new file mode 100644 index 0000000..da14b05 --- /dev/null +++ b/tests/expected/bootp @@ -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 diff --git a/tests/expected/leading0 b/tests/expected/leading0 new file mode 100644 index 0000000..46da8bf --- /dev/null +++ b/tests/expected/leading0 @@ -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 diff --git a/tests/expected/simple b/tests/expected/simple new file mode 100644 index 0000000..da14b05 --- /dev/null +++ b/tests/expected/simple @@ -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 diff --git a/tests/leading0 b/tests/leading0 new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/tests/leading0 @@ -0,0 +1 @@ +test.sh \ No newline at end of file diff --git a/tests/leases/bootp b/tests/leases/bootp new file mode 120000 index 0000000..8fd3246 --- /dev/null +++ b/tests/leases/bootp @@ -0,0 +1 @@ +simple \ No newline at end of file diff --git a/tests/leases/leading0 b/tests/leases/leading0 new file mode 120000 index 0000000..8fd3246 --- /dev/null +++ b/tests/leases/leading0 @@ -0,0 +1 @@ +simple \ No newline at end of file diff --git a/tests/leases/simple b/tests/leases/simple new file mode 100644 index 0000000..9454b83 --- /dev/null +++ b/tests/leases/simple @@ -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; +} diff --git a/tests/simple b/tests/simple new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/tests/simple @@ -0,0 +1 @@ +test.sh \ No newline at end of file diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 0000000..f1f1587 --- /dev/null +++ b/tests/test.sh @@ -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 $?