From: Sebastian Harl Date: Mon, 28 Apr 2014 05:57:46 +0000 (+0200) Subject: t/integration: Added simple framework for integration tests. X-Git-Tag: sysdb-0.1.0~71 X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=commitdiff_plain;h=bb40de500bfe57d044ed45ed66e5d5c38f0818ba t/integration: Added simple framework for integration tests. Added a test using very simple configuration snippets. --- diff --git a/.gitignore b/.gitignore index 7ebb01e..b9cfd1d 100644 --- a/.gitignore +++ b/.gitignore @@ -48,7 +48,9 @@ src/sysdbd *.o sysdb.h -# unit testing output +# integration/unit testing output +t/integration/*.sh.log +t/integration/*.sh.trs t/unit/libsysdb_test t/unit/libsysdb_net_test t/unit/*.log diff --git a/t/Makefile.am b/t/Makefile.am index 4764a6e..504e88c 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -5,8 +5,15 @@ AM_CFLAGS = @STRICT_CFLAGS@ @COVERAGE_CFLAGS@ AM_LDFLAGS = @COVERAGE_LDFLAGS@ AM_CPPFLAGS = -I$(top_srcdir)/src/include -TESTS = unit/libsysdb_test unit/libsysdb_net_test -check_PROGRAMS = unit/libsysdb_test unit/libsysdb_net_test +TESTS = +check_PROGRAMS = + +# +# unit tests +# + +TESTS += unit/libsysdb_test unit/libsysdb_net_test +check_PROGRAMS += unit/libsysdb_test unit/libsysdb_net_test unit_libsysdb_test_SOURCES = \ unit/libsysdb_test.c unit/libsysdb_test.h \ @@ -35,5 +42,11 @@ endif unit_libsysdb_net_test_CFLAGS = $(AM_CFLAGS) @CHECK_CFLAGS@ -I$(top_srcdir)/t/unit unit_libsysdb_net_test_LDADD = $(top_builddir)/src/libsysdb.la @CHECK_LIBS@ +# +# integration tests +# + +TESTS += integration/simple_config.sh + test: check diff --git a/t/integration/simple_config.sh b/t/integration/simple_config.sh new file mode 100755 index 0000000..3484351 --- /dev/null +++ b/t/integration/simple_config.sh @@ -0,0 +1,53 @@ +#! /bin/bash +# +# SysDB -- t/integration/simple_config.sh +# Copyright (C) 2012 Sebastian 'tokkee' Harl +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# +# Integration tests using simple configuration snippets. +# + +set -e + +source "$( dirname "$0" )/test_lib.sh" + +cat < "$TESTDIR/sysdbd.conf" +Listen "invalid://address" +EOF + +if "$TOP_SRCDIR/src/sysdbd" -D -C "$TESTDIR/sysdbd.conf"; then + echo 'SysDBd accepted invalid listen address; expected: failure' >&2 + exit 1 +fi + +cat < "$TESTDIR/sysdbd.conf" +Listen "$SOCKET_FILE" +EOF + +"$TOP_SRCDIR/src/sysdbd" -D -C "$TESTDIR/sysdbd.conf" & +sysdbd_pid=$! + +wait_for_sysdbd +kill $! diff --git a/t/integration/test_lib.sh b/t/integration/test_lib.sh new file mode 100644 index 0000000..85bffb9 --- /dev/null +++ b/t/integration/test_lib.sh @@ -0,0 +1,54 @@ +# +# SysDB -- t/integration/test_lib.sh +# Copyright (C) 2012 Sebastian 'tokkee' Harl +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# +# Shell library of test helpers for integration tests. +# + +TOP_SRCDIR="$( readlink -f "$( dirname "$0" )/../.." )" +TESTDIR="$( mktemp -d )" +trap "rm -rf '$TESTDIR'" EXIT + +mkdir "$TESTDIR/backend" +cp "$TOP_SRCDIR/t/integration/.libs/mock_plugin.so" "$TESTDIR/backend" + +SOCKET_FILE="$TESTDIR/sock" +PLUGIN_DIR="$TESTDIR" + +function wait_for_sysdbd() { + local i + for (( i=0; i<10; i++ )); do + if test -e "$SOCKET_FILE"; then + break + fi + sleep 1 + done + if test $i -eq 10; then + echo 'SysDBd did not start within 10 seconds' >&2 + exit 1 + fi +} +