Commit 6b3132f7 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[1704] Use a null InterprocessSync object for some tests

This makes some tests pass which uses logger_example, which is
a standalone binary.
parent 865669e9
......@@ -28,6 +28,7 @@
#include <log/message_initializer.h>
#include <log/message_reader.h>
#include <log/message_types.h>
#include "util/interprocess_sync_null.h"
using namespace std;
......@@ -148,6 +149,10 @@ LoggerManager::readLocalMessageFile(const char* file) {
MessageDictionary& dictionary = MessageDictionary::globalDictionary();
MessageReader reader(&dictionary);
// Turn off use of any lock files
logger.setInterprocessSync(new isc::util::InterprocessSyncNull("log"));
try {
logger.info(LOG_READING_LOCAL_FILE).arg(file);
......
......@@ -16,8 +16,6 @@
# The logger supports the idea of a "console" logger than logs to either stdout
# or stderr. This test checks that both these options work.
export B10_LOCKFILE_DIR_FROM_BUILD=@abs_top_builddir@
testname="Console output test"
echo $testname
......
......@@ -15,8 +15,6 @@
# Checks that the logger will route messages to the chosen destination.
export B10_LOCKFILE_DIR_FROM_BUILD=@abs_top_builddir@
testname="Destination test"
echo $testname
......
......@@ -16,8 +16,6 @@
# Checks that the initLogger() call uses for unit tests respects the setting of
# the environment variables.
export B10_LOCKFILE_DIR_FROM_BUILD=@abs_top_builddir@
testname="initLogger test"
echo $testname
......
......@@ -16,8 +16,6 @@
# Checks that a local message file can override the definitions in the message
# dictionary.
export B10_LOCKFILE_DIR_FROM_BUILD=@abs_top_builddir@
testname="Local message file test"
echo $testname
......
......@@ -41,6 +41,7 @@
// Include a set of message definitions.
#include <log/log_messages.h>
#include "util/interprocess_sync_null.h"
using namespace isc::log;
using namespace std;
......@@ -282,8 +283,11 @@ int main(int argc, char** argv) {
// Log a few messages to different loggers.
isc::log::Logger logger_ex(ROOT_NAME);
logger_ex.setInterprocessSync(new isc::util::InterprocessSyncNull(ROOT_NAME));
isc::log::Logger logger_alpha("alpha");
logger_alpha.setInterprocessSync(new isc::util::InterprocessSyncNull("alpha"));
isc::log::Logger logger_beta("beta");
logger_beta.setInterprocessSync(new isc::util::InterprocessSyncNull("beta"));
LOG_FATAL(logger_ex, LOG_WRITE_ERROR).arg("test1").arg("42");
LOG_ERROR(logger_ex, LOG_READING_LOCAL_FILE).arg("dummy/file");
......
......@@ -16,8 +16,6 @@
# Checks that the logger will limit the output of messages less severe than
# the severity/debug setting.
export B10_LOCKFILE_DIR_FROM_BUILD=@abs_top_builddir@
testname="Severity test"
echo $testname
......
......@@ -13,7 +13,9 @@ libutil_la_SOURCES += locks.h lru_list.h
libutil_la_SOURCES += strutil.h strutil.cc
libutil_la_SOURCES += buffer.h io_utilities.h
libutil_la_SOURCES += time_utilities.h time_utilities.cc
libutil_la_SOURCES += interprocess_sync.h interprocess_sync_file.h interprocess_sync_file.cc
libutil_la_SOURCES += interprocess_sync.h
libutil_la_SOURCES += interprocess_sync_file.h interprocess_sync_file.cc
libutil_la_SOURCES += interprocess_sync_null.h interprocess_sync_null.cc
libutil_la_SOURCES += range_utilities.h
libutil_la_SOURCES += hash/sha1.h hash/sha1.cc
libutil_la_SOURCES += encode/base16_from_binary.h
......
// Copyright (C) 2012 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.
#include "interprocess_sync_null.h"
namespace isc {
namespace util {
InterprocessSyncNull::~InterprocessSyncNull() {
}
bool
InterprocessSyncNull::lock() {
return (true);
}
bool
InterprocessSyncNull::tryLock() {
return (true);
}
bool
InterprocessSyncNull::unlock() {
return (true);
}
} // namespace util
} // namespace isc
// Copyright (C) 2012 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.
#ifndef __INTERPROCESS_SYNC_NULL_H__
#define __INTERPROCESS_SYNC_NULL_H__
#include "util/interprocess_sync.h"
namespace isc {
namespace util {
/// \brief Null Interprocess Sync Class
///
/// This class specifies a concrete implementation for a null (no effect)
/// interprocess synchronization mechanism. Please see the
/// InterprocessSync class documentation for usage.
class InterprocessSyncNull : public InterprocessSync {
public:
/// \brief Constructor
///
/// Creates a null interprocess synchronization object
///
/// \param name Name of the synchronization task. This has to be
/// identical among the various processes that need to be
/// synchronized for the same task.
InterprocessSyncNull(const std::string& task_name) :
InterprocessSync(task_name)
{}
/// \brief Destructor
virtual ~InterprocessSyncNull();
protected:
/// \brief Acquire the lock (never blocks)
///
/// \return Always returns true
bool lock();
/// \brief Try to acquire a lock (doesn't block)
///
/// \return Always returns true
bool tryLock();
/// \brief Release the lock
///
/// \return Always returns true
bool unlock();
};
} // namespace util
} // namespace isc
#endif // __INTERPROCESS_SYNC_NULL_H__
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment