Browse Source

[3599] Unit tests framework added.

Tomek Mrugalski 10 years ago
parent
commit
20c1bcf04e

+ 8 - 0
configure.ac

@@ -1393,6 +1393,14 @@ AC_CONFIG_FILES([compatcheck/Makefile
                  src/bin/perfdhcp/Makefile
                  src/bin/perfdhcp/tests/Makefile
                  src/bin/perfdhcp/tests/testdata/Makefile
+                 src/bin/admin/Makefile
+                 src/bin/admin/kea-admin
+                 src/bin/admin/scripts/Makefile
+                 src/bin/admin/tests/Makefile
+                 src/bin/admin/tests/memfile_tests.sh
+                 src/bin/admin/tests/mysql_tests.sh
+                 src/bin/admin/scripts/mysql/Makefile
+                 src/bin/admin/scripts/pgsql/Makefile
                  src/hooks/Makefile
                  src/hooks/dhcp/Makefile
                  src/hooks/dhcp/user_chk/Makefile

+ 1 - 1
src/bin/Makefile.am

@@ -1,5 +1,5 @@
 # The following build order must be maintained.
-SUBDIRS = dhcp4 dhcp6 d2 perfdhcp
+SUBDIRS = dhcp4 dhcp6 d2 perfdhcp admin
 
 if CONFIG_BACKEND_JSON
 SUBDIRS += keactrl

+ 21 - 0
src/bin/admin/Makefile.am

@@ -0,0 +1,21 @@
+SUBDIRS = . scripts tests
+
+# Install kea-admin in sbin.
+sbin_SCRIPTS  = kea-admin
+
+man_MANS = kea-admin.8
+DISTCLEANFILES = $(man_MANS)
+EXTRA_DIST = $(man_MANS) admin-utils.sh
+
+if GENERATE_DOCS
+
+kea-admin.8: kea-admin.xml
+	@XSLTPROC@ --novalid --xinclude --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $(builddir)/kea-admin.xml
+
+else
+
+$(man_MANS):
+	@echo Man generation disabled.  Creating dummy $@.  Configure with --enable-generate-docs to enable it.
+	@echo Man generation disabled.  Remove this file, configure with --enable-generate-docs, and rebuild Kea > $@
+
+endif

+ 1 - 0
src/bin/admin/kea-admin.in

@@ -22,6 +22,7 @@
 
 
 # Get the location of the kea-admin scripts
+prefix=@prefix@
 SCRIPTS_DIR_DEFAULT=@datarootdir@/@PACKAGE@/scripts
 scripts_dir=${SCRIPTS_DIR_DEFAULT}
 

+ 1 - 0
src/bin/admin/scripts/Makefile.am

@@ -0,0 +1 @@
+SUBDIRS = mysql pgsql

+ 6 - 0
src/bin/admin/scripts/mysql/Makefile.am

@@ -0,0 +1,6 @@
+SUBDIRS = .
+
+EXTRA_DIST = dhcpdb_create.mysql upgrade_1.0_to_2.0.sh
+
+dist_pkgdata_DATA = $(EXTRA_DIR)
+

+ 5 - 0
src/bin/admin/scripts/pgsql/Makefile.am

@@ -0,0 +1,5 @@
+SUBDIRS = .
+
+EXTRA_DIST = dhcpdb_create.pgsql
+
+dist_pkgdata_DATA = $(EXTRA_DIR)

+ 46 - 0
src/bin/admin/tests/memfile_tests.sh.in

@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+# Include common test library.
+. @abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh
+
+memfile_init_test() {
+    test_start "memfile.init"
+    
+    # @todo: Implement this (ticket #3601)
+
+    test_finish 0
+}
+
+memfile_version_test() {
+    test_start "memfile.version"
+    
+    # @todo: Implement this (ticket #3601)
+
+    test_finish 0
+}
+
+memfile_upgrade_test() {
+    test_start "memfile.upgrade"
+    
+    # @todo: Implement this (ticket #3601)
+
+    test_finish 0
+}
+
+memfile_init_test
+memfile_version_test
+memfile_upgrade_test

+ 58 - 0
src/bin/admin/tests/mysql_tests.sh.in

@@ -0,0 +1,58 @@
+#!/bin/sh
+
+# Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+# Include common test library.
+. @abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh
+
+# If the code is installed, include admin-utils.sh from the destination
+# directory. If not, include it from the sources.
+prefix=@prefix@
+
+if [ -e @datarootdir@/admin-utils.sh ]; then
+    echo "INCLUDING FROM DESTDIR"
+    . @datarootdir@/admin-utils.sh
+else
+    echo "INCLUDING FROM BUILDDIR"
+    . @abs_top_builddir@/src/bin/admin/admin-utils.sh
+fi
+
+mysql_init_test() {
+    test_start "mysql.init"
+    
+    # @todo: Implement this
+
+    test_finish 0
+}
+
+mysql_version_test() {
+    test_start "mysql.version"
+    
+    # @todo: Implement this
+
+    test_finish 0
+}
+
+mysql_upgrade_test() {
+    test_start "mysql.upgrade"
+    
+    # @todo: Implement this
+
+    test_finish 0
+}
+
+mysql_init_test
+mysql_version_test
+mysql_upgrade_test

+ 3 - 3
src/lib/dhcpsrv/Makefile.am

@@ -113,9 +113,9 @@ endif
 # The message file should be in the distribution
 EXTRA_DIST = dhcpsrv_messages.mes
 
-# Distribute MySQL schema creation script and backend documentation
-EXTRA_DIST += dhcpdb_create.mysql dhcpdb_create.pgsql database_backends.dox libdhcpsrv.dox
-dist_pkgdata_DATA = dhcpdb_create.mysql dhcpdb_create.pgsql
+# Distribute backend documentation
+# Database schema creation script moved to src/bin/admin
+EXTRA_DIST += database_backends.dox libdhcpsrv.dox
 
 install-data-local:
 	$(mkinstalldirs) $(DESTDIR)$(dhcp_data_dir)