Use ".cfg" as the configuration file extension
[nsca-ng.git] / tests / local.at
blobdb7600c20ef262cd7c906f1541c6f4d8da482060
1 # Copyright (c) 2013 Holger Weiss <holger@weiss.in-berlin.de>
2 # All rights reserved.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
7 # 1. Redistributions of source code must retain the above copyright notice, this
8 #    list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright notice,
11 #    this list of conditions and the following disclaimer in the documentation
12 #    and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 # DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 # Initialize Autotest.
26 AT_INIT
28 # Enable colored test output.
29 AT_COLOR_TESTS
31 # Log the `--version' of our programs.
32 AT_TESTED([test_nsca])
34 # NSCA_CHECK([INPUT], [STDOUT], [STDERR], [CLIENT-FLAGS], [SERVER-FLAGS],
35 #            [CLIENT-CONF], [SERVER-CONF], [STATUS = 0], [COMMANDS = 1])
36 # -----------------------------------------------------------------------
37 # Transmit the given INPUT to the nsca-ng(8) server using send_nsca(8).  If the
38 # INPUT consists of multiple monitoring commands, the number of COMMANDS must be
39 # specified.  The data written to the FIFO by the server is then checked against
40 # STDOUT, send_nsca(8)'s standard error output is checked against STDERR, and
41 # the exit status is checked against STATUS.  Non-default CLIENT-CONF and/or
42 # SERVER-CONF contents may be specified.  See also the AT_CHECK documentation.
43 m4_define([NSCA_CHECK],
45   dnl Put together the command line.
46   m4_define([nsca_cmd_line], [<input])
47   m4_ifval([$4], [m4_append([nsca_cmd_line], [NSCA_CLIENT_FLAGS="$4"], [ ])])
48   m4_ifval([$5], [m4_append([nsca_cmd_line], [NSCA_SERVER_FLAGS="$5"], [ ])])
49   m4_append([nsca_cmd_line], [test_nsca], [ ])
50   m4_ifval([$9], [m4_append([nsca_cmd_line], [-l $9], [ ])])
52   dnl Optionally prepare the input file.
53   m4_ifval([$1],
54     [AT_CAPTURE_FILE([input])
55      AT_DATA([input], [m4_n([$1])])])
57   dnl Optionally create configuration files.
58   m4_ifval([$6],
59     [AT_CAPTURE_FILE([client.cfg])
60      AT_DATA([client.cfg], [m4_n([$6])])])
61   m4_ifval([$7],
62     [AT_CAPTURE_FILE([server.cfg])
63      AT_DATA([server.cfg], [m4_n([$7])])])
65   dnl We append a newline to STDOUT/STDERR, unless a literal was specified.
66   m4_set_add_all([nsca_at_literals], [ignore], [ignore-nolog], [stdout],
67     [stderr], [stdout-nolog], [stderr-nolog], [expout], [experr])
69   dnl Run the check.
70   AT_CHECK([nsca_cmd_line], [$8],
71     [m4_set_contains([nsca_at_literals], [$2], [$2], [m4_n([$2])])],
72     [m4_set_contains([nsca_at_literals], [$3], [$3], [m4_n([$3])])])
75 dnl vim:set joinspaces textwidth=80 filetype=m4: