blob: 7c5ebeb0c5b323857906becd5783954f70fd3c49 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#!/bin/sh
# Copyright (C) 2011-2020 Internet Systems Consortium, Inc. ("ISC")
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# The logger supports the idea of a "console" logger than logs to either stdout
# or stderr. This test checks that both these options work.
# Exit with error if commands exit with non-zero and if undefined variables are
# used.
set -eu
# Include common test library.
# shellcheck disable=SC1091
# SC1091: Not following: ... was not specified as input (see shellcheck -x).
. "@abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh"
tempfile="@abs_builddir@/console_test_tempfile_$$"
# Look at tempfile and check that the count equals the expected count
passfail() {
count=$(wc -l $tempfile | awk '{print $1}')
if [ "${count}" -eq "${1}" ]; then
test_finish 0
else
test_finish 1
fi
}
test_start 'console-output.stdout'
rm -f $tempfile
./logger_example -c stdout -s error 1> $tempfile 2> /dev/null
passfail 4
test_start 'console-output.stdout-not-stderr'
rm -f $tempfile
./logger_example -c stdout -s error 1> /dev/null 2> $tempfile
passfail 0
test_start 'console-output.stderr'
rm -f $tempfile
./logger_example -c stderr -s error 1> /dev/null 2> $tempfile
passfail 4
test_start 'console-output.stderr-not-stdout'
rm -f $tempfile
./logger_example -c stderr -s error 1> $tempfile 2> /dev/null
passfail 0
# Tidy up
rm -f $tempfile
|