BIND 10 trac555, updated. 475624c79f83adc6befd4d631eeaf83d83fe89f9 [trac555] Added shell-based unit test for console appender
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu May 26 16:45:56 UTC 2011
The branch, trac555 has been updated
via 475624c79f83adc6befd4d631eeaf83d83fe89f9 (commit)
from 3d05a83e9466e6075dec6e4b7a1502989d9205e9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 475624c79f83adc6befd4d631eeaf83d83fe89f9
Author: Stephen Morris <stephen at isc.org>
Date: Thu May 26 17:45:17 2011 +0100
[trac555] Added shell-based unit test for console appender
-----------------------------------------------------------------------
Summary of changes:
configure.ac | 2 +
src/lib/log/tests/Makefile.am | 3 +-
src/lib/log/tests/console_test.sh.in | 63 ++++++++++++++++++++++++++++
src/lib/log/tests/run_time_init_test.sh.in | 23 ++++++----
4 files changed, 80 insertions(+), 11 deletions(-)
create mode 100755 src/lib/log/tests/console_test.sh.in
-----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 6363b43..f6908a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -891,6 +891,7 @@ AC_OUTPUT([doc/version.ent
src/lib/dns/tests/testdata/gen-wiredata.py
src/lib/cc/session_config.h.pre
src/lib/cc/tests/session_unittests_config.h
+ src/lib/log/tests/console_test.sh
src/lib/log/tests/run_time_init_test.sh
src/lib/util/python/mkpywrapper.py
src/lib/server_common/tests/data_path.h
@@ -919,6 +920,7 @@ AC_OUTPUT([doc/version.ent
chmod +x src/lib/dns/gen-rdatacode.py
chmod +x src/lib/dns/tests/testdata/gen-wiredata.py
chmod +x src/lib/log/tests/run_time_init_test.sh
+ chmod +x src/lib/log/tests/console_test.sh
chmod +x src/lib/util/python/mkpywrapper.py
chmod +x tests/system/conf.sh
])
diff --git a/src/lib/log/tests/Makefile.am b/src/lib/log/tests/Makefile.am
index 6c37f06..a66dc83 100644
--- a/src/lib/log/tests/Makefile.am
+++ b/src/lib/log/tests/Makefile.am
@@ -46,6 +46,7 @@ logger_support_test_LDADD += $(top_builddir)/src/lib/util/libutil.la
noinst_PROGRAMS = $(TESTS)
# Additional test using the shell
-PYTESTS = run_time_init_test.sh
+PYTESTS = run_time_init_test.sh console_test.sh
check-local:
$(SHELL) $(abs_builddir)/run_time_init_test.sh
+ $(SHELL) $(abs_builddir)/console_test.sh
diff --git a/src/lib/log/tests/console_test.sh.in b/src/lib/log/tests/console_test.sh.in
new file mode 100755
index 0000000..ea2e459
--- /dev/null
+++ b/src/lib/log/tests/console_test.sh.in
@@ -0,0 +1,63 @@
+#!/bin/sh
+# Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+testname="Console output test"
+echo $testname
+
+failcount=0
+tempfile=@abs_builddir@/console_test_tempfile_$$
+
+# Look at tempfile and check that the count equals the expected count
+passfail() {
+ count=`wc -l $tempfile | cut -f1 -d' '`
+ if [ $count -eq $1 ]; then
+ echo " -- pass"
+ else
+ echo " ** FAIL"
+ failcount=`expr $failcount + $1`
+ fi
+}
+
+echo "1. Checking that console output to stdout goes to stdout:"
+rm -f $tempfile
+./logger_support_test -s error -c stdout 1> $tempfile
+passfail 2
+
+echo "2. Checking that console output to stdout does not go to stderr:"
+rm -f $tempfile
+./logger_support_test -s error -c stdout 2> $tempfile
+passfail 0
+
+echo "3. Checking that console output to stderr goes to stderr:"
+rm -f $tempfile
+./logger_support_test -s error -c stderr 2> $tempfile
+passfail 2
+
+echo "4. Checking that console output to stderr does not go to stdout:"
+rm -f $tempfile
+./logger_support_test -s error -c stderr 1> $tempfile
+passfail 0
+
+rm -f $tempfile
+
+if [ $failcount -eq 0 ]; then
+ echo "PASS: $testname"
+elif [ $failcount -eq 1 ]; then
+ echo "FAIL: $testname - 1 test failed"
+else
+ echo "FAIL: $testname - $failcount tests failed"
+fi
+
+exit $failcount
diff --git a/src/lib/log/tests/run_time_init_test.sh.in b/src/lib/log/tests/run_time_init_test.sh.in
index e48a781..45c3774 100755
--- a/src/lib/log/tests/run_time_init_test.sh.in
+++ b/src/lib/log/tests/run_time_init_test.sh.in
@@ -13,17 +13,20 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
+testname="Run-time initialization test"
+echo $testname
+
failcount=0
localmes=@abs_builddir@/localdef_mes_$$
tempfile=@abs_builddir@/run_time_init_test_tempfile_$$
passfail() {
if [ $1 -eq 0 ]; then
- echo "pass"
+ echo " -- pass"
else
- echo "FAIL"
+ echo " ** FAIL"
+ failcount=`expr $failcount + $1`
fi
- failcount=`expr $failcount + $1`
}
# Create the local message file for testing
@@ -35,7 +38,7 @@ cat > $localmes << .
% RDLOCMES replacement read local message file, parameter is '%1'
.
-echo -n "1. runInitTest default parameters: "
+echo "1. runInitTest default parameters: "
cat > $tempfile << .
FATAL [alpha.example] MSG_WRITERR, error writing to test1: 42
ERROR [alpha.example] MSG_RDLOCMES, reading local message file dummy/file
@@ -45,7 +48,7 @@ INFO [alpha.dlm] MSG_OPENIN, unable to open message file example.msg for input:
./logger_support_test | cut -d' ' -f3- | diff $tempfile -
passfail $?
-echo -n "2. Severity filter: "
+echo "2. Severity filter: "
cat > $tempfile << .
FATAL [alpha.example] MSG_WRITERR, error writing to test1: 42
ERROR [alpha.example] MSG_RDLOCMES, reading local message file dummy/file
@@ -53,7 +56,7 @@ ERROR [alpha.example] MSG_RDLOCMES, reading local message file dummy/file
./logger_support_test -s error | cut -d' ' -f3- | diff $tempfile -
passfail $?
-echo -n "3. Debug level: "
+echo "3. Debug level: "
cat > $tempfile << .
FATAL [alpha.example] MSG_WRITERR, error writing to test1: 42
ERROR [alpha.example] MSG_RDLOCMES, reading local message file dummy/file
@@ -66,7 +69,7 @@ DEBUG [alpha.example] MSG_RDLOCMES, reading local message file dummy/25
./logger_support_test -s debug -d 25 | cut -d' ' -f3- | diff $tempfile -
passfail $?
-echo -n "4. Local message replacement: "
+echo "4. Local message replacement: "
cat > $tempfile << .
WARN [alpha.log] MSG_IDNOTFND, could not replace message text for 'MSG_NOTHERE': no such message
FATAL [alpha.example] MSG_WRITERR, error writing to test1: 42
@@ -80,11 +83,11 @@ rm -f $localmes
rm -f $tempfile
if [ $failcount -eq 0 ]; then
- echo "PASS: run_time_init_test"
+ echo "PASS: $testname"
elif [ $failcount -eq 1 ]; then
- echo "FAIL: run_time_init_test - 1 test failed"
+ echo "FAIL: $testname - 1 test failed"
else
- echo "FAIL: run_time_init_test - $failcount tests failed"
+ echo "FAIL: $testname - $failcount tests failed"
fi
exit $failcount
More information about the bind10-changes
mailing list