1 # Copyright (c) 2013 Holger Weiss <holger@weiss.in-berlin.de>
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.
28 # Enable colored test output.
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 Create the input file, unless $1 equals the literal string "input".
53 AT_CAPTURE_FILE([input])
54 m4_if([$1], [input], [], [AT_DATA([input], [m4_n([$1])])])
56 dnl Optionally create configuration files.
58 [AT_CAPTURE_FILE([client.cfg])
59 AT_DATA([client.cfg], [m4_n([$6])])])
61 [AT_CAPTURE_FILE([server.cfg])
62 AT_DATA([server.cfg], [m4_n([$7])])])
64 dnl We append a newline to STDOUT/STDERR, unless a literal was specified.
65 m4_set_add_all([nsca_at_literals], [ignore], [ignore-nolog], [stdout],
66 [stderr], [stdout-nolog], [stderr-nolog], [expout], [experr])
69 AT_CHECK([nsca_cmd_line], [$8],
70 [m4_set_contains([nsca_at_literals], [$2], [$2], [m4_n([$2])])],
71 [m4_set_contains([nsca_at_literals], [$3], [$3], [m4_n([$3])])])
74 dnl vim:set joinspaces textwidth=80 filetype=m4: