BIND 10 trac555, updated. 1a32f61cafb9f735815bf8f4abb0d8e1019269c3 [trac555] Ensure text of messages starts with lowercase character
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri May 27 13:50:30 UTC 2011
The branch, trac555 has been updated
via 1a32f61cafb9f735815bf8f4abb0d8e1019269c3 (commit)
via f3395938a1ead66ef30ab1d261e3a38fea16faa4 (commit)
via 36e95aa1164d24b5b2c46d64958c709a9a02fd51 (commit)
from 0692e63e77ba5f6e1dd24619f215c06a53a48845 (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 1a32f61cafb9f735815bf8f4abb0d8e1019269c3
Author: Stephen Morris <stephen at isc.org>
Date: Fri May 27 14:50:02 2011 +0100
[trac555] Ensure text of messages starts with lowercase character
commit f3395938a1ead66ef30ab1d261e3a38fea16faa4
Author: Stephen Morris <stephen at isc.org>
Date: Fri May 27 14:41:22 2011 +0100
[trac555] Reorganisation of stand-along logger tests
Renamed the logger_support_test program to the more descriptive
(and accurate) logger_example, and separated out the different
tests into different shell scripts.
commit 36e95aa1164d24b5b2c46d64958c709a9a02fd51
Author: Stephen Morris <stephen at isc.org>
Date: Fri May 27 14:13:34 2011 +0100
[trac555] Use getSeverity() instead of explicitly checking severity string
-----------------------------------------------------------------------
Summary of changes:
configure.ac | 3 +-
src/lib/log/logger_manager.h | 18 ++++----
src/lib/log/messagedef.cc | 8 ++--
src/lib/log/messagedef.h | 2 +-
src/lib/log/messagedef.mes | 6 +-
src/lib/log/tests/Makefile.am | 17 ++++----
src/lib/log/tests/console_test.sh.in | 13 ++++--
.../{logger_support_test.cc => logger_example.cc} | 40 +++++++------------
...un_time_init_test.sh.in => severity_test.sh.in} | 36 +++++-------------
9 files changed, 62 insertions(+), 81 deletions(-)
rename src/lib/log/tests/{logger_support_test.cc => logger_example.cc} (84%)
rename src/lib/log/tests/{run_time_init_test.sh.in => severity_test.sh.in} (67%)
-----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index f6908a7..771391f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -892,7 +892,8 @@ AC_OUTPUT([doc/version.ent
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/log/tests/local_file_test.sh
+ src/lib/log/tests/severity_test.sh
src/lib/util/python/mkpywrapper.py
src/lib/server_common/tests/data_path.h
tests/system/conf.sh
diff --git a/src/lib/log/logger_manager.h b/src/lib/log/logger_manager.h
index f36e493..010c764 100644
--- a/src/lib/log/logger_manager.h
+++ b/src/lib/log/logger_manager.h
@@ -82,6 +82,15 @@ public:
isc::log::Severity severity = isc::log::INFO,
int dbglevel = 0);
+ /// \brief Read local message file
+ ///
+ /// Reads the local message file into the global dictionary, overwriting
+ /// existing messages. If the file contained any message IDs not in the
+ /// dictionary, they are listed in a warning message.
+ ///
+ /// \param file Name of the local message file
+ static void readLocalMessageFile(const char* file);
+
private:
/// \brief Initialize Processing
///
@@ -102,15 +111,6 @@ private:
/// TODO: Check that the root logger has something enabled
void processEnd();
- /// \brief Read local message file
- ///
- /// Reads the local message file into the global dictionary, overwriting
- /// existing messages. If the file contained any message IDs not in the
- /// dictionary, they are listed in a warning message.
- ///
- /// \param file Name of the local message file
- static void readLocalMessageFile(const char* file);
-
// Members
LoggerManagerImpl* impl_; ///< Pointer to implementation
};
diff --git a/src/lib/log/messagedef.cc b/src/lib/log/messagedef.cc
index 19472dd..853722a 100644
--- a/src/lib/log/messagedef.cc
+++ b/src/lib/log/messagedef.cc
@@ -1,4 +1,4 @@
-// File created from messagedef.mes on Fri May 27 12:15:25 2011
+// File created from messagedef.mes on Fri May 27 14:49:45 2011
#include <cstddef>
#include <log/message_types.h>
@@ -34,9 +34,9 @@ extern const isc::log::MessageID MSG_WRITERR = "MSG_WRITERR";
namespace {
const char* values[] = {
- "MSG_BADDESTINATION", "Unrecognized log destination: %1",
- "MSG_BADSEVERITY", "Unrecognized log severity: %1",
- "MSG_BADSTREAM", "Bad log console output stream: %1",
+ "MSG_BADDESTINATION", "unrecognized log destination: %1",
+ "MSG_BADSEVERITY", "unrecognized log severity: %1",
+ "MSG_BADSTREAM", "bad log console output stream: %1",
"MSG_DUPLNS", "line %1: duplicate $NAMESPACE directive found",
"MSG_DUPMSGID", "duplicate message ID (%1) in compiled code",
"MSG_IDNOTFND", "could not replace message text for '%1': no such message",
diff --git a/src/lib/log/messagedef.h b/src/lib/log/messagedef.h
index 9ad6268..bdb1075 100644
--- a/src/lib/log/messagedef.h
+++ b/src/lib/log/messagedef.h
@@ -1,4 +1,4 @@
-// File created from messagedef.mes on Fri May 27 12:15:25 2011
+// File created from messagedef.mes on Fri May 27 14:49:45 2011
#ifndef __MESSAGEDEF_H
#define __MESSAGEDEF_H
diff --git a/src/lib/log/messagedef.mes b/src/lib/log/messagedef.mes
index b377aff..a54931b 100644
--- a/src/lib/log/messagedef.mes
+++ b/src/lib/log/messagedef.mes
@@ -118,14 +118,14 @@ the named output file.
A line starting with a dollar symbol was found, but the first word on the line
(shown in the message) was not a recognised message compiler directive.
-% BADSEVERITY Unrecognized log severity: %1
+% BADSEVERITY unrecognized log severity: %1
A logger severity value was given that was not recognized. The severity
should be one of "DEBUG", "INFO", "WARN", "ERROR", or "FATAL".
-% BADDESTINATION Unrecognized log destination: %1
+% BADDESTINATION unrecognized log destination: %1
A logger destination value was given that was not recognized. The
destination should be one of "console", "file", or "syslog".
-% BADSTREAM Bad log console output stream: %1
+% BADSTREAM bad log console output stream: %1
A log console output stream was given that was not recognized. The
output stream should be one of "stdout", or "stderr"
diff --git a/src/lib/log/tests/Makefile.am b/src/lib/log/tests/Makefile.am
index a66dc83..549d53c 100644
--- a/src/lib/log/tests/Makefile.am
+++ b/src/lib/log/tests/Makefile.am
@@ -36,17 +36,18 @@ run_unittests_LDADD += $(top_builddir)/src/lib/util/libutil.la
run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
endif
-TESTS += logger_support_test
-logger_support_test_SOURCES = logger_support_test.cc
-logger_support_test_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
-logger_support_test_LDFLAGS = $(AM_LDFLAGS) $(LOG4CPLUS_LDFLAGS)
-logger_support_test_LDADD = $(top_builddir)/src/lib/log/liblog.la
-logger_support_test_LDADD += $(top_builddir)/src/lib/util/libutil.la
+TESTS += logger_example
+logger_example_SOURCES = logger_example.cc
+logger_example_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
+logger_example_LDFLAGS = $(AM_LDFLAGS) $(LOG4CPLUS_LDFLAGS)
+logger_example_LDADD = $(top_builddir)/src/lib/log/liblog.la
+logger_example_LDADD += $(top_builddir)/src/lib/util/libutil.la
noinst_PROGRAMS = $(TESTS)
# Additional test using the shell
-PYTESTS = run_time_init_test.sh console_test.sh
+PYTESTS = console_test.sh local_file_test.sh severity_test.sh
check-local:
- $(SHELL) $(abs_builddir)/run_time_init_test.sh
$(SHELL) $(abs_builddir)/console_test.sh
+ $(SHELL) $(abs_builddir)/local_file_test.sh
+ $(SHELL) $(abs_builddir)/severity_test.sh
diff --git a/src/lib/log/tests/console_test.sh.in b/src/lib/log/tests/console_test.sh.in
index ea2e459..e499dfd 100755
--- a/src/lib/log/tests/console_test.sh.in
+++ b/src/lib/log/tests/console_test.sh.in
@@ -13,6 +13,11 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
+# \brief
+#
+# The logger supports the idea of a "console" logger than logs to either stdout
+# or stderr. This test checks that both these options work.
+
testname="Console output test"
echo $testname
@@ -32,22 +37,22 @@ passfail() {
echo "1. Checking that console output to stdout goes to stdout:"
rm -f $tempfile
-./logger_support_test -s error -c stdout 1> $tempfile
+./logger_example -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
+./logger_example -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
+./logger_example -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
+./logger_example -s error -c stderr 1> $tempfile
passfail 0
rm -f $tempfile
diff --git a/src/lib/log/tests/logger_example.cc b/src/lib/log/tests/logger_example.cc
new file mode 100644
index 0000000..fb86ad4
--- /dev/null
+++ b/src/lib/log/tests/logger_example.cc
@@ -0,0 +1,181 @@
+// 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.
+
+/// \brief Example Program
+///
+/// Simple example program showing how to use the logger. The various
+/// command-line options let most aspects of the logger be exercised, so
+/// making this a useful tool for testing.
+///
+/// See the usage() method for details of use.
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <boost/lexical_cast.hpp>
+
+#include <iostream>
+#include <string>
+
+#include <util/strutil.h>
+
+#include <log/logger.h>
+#include <log/logger_level.h>
+#include <log/logger_manager.h>
+#include <log/logger_specification.h>
+#include <log/macros.h>
+#include <log/root_logger_name.h>
+
+// Include a set of message definitions.
+#include <log/messagedef.h>
+
+using namespace isc::log;
+using namespace std;
+
+
+// Print usage information
+
+void usage() {
+ cout <<
+"logger_support_test [-h] [-c stream] [-d dbglevel] [-f file]\n"
+" [-s severity] [localfile]\n"
+"\n"
+" -h Print this message and exit\n"
+"\n"
+" -d dbglevel Debug level. Only interpreted if the severity is 'debug'\n"
+" this is a number between 0 and 99.\n"
+" -c stream Send output to the console. 'stream' is one of 'stdout'\n"
+" of 'stderr'. The '-c' switch is incompatible with '-f'\n"
+" and '-l'\n"
+" -f file Send output to specified file, appending to existing file\n"
+" if one exists. Incompatible with -c and -l switches.\n"
+" -s severity Set the severity of messages output. 'severity' is one\n"
+" of 'debug', 'info', 'warn', 'error', 'fatal', the default\n"
+" being 'info'.\n"
+"\n"
+"If none of -c, -f or -l is given, by default, output is sent to stdout\n";
+}
+
+
+// The program sets the attributes on the root logger and logs a set of
+// messages. Looking at the output determines whether the program worked.
+
+int main(int argc, char** argv) {
+ const string ROOT_NAME = "alpha";
+
+ bool c_found = false; // Set true if "-c" found
+ bool f_found = false; // Set true if "-f" found
+ bool l_found = false; // Set true if "-l" found
+
+ int option; // For getopt() processing
+
+ LoggerSpecification spec(ROOT_NAME); // Logger specification
+ OutputOption outopt; // Logger output option
+
+ // Initialize loggers (to set the root name and initialize logging);
+ LoggerManager::init(ROOT_NAME);
+
+ // Parse options
+ while ((option = getopt(argc, argv, "hc:d:f:s:")) != -1) {
+ switch (option) {
+ case 'c':
+ if (f_found || l_found) {
+ cerr << "Cannot specify -c with -f or -l\n";
+ return (1);
+ }
+
+ c_found = true;
+ outopt.destination = OutputOption::DEST_CONSOLE;
+
+ if (strcmp(optarg, "stdout") == 0) {
+ outopt.stream = OutputOption::STR_STDOUT;
+
+ } else if (strcmp(optarg, "stderr") == 0) {
+ outopt.stream = OutputOption::STR_STDERR;
+
+ } else {
+ cerr << "Unrecognised console option: " << optarg << "\n";
+ return (1);
+ }
+ break;
+
+ case 'd':
+ spec.setDbglevel(boost::lexical_cast<int>(optarg));
+ break;
+
+ case 'f':
+ if (c_found || l_found) {
+ cerr << "Cannot specify -f with -c or -l\n";
+ return (1);
+ }
+
+ f_found = true;
+
+ outopt.destination = OutputOption::DEST_FILE;
+ outopt.filename = optarg;
+ break;
+
+ case 'h':
+ usage();
+ return (0);
+
+ case 's':
+ {
+ string severity(optarg);
+ isc::util::str::uppercase(severity);
+ spec.setSeverity(getSeverity(severity));
+ }
+ break;
+
+ default:
+ std::cerr << "Unrecognised option: " <<
+ static_cast<char>(option) << "\n";
+ return (1);
+ }
+ }
+
+ // Set the local file
+ if (optind < argc) {
+ LoggerManager::readLocalMessageFile(argv[optind]);
+ }
+
+ // Update the logging parameters
+
+ // Set an output option if we have not done so already.
+ if (! (c_found || f_found || l_found)) {
+ outopt.destination = OutputOption::DEST_CONSOLE;
+ outopt.stream = OutputOption::STR_STDOUT;
+ }
+ spec.addOutputOption(outopt);
+
+ // Set the logging options for the root logger.
+ LoggerManager manager;
+ manager.process(spec);
+
+
+ // Log a few messages
+ isc::log::Logger logger_dlm("dlm");
+ isc::log::Logger logger_ex("example");
+ LOG_FATAL(logger_ex, MSG_WRITERR).arg("test1").arg("42");
+ LOG_ERROR(logger_ex, MSG_RDLOCMES).arg("dummy/file");
+ LOG_WARN(logger_dlm, MSG_READERR).arg("a.txt").arg("dummy reason");
+ LOG_INFO(logger_dlm, MSG_OPENIN).arg("example.msg").arg("dummy reason");
+ LOG_DEBUG(logger_ex, 0, MSG_RDLOCMES).arg("dummy/0");
+ LOG_DEBUG(logger_ex, 24, MSG_RDLOCMES).arg("dummy/24");
+ LOG_DEBUG(logger_ex, 25, MSG_RDLOCMES).arg("dummy/25");
+ LOG_DEBUG(logger_ex, 26, MSG_RDLOCMES).arg("dummy/26");
+
+ return (0);
+}
diff --git a/src/lib/log/tests/logger_support_test.cc b/src/lib/log/tests/logger_support_test.cc
deleted file mode 100644
index 3a2b11a..0000000
--- a/src/lib/log/tests/logger_support_test.cc
+++ /dev/null
@@ -1,191 +0,0 @@
-// 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.
-
-/// \brief Example Program
-///
-/// Simple example program showing how to use the logger.
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <boost/lexical_cast.hpp>
-
-#include <iostream>
-#include <string>
-
-#include <log/logger.h>
-#include <log/logger_manager.h>
-#include <log/logger_specification.h>
-#include <log/macros.h>
-#include <log/root_logger_name.h>
-
-// Include a set of message definitions.
-#include <log/messagedef.h>
-
-using namespace isc::log;
-using namespace std;
-
-
-// Print usage information
-
-void usage() {
- cout <<
-"logger_support_test [-h] [-c stream] [-d dbglevel] [-f file]\n"
-" [-s severity] [localfile]\n"
-"\n"
-" -h Print this message and exit\n"
-"\n"
-" -d dbglevel Debug level. Only interpreted if the severity is 'debug'\n"
-" this is a number between 0 and 99.\n"
-" -c stream Send output to the console. 'stream' is one of 'stdout'\n"
-" of 'stderr'. The '-c' switch is incompatible with '-f'\n"
-" and '-l'\n"
-" -f file Send output to specified file, appending to existing file\n"
-" if one exists. Incompatible with -c and -l switches.\n"
-" -s severity Set the severity of messages output. 'severity' is one\n"
-" of 'debug', 'info', 'warn', 'error', 'fatal', the default\n"
-" being 'info'.\n"
-"\n"
-"If none of -c, -f or -l is given, by default, output is sent to stdout\n";
-}
-
-
-// The program sets the attributes on the root logger and logs a set of
-// messages. Looking at the output determines whether the program worked.
-
-int main(int argc, char** argv) {
- const string ROOT_NAME = "alpha";
-
- bool c_found = false; // Set true if "-c" found
- bool f_found = false; // Set true if "-f" found
- bool l_found = false; // Set true if "-l" found
-
- const char* localfile = NULL; // Local message file
- int option; // For getopt() processing
-
- LoggerSpecification spec(ROOT_NAME); // Logger specification
- OutputOption outopt; // Logger output option
-
- // Initialize loggers (to set the root name and initialize logging);
- // We'll reset them later.
- setRootLoggerName(ROOT_NAME);
- Logger rootLogger(ROOT_NAME);
-
- // Parse options
- while ((option = getopt(argc, argv, "hc:d:f:s:")) != -1) {
- switch (option) {
- case 'c':
- if (f_found || l_found) {
- cerr << "Cannot specify -c with -f or -l\n";
- return (1);
- }
-
- c_found = true;
- outopt.destination = OutputOption::DEST_CONSOLE;
-
- if (strcmp(optarg, "stdout") == 0) {
- outopt.stream = OutputOption::STR_STDOUT;
-
- } else if (strcmp(optarg, "stderr") == 0) {
- outopt.stream = OutputOption::STR_STDERR;
-
- } else {
- cerr << "Unrecognised console option: " << optarg << "\n";
- return (1);
- }
- break;
-
- case 'd':
- spec.setDbglevel(boost::lexical_cast<int>(optarg));
- break;
-
- case 'f':
- if (c_found || l_found) {
- cerr << "Cannot specify -f with -c or -l\n";
- return (1);
- }
-
- f_found = true;
-
- outopt.destination = OutputOption::DEST_FILE;
- outopt.filename = optarg;
- break;
-
- case 'h':
- usage();
- return (0);
-
- case 's':
- if (strcmp(optarg, "debug") == 0) {
- spec.setSeverity(isc::log::DEBUG);
-
- } else if (strcmp(optarg, "info") == 0) {
- spec.setSeverity(isc::log::INFO);
-
- } else if (strcmp(optarg, "warn") == 0) {
- spec.setSeverity(isc::log::WARN);
-
- } else if (strcmp(optarg, "error") == 0) {
- spec.setSeverity(isc::log::ERROR);
-
- } else if (strcmp(optarg, "fatal") == 0) {
- spec.setSeverity(isc::log::FATAL);
-
- } else {
- cerr << "Unrecognised severity option: " << optarg << "\n";
- return (1);
- }
- break;
-
- default:
- std::cerr << "Unrecognised option: " <<
- static_cast<char>(option) << "\n";
- return (1);
- }
- }
-
- if (optind < argc) {
- localfile = argv[optind];
- }
-
- // Update the logging parameters
- LoggerManager::init(ROOT_NAME, localfile, isc::log::INFO, 0);
-
- // Set an output option if we have not done so already.
- if (! (c_found || f_found || l_found)) {
- outopt.destination = OutputOption::DEST_CONSOLE;
- outopt.stream = OutputOption::STR_STDOUT;
- }
- spec.addOutputOption(outopt);
-
- // Set the logging options for the root logger.
- LoggerManager manager;
- manager.process(spec);
-
-
- // Log a few messages
- isc::log::Logger logger_dlm("dlm");
- isc::log::Logger logger_ex("example");
- LOG_FATAL(logger_ex, MSG_WRITERR).arg("test1").arg("42");
- LOG_ERROR(logger_ex, MSG_RDLOCMES).arg("dummy/file");
- LOG_WARN(logger_dlm, MSG_READERR).arg("a.txt").arg("dummy reason");
- LOG_INFO(logger_dlm, MSG_OPENIN).arg("example.msg").arg("dummy reason");
- LOG_DEBUG(logger_ex, 0, MSG_RDLOCMES).arg("dummy/0");
- LOG_DEBUG(logger_ex, 24, MSG_RDLOCMES).arg("dummy/24");
- LOG_DEBUG(logger_ex, 25, MSG_RDLOCMES).arg("dummy/25");
- LOG_DEBUG(logger_ex, 26, MSG_RDLOCMES).arg("dummy/26");
-
- return (0);
-}
diff --git a/src/lib/log/tests/run_time_init_test.sh.in b/src/lib/log/tests/run_time_init_test.sh.in
deleted file mode 100755
index 45c3774..0000000
--- a/src/lib/log/tests/run_time_init_test.sh.in
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/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="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"
- else
- echo " ** FAIL"
- failcount=`expr $failcount + $1`
- fi
-}
-
-# Create the local message file for testing
-
-cat > $localmes << .
-\$PREFIX MSG_
-% NOTHERE this message is not in the global dictionary
-% READERR replacement read error, parameters: '%1' and '%2'
-% RDLOCMES replacement read local message file, parameter is '%1'
-.
-
-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
-WARN [alpha.dlm] MSG_READERR, error reading from message file a.txt: dummy reason
-INFO [alpha.dlm] MSG_OPENIN, unable to open message file example.msg for input: dummy reason
-.
-./logger_support_test | cut -d' ' -f3- | diff $tempfile -
-passfail $?
-
-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
-.
-./logger_support_test -s error | cut -d' ' -f3- | diff $tempfile -
-passfail $?
-
-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
-WARN [alpha.dlm] MSG_READERR, error reading from message file a.txt: dummy reason
-INFO [alpha.dlm] MSG_OPENIN, unable to open message file example.msg for input: dummy reason
-DEBUG [alpha.example] MSG_RDLOCMES, reading local message file dummy/0
-DEBUG [alpha.example] MSG_RDLOCMES, reading local message file dummy/24
-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 "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
-ERROR [alpha.example] MSG_RDLOCMES, replacement read local message file, parameter is 'dummy/file'
-WARN [alpha.dlm] MSG_READERR, replacement read error, parameters: 'a.txt' and 'dummy reason'
-.
-./logger_support_test -s warn $localmes | cut -d' ' -f3- | diff $tempfile -
-passfail $?
-
-rm -f $localmes
-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/severity_test.sh.in b/src/lib/log/tests/severity_test.sh.in
new file mode 100755
index 0000000..bee041d
--- /dev/null
+++ b/src/lib/log/tests/severity_test.sh.in
@@ -0,0 +1,77 @@
+#!/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.
+
+# \brief Severity test
+#
+# Checks that the logger will limit the output of messages less severy than
+# the severity/debug setting.
+
+testname="Severity test"
+echo $testname
+
+failcount=0
+tempfile=@abs_builddir@/severity_test_tempfile_$$
+
+passfail() {
+ if [ $1 -eq 0 ]; then
+ echo " -- pass"
+ else
+ echo " ** FAIL"
+ failcount=`expr $failcount + $1`
+ fi
+}
+
+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
+WARN [alpha.dlm] MSG_READERR, error reading from message file a.txt: dummy reason
+INFO [alpha.dlm] MSG_OPENIN, unable to open message file example.msg for input: dummy reason
+.
+./logger_example | cut -d' ' -f3- | diff $tempfile -
+passfail $?
+
+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
+.
+./logger_example -s error | cut -d' ' -f3- | diff $tempfile -
+passfail $?
+
+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
+WARN [alpha.dlm] MSG_READERR, error reading from message file a.txt: dummy reason
+INFO [alpha.dlm] MSG_OPENIN, unable to open message file example.msg for input: dummy reason
+DEBUG [alpha.example] MSG_RDLOCMES, reading local message file dummy/0
+DEBUG [alpha.example] MSG_RDLOCMES, reading local message file dummy/24
+DEBUG [alpha.example] MSG_RDLOCMES, reading local message file dummy/25
+.
+./logger_example -s debug -d 25 | cut -d' ' -f3- | diff $tempfile -
+passfail $?
+
+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
More information about the bind10-changes
mailing list