1 #! /bin/bash
2 #
3 # SysDB -- t/integration/simple_config.sh
4 # Copyright (C) 2012 Sebastian 'tokkee' Harl <sh@tokkee.org>
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
20 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #
29 # Integration tests using simple configuration snippets.
30 #
32 set -ex
34 source "$( dirname "$0" )/test_lib.sh"
36 # Very basics ;-)
37 run_sysdb -V
38 run_sysdb -h
40 run_sysdbd -V
41 run_sysdbd -h
43 # Simple invalid configuration examples.
44 cat <<EOF > "$SYSDBD_CONF"
45 Invalid "option"
46 EOF
47 if run_sysdbd_foreground -D -C "$SYSDBD_CONF"; then
48 echo 'SysDBd accepted invalid option; expected: failure' >&2
49 exit 1
50 fi
52 cat <<EOF > "$SYSDBD_CONF"
53 Listen "invalid://address"
54 EOF
55 if run_sysdbd_foreground -D -C "$SYSDBD_CONF"; then
56 echo 'SysDBd accepted invalid listen address; expected: failure' >&2
57 exit 1
58 fi
60 cat <<EOF > "$SYSDBD_CONF"
61 Interval "foo"
62 EOF
63 if run_sysdbd_foreground -D -C "$SYSDBD_CONF"; then
64 echo 'SysDBd accepted invalid interval; expected: failure' >&2
65 exit 1
66 fi
68 cat <<EOF > "$SYSDBD_CONF"
69 Interval -3.0
70 EOF
71 if run_sysdbd_foreground -D -C "$SYSDBD_CONF"; then
72 echo 'SysDBd accepted invalid interval; expected: failure' >&2
73 exit 1
74 fi
76 # Simple configuration examples.
77 cat <<EOF > "$SYSDBD_CONF"
78 Listen "$SOCKET_FILE"
79 EOF
81 run_sysdbd -D -C "$SYSDBD_CONF"
82 wait_for_sysdbd
84 # reconfigure
85 SOCKET_FILE="$SOCKET_FILE-2"
86 cat <<EOF > "$SYSDBD_CONF"
87 Listen "${SOCKET_FILE}"
88 EOF
89 kill -HUP $SYSDBD_PID
90 wait_for_sysdbd
92 stop_sysdbd