diff options
author | Stephen D. Huston <shuston@apache.org> | 2008-10-15 22:33:34 +0000 |
---|---|---|
committer | Stephen D. Huston <shuston@apache.org> | 2008-10-15 22:33:34 +0000 |
commit | 708790b9914b97404974860f0b801b720dd7a0ec (patch) | |
tree | 7f192e792e4c27d7930a64b2387203b2349dff30 /cpp/src/tests | |
parent | 8cdf7df6f7690b0fc789ad2a9735299953384daf (diff) | |
download | qpid-python-708790b9914b97404974860f0b801b720dd7a0ec.tar.gz |
Split logging options into portable options and sink-related options that are platform-specific. Re-did sink options for Posix as discussed on qpid-dev (no more --log-output, but more specific --log-to-<target> options. Allows addition of Windows options without further reorg of Posix code.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@705083 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests')
-rw-r--r-- | cpp/src/tests/logging.cpp | 37 | ||||
-rwxr-xr-x | cpp/src/tests/start_broker | 2 | ||||
-rwxr-xr-x | cpp/src/tests/start_cluster | 4 | ||||
-rwxr-xr-x | cpp/src/tests/start_cluster_hosts | 2 |
4 files changed, 30 insertions, 15 deletions
diff --git a/cpp/src/tests/logging.cpp b/cpp/src/tests/logging.cpp index 32163c0058..bfd7e52eda 100644 --- a/cpp/src/tests/logging.cpp +++ b/cpp/src/tests/logging.cpp @@ -19,8 +19,13 @@ #include "test_tools.h" #include "qpid/log/Logger.h" #include "qpid/log/Options.h" +#include "qpid/log/OstreamOutput.h" #include "qpid/memory.h" #include "qpid/Options.h" +#if defined (_WIN32) +#else +# include "qpid/log/posix/SinkOptions.h" +#endif #include <boost/test/floating_point_comparison.hpp> #include <boost/format.hpp> @@ -179,7 +184,7 @@ QPID_AUTO_TEST_CASE(testOstreamOutput) { ScopedSuppressLogging ls(l); l.select(Selector(error)); ostringstream os; - l.output(os); + l.output(qpid::make_auto_ptr<Logger::Output>(new OstreamOutput(os))); QPID_LOG(error, "foo"); QPID_LOG(error, "bar"); QPID_LOG(error, "baz"); @@ -257,19 +262,22 @@ QPID_AUTO_TEST_CASE(testOptionsParse) { "--log-enable", "error+:foo", "--log-enable", "debug:bar", "--log-enable", "info", - "--log-output", "x", - "--log-output", "y", + "--log-to-stderr", "no", + "--log-to-file", "logout", "--log-level", "yes", "--log-source", "1", "--log-thread", "true", "--log-function", "YES" }; qpid::log::Options opts(""); + qpid::log::posix::SinkOptions sinks("test"); opts.parse(ARGC(argv), const_cast<char**>(argv)); + sinks = *opts.sinkOptions; vector<string> expect=list_of("error+:foo")("debug:bar")("info"); BOOST_CHECK_EQUAL(expect, opts.selectors); - expect=list_of("x")("y"); - BOOST_CHECK_EQUAL(expect, opts.outputs); + BOOST_CHECK(!sinks.logToStderr); + BOOST_CHECK(!sinks.logToStdout); + BOOST_CHECK(sinks.logFile == "logout"); BOOST_CHECK(opts.level); BOOST_CHECK(opts.source); BOOST_CHECK(opts.function); @@ -278,9 +286,12 @@ QPID_AUTO_TEST_CASE(testOptionsParse) { QPID_AUTO_TEST_CASE(testOptionsDefault) { Options opts(""); - vector<string> expect=list_of("stderr"); - BOOST_CHECK_EQUAL(expect, opts.outputs); - expect=list_of("error+"); + qpid::log::posix::SinkOptions sinks("test"); + sinks = *opts.sinkOptions; + BOOST_CHECK(sinks.logToStderr); + BOOST_CHECK(!sinks.logToStdout); + BOOST_CHECK(sinks.logFile.length() == 0); + vector<string> expect=list_of("error+"); BOOST_CHECK_EQUAL(expect, opts.selectors); BOOST_CHECK(opts.time && opts.level); BOOST_CHECK(!(opts.source || opts.function || opts.thread)); @@ -313,7 +324,8 @@ QPID_AUTO_TEST_CASE(testLoggerStateure) { 0, "--log-time", "no", "--log-source", "yes", - "--log-output", "logging.tmp", + "--log-to-stderr", "no", + "--log-to-file", "logging.tmp", "--log-enable", "critical" }; opts.parse(ARGC(argv), const_cast<char**>(argv)); @@ -332,10 +344,13 @@ QPID_AUTO_TEST_CASE(testQuoteNonPrintable) { Logger& l=Logger::instance(); ScopedSuppressLogging ls(l); Options opts("test"); - opts.outputs.clear(); - opts.outputs.push_back("logging.tmp"); opts.time=false; + qpid::log::posix::SinkOptions *sinks = + dynamic_cast<qpid::log::posix::SinkOptions *>(opts.sinkOptions.get()); + sinks->logToStderr = false; + sinks->logFile = "logging.tmp"; l.configure(opts); + char s[] = "null\0tab\tspace newline\nret\r\x80\x99\xff"; string str(s, sizeof(s)); QPID_LOG(critical, str); diff --git a/cpp/src/tests/start_broker b/cpp/src/tests/start_broker index aabe12ad43..77ec83c5f1 100755 --- a/cpp/src/tests/start_broker +++ b/cpp/src/tests/start_broker @@ -1,4 +1,4 @@ #!/bin/sh # Start a test broker. srcdir=`dirname $0` -exec $srcdir/run_test ../qpidd --auth=no --no-module-dir --daemon --port=0 --log-output qpidd.log "$@" > qpidd.port +exec $srcdir/run_test ../qpidd --auth=no --no-module-dir --daemon --port=0 --log-to-file qpidd.log "$@" > qpidd.port diff --git a/cpp/src/tests/start_cluster b/cpp/src/tests/start_cluster index 0c1722e566..1dc3773500 100755 --- a/cpp/src/tests/start_cluster +++ b/cpp/src/tests/start_cluster @@ -16,10 +16,10 @@ OPTS="-d --load-module ../.libs/cluster.so --cluster-name=$CLUSTER --no-data-di if test "$SIZE" = "one"; then # Special case of singleton cluster, use default port. ../qpidd -q - with_ais_group ../qpidd $OPTS --log-output=cluster.log || exit 1 + with_ais_group ../qpidd $OPTS --log-to-file=cluster.log || exit 1 else for (( i=0; i<SIZE; ++i )); do - PORT=`with_ais_group ../qpidd -p0 --log-output=cluster$i.log $OPTS` || exit 1 + PORT=`with_ais_group ../qpidd -p0 --log-to-file=cluster$i.log $OPTS` || exit 1 echo $PORT >> cluster.ports done fi diff --git a/cpp/src/tests/start_cluster_hosts b/cpp/src/tests/start_cluster_hosts index f1dce9f0de..40670f8a07 100755 --- a/cpp/src/tests/start_cluster_hosts +++ b/cpp/src/tests/start_cluster_hosts @@ -37,7 +37,7 @@ CLUSTER=${*:-$CLUSTER} # Use args or env test -z "$CLUSTER" && { echo Must specify at least one host; exit 1; } -OPTS="-d $PORTOPT --load-module $LIBQPIDCLUSTER --cluster-name=$NAME --no-data-dir --auth=no --log-output=syslog --log-enable=info+" +OPTS="-d $PORTOPT --load-module $LIBQPIDCLUSTER --cluster-name=$NAME --no-data-dir --auth=no --log-to-syslog --log-enable=info+" num=0 for h in $CLUSTER; do |