diff --git a/configure.ac b/configure.ac index 159841f439..79128191ab 100644 --- a/configure.ac +++ b/configure.ac @@ -1297,6 +1297,8 @@ AC_CONFIG_FILES([Makefile src/lib/xfr/Makefile src/lib/xfr/tests/Makefile src/lib/log/Makefile + src/lib/log/interprocess/Makefile + src/lib/log/interprocess/tests/Makefile src/lib/log/compiler/Makefile src/lib/log/tests/Makefile src/lib/resolve/Makefile diff --git a/src/lib/log/Makefile.am b/src/lib/log/Makefile.am index 18d5f909ae..cc00bebc24 100644 --- a/src/lib/log/Makefile.am +++ b/src/lib/log/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = . compiler tests +SUBDIRS = interprocess . compiler tests AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib AM_CPPFLAGS += $(BOOST_INCLUDES) @@ -49,6 +49,6 @@ libb10_log_la_CXXFLAGS += -Wno-error endif libb10_log_la_CPPFLAGS = $(AM_CPPFLAGS) $(LOG4CPLUS_INCLUDES) libb10_log_la_LIBADD = $(top_builddir)/src/lib/util/libb10-util.la -libb10_log_la_LIBADD += $(top_builddir)/src/lib/util/threads/libb10-threads.la +libb10_log_la_LIBADD += interprocess/libb10-log_interprocess.la libb10_log_la_LIBADD += $(LOG4CPLUS_LIBS) libb10_log_la_LDFLAGS = -no-undefined -version-info 1:0:0 diff --git a/src/lib/log/interprocess/Makefile.am b/src/lib/log/interprocess/Makefile.am new file mode 100644 index 0000000000..567ff091ed --- /dev/null +++ b/src/lib/log/interprocess/Makefile.am @@ -0,0 +1,21 @@ +SUBDIRS = . tests + +AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib +AM_CPPFLAGS += -DLOCKFILE_DIR=\"${localstatedir}/${PACKAGE_NAME}\" +AM_CPPFLAGS += $(BOOST_INCLUDES) + +AM_CXXFLAGS = $(B10_CXXFLAGS) + +CLEANFILES = *.gcno *.gcda + +noinst_LTLIBRARIES = libb10-log_interprocess.la + +libb10_log_interprocess_la_SOURCES = interprocess_sync.h +libb10_log_interprocess_la_SOURCES += interprocess_sync_file.h +libb10_log_interprocess_la_SOURCES += interprocess_sync_file.cc +libb10_log_interprocess_la_SOURCES += interprocess_sync_null.h +libb10_log_interprocess_la_SOURCES += interprocess_sync_null.cc + +libb10_log_interprocess_la_LIBADD = $(top_builddir)/src/lib/util/threads/libb10-threads.la + +EXTRA_DIST = README diff --git a/src/lib/log/interprocess/README b/src/lib/log/interprocess/README new file mode 100644 index 0000000000..e910a3a922 --- /dev/null +++ b/src/lib/log/interprocess/README @@ -0,0 +1,13 @@ +The files in this directory implement a helper sub-library of the +inter process locking for the log library. We use our own locks +because such locks are only available in relatively recent versions of +log4cplus. Also (against our usual practice) we somehow re-invented +an in-house version of such a general purose library rather than +existing proven tools such as boost::interprocess. While we decided +to go with the in-house version for the log library at least until we +completely swith to log4cplus's native lock support, no other BIND 10 +module should use this; they should use existing external +tools/libraries. + +This sub-library is therefore "hidden" here. As such, none of these +files should be installed. diff --git a/src/lib/util/interprocess_sync.h b/src/lib/log/interprocess/interprocess_sync.h similarity index 98% rename from src/lib/util/interprocess_sync.h rename to src/lib/log/interprocess/interprocess_sync.h index f55f0ac5ca..10453cce6e 100644 --- a/src/lib/util/interprocess_sync.h +++ b/src/lib/log/interprocess/interprocess_sync.h @@ -18,7 +18,8 @@ #include namespace isc { -namespace util { +namespace log { +namespace interprocess { class InterprocessSyncLocker; // forward declaration @@ -143,7 +144,8 @@ protected: InterprocessSync& sync_; ///< Ref to underlying sync object }; -} // namespace util +} // namespace interprocess +} // namespace log } // namespace isc #endif // INTERPROCESS_SYNC_H diff --git a/src/lib/util/interprocess_sync_file.cc b/src/lib/log/interprocess/interprocess_sync_file.cc similarity index 95% rename from src/lib/util/interprocess_sync_file.cc rename to src/lib/log/interprocess/interprocess_sync_file.cc index 25af55cb37..7f8fcb4fea 100644 --- a/src/lib/util/interprocess_sync_file.cc +++ b/src/lib/log/interprocess/interprocess_sync_file.cc @@ -12,7 +12,7 @@ // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. -#include "interprocess_sync_file.h" +#include #include #include @@ -26,7 +26,8 @@ #include namespace isc { -namespace util { +namespace log { +namespace interprocess { InterprocessSyncFile::~InterprocessSyncFile() { if (fd_ != -1) { @@ -128,5 +129,6 @@ InterprocessSyncFile::unlock() { return (false); } -} // namespace util +} // namespace interprocess +} // namespace log } // namespace isc diff --git a/src/lib/util/interprocess_sync_file.h b/src/lib/log/interprocess/interprocess_sync_file.h similarity index 95% rename from src/lib/util/interprocess_sync_file.h rename to src/lib/log/interprocess/interprocess_sync_file.h index 153b39164f..cb070038c4 100644 --- a/src/lib/util/interprocess_sync_file.h +++ b/src/lib/log/interprocess/interprocess_sync_file.h @@ -15,11 +15,12 @@ #ifndef INTERPROCESS_SYNC_FILE_H #define INTERPROCESS_SYNC_FILE_H -#include +#include #include namespace isc { -namespace util { +namespace log { +namespace interprocess { /// \brief InterprocessSyncFileError /// @@ -85,7 +86,8 @@ private: int fd_; ///< The descriptor for the open file }; -} // namespace util +} // namespace interprocess +} // namespace log } // namespace isc #endif // INTERPROCESS_SYNC_FILE_H diff --git a/src/lib/util/interprocess_sync_null.cc b/src/lib/log/interprocess/interprocess_sync_null.cc similarity index 88% rename from src/lib/util/interprocess_sync_null.cc rename to src/lib/log/interprocess/interprocess_sync_null.cc index 5355d5727e..226f7226ae 100644 --- a/src/lib/util/interprocess_sync_null.cc +++ b/src/lib/log/interprocess/interprocess_sync_null.cc @@ -12,10 +12,11 @@ // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. -#include "interprocess_sync_null.h" +#include namespace isc { -namespace util { +namespace log { +namespace interprocess { InterprocessSyncNull::~InterprocessSyncNull() { } @@ -38,5 +39,6 @@ InterprocessSyncNull::unlock() { return (true); } -} // namespace util +} // namespace interprocess +} // namespace log } // namespace isc diff --git a/src/lib/util/interprocess_sync_null.h b/src/lib/log/interprocess/interprocess_sync_null.h similarity index 93% rename from src/lib/util/interprocess_sync_null.h rename to src/lib/log/interprocess/interprocess_sync_null.h index be775148e0..41dab50143 100644 --- a/src/lib/util/interprocess_sync_null.h +++ b/src/lib/log/interprocess/interprocess_sync_null.h @@ -15,10 +15,11 @@ #ifndef INTERPROCESS_SYNC_NULL_H #define INTERPROCESS_SYNC_NULL_H -#include +#include namespace isc { -namespace util { +namespace log { +namespace interprocess { /// \brief Null Interprocess Sync Class /// @@ -58,7 +59,8 @@ protected: bool unlock(); }; -} // namespace util +} // namespace interprocess +} // namespace log } // namespace isc #endif // INTERPROCESS_SYNC_NULL_H diff --git a/src/lib/log/interprocess/tests/Makefile.am b/src/lib/log/interprocess/tests/Makefile.am new file mode 100644 index 0000000000..3013f99765 --- /dev/null +++ b/src/lib/log/interprocess/tests/Makefile.am @@ -0,0 +1,37 @@ +SUBDIRS = . + +AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib +AM_CPPFLAGS += $(BOOST_INCLUDES) +# XXX: we'll pollute the top builddir for creating a temporary test file +# used to bind a UNIX domain socket so we can minimize the risk of exceeding +# the limit of file name path size. +AM_CPPFLAGS += -DTEST_DATA_TOPBUILDDIR=\"$(abs_top_builddir)\" +AM_CXXFLAGS = $(B10_CXXFLAGS) + +if USE_STATIC_LINK +AM_LDFLAGS = -static +endif + +CLEANFILES = *.gcno *.gcda + +TESTS_ENVIRONMENT = \ + $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND) + +TESTS = +if HAVE_GTEST +TESTS += run_unittests +run_unittests_SOURCES = run_unittests.cc +run_unittests_SOURCES += interprocess_sync_file_unittest.cc +run_unittests_SOURCES += interprocess_sync_null_unittest.cc + +run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) +run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) + +run_unittests_LDADD = ../libb10-log_interprocess.la +run_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la +run_unittests_LDADD += $(top_builddir)/src/lib/util/threads/libb10-threads.la +run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libb10-exceptions.la +run_unittests_LDADD += $(GTEST_LDADD) +endif + +noinst_PROGRAMS = $(TESTS) diff --git a/src/lib/util/tests/interprocess_sync_file_unittest.cc b/src/lib/log/interprocess/tests/interprocess_sync_file_unittest.cc similarity index 95% rename from src/lib/util/tests/interprocess_sync_file_unittest.cc rename to src/lib/log/interprocess/tests/interprocess_sync_file_unittest.cc index 38d9026f37..4df365e29d 100644 --- a/src/lib/util/tests/interprocess_sync_file_unittest.cc +++ b/src/lib/log/interprocess/tests/interprocess_sync_file_unittest.cc @@ -12,18 +12,16 @@ // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. -#include +#include #include -#include +#include #include #include using namespace std; -using isc::util::test::parentReadState; - -namespace isc { -namespace util { +using namespace isc::log::interprocess; +using isc::util::unittests::parentReadState; namespace { TEST(InterprocessSyncFileTest, TestLock) { @@ -150,6 +148,4 @@ TEST(InterprocessSyncFileTest, TestMultipleFilesForked) { EXPECT_EQ (0, unlink(TEST_DATA_TOPBUILDDIR "/test1_lockfile")); } -} // anonymous namespace -} // namespace util -} // namespace isc +} // unnamed namespace diff --git a/src/lib/util/tests/interprocess_sync_null_unittest.cc b/src/lib/log/interprocess/tests/interprocess_sync_null_unittest.cc similarity index 95% rename from src/lib/util/tests/interprocess_sync_null_unittest.cc rename to src/lib/log/interprocess/tests/interprocess_sync_null_unittest.cc index 70e2b07f0e..cc9795c0dc 100644 --- a/src/lib/util/tests/interprocess_sync_null_unittest.cc +++ b/src/lib/log/interprocess/tests/interprocess_sync_null_unittest.cc @@ -12,13 +12,13 @@ // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. -#include "util/interprocess_sync_null.h" +#include #include using namespace std; +using namespace isc::log::interprocess; -namespace isc { -namespace util { +namespace { TEST(InterprocessSyncNullTest, TestNull) { InterprocessSyncNull sync("test1"); @@ -72,5 +72,4 @@ TEST(InterprocessSyncNullTest, TestNull) { EXPECT_TRUE(locker.unlock()); } -} // namespace util -} // namespace isc +} diff --git a/src/lib/log/interprocess/tests/run_unittests.cc b/src/lib/log/interprocess/tests/run_unittests.cc new file mode 100644 index 0000000000..03fb3220d1 --- /dev/null +++ b/src/lib/log/interprocess/tests/run_unittests.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2013 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 +#include +#include + +int +main(int argc, char* argv[]) { + ::testing::InitGoogleTest(&argc, argv); + + setenv("B10_LOCKFILE_DIR_FROM_BUILD", TEST_DATA_TOPBUILDDIR, 1); + return (isc::util::unittests::run_all()); +} diff --git a/src/lib/log/logger.cc b/src/lib/log/logger.cc index fef5627c8a..a04267cfd4 100644 --- a/src/lib/log/logger.cc +++ b/src/lib/log/logger.cc @@ -182,7 +182,7 @@ Logger::fatal(const isc::log::MessageID& ident) { // Replace the interprocess synchronization object void -Logger::setInterprocessSync(isc::util::InterprocessSync* sync) { +Logger::setInterprocessSync(isc::log::interprocess::InterprocessSync* sync) { getLoggerPtr()->setInterprocessSync(sync); } diff --git a/src/lib/log/logger.h b/src/lib/log/logger.h index e3ba163995..de2b30438d 100644 --- a/src/lib/log/logger.h +++ b/src/lib/log/logger.h @@ -25,10 +25,13 @@ #include #include -#include - namespace isc { namespace log { +namespace interprocess { +// Forward declaration to hide implementation details from normal +// applications. +class InterprocessSync; +} /// \page LoggingApi Logging API /// \section LoggingApiOverview Overview @@ -254,11 +257,16 @@ public: /// If this method is called with NULL as the argument, it throws a /// BadInterprocessSync exception. /// + /// \note This method is intended to be used only within this log library + /// and its tests. Normal application shouldn't use it (in fact, + /// normal application shouldn't even be able to instantiate + /// InterprocessSync objects). + /// /// \param sync The logger uses this synchronization object for /// synchronizing output of log messages. It should be deletable and /// the ownership is transferred to the logger. If NULL is passed, /// a BadInterprocessSync exception is thrown. - void setInterprocessSync(isc::util::InterprocessSync* sync); + void setInterprocessSync(isc::log::interprocess::InterprocessSync* sync); /// \brief Equality /// diff --git a/src/lib/log/logger_impl.cc b/src/lib/log/logger_impl.cc index 936373809d..96f021df66 100644 --- a/src/lib/log/logger_impl.cc +++ b/src/lib/log/logger_impl.cc @@ -32,16 +32,15 @@ #include #include #include +#include #include -#include // Note: as log4cplus and the BIND 10 logger have many concepts in common, and // thus many similar names, to disambiguate types we don't "use" the log4cplus // namespace: instead, all log4cplus types are explicitly qualified. using namespace std; -using namespace isc::util; namespace isc { namespace log { @@ -54,7 +53,7 @@ namespace log { LoggerImpl::LoggerImpl(const string& name) : name_(expandLoggerName(name)), logger_(log4cplus::Logger::getInstance(name_)), - sync_(new InterprocessSyncFile("logger")) + sync_(new interprocess::InterprocessSyncFile("logger")) { } @@ -112,7 +111,8 @@ LoggerImpl::lookupMessage(const MessageID& ident) { // Replace the interprocess synchronization object void -LoggerImpl::setInterprocessSync(isc::util::InterprocessSync* sync) { +LoggerImpl::setInterprocessSync(isc::log::interprocess::InterprocessSync* sync) +{ if (sync == NULL) { isc_throw(BadInterprocessSync, "NULL was passed to setInterprocessSync()"); @@ -130,7 +130,7 @@ LoggerImpl::outputRaw(const Severity& severity, const string& message) { // Use an interprocess sync locker for mutual exclusion from other // processes to avoid log messages getting interspersed. - InterprocessSyncLocker locker(*sync_); + interprocess::InterprocessSyncLocker locker(*sync_); if (!locker.lock()) { LOG4CPLUS_ERROR(logger_, "Unable to lock logger lockfile"); diff --git a/src/lib/log/logger_impl.h b/src/lib/log/logger_impl.h index 7280d5ce8f..d8dea26a82 100644 --- a/src/lib/log/logger_impl.h +++ b/src/lib/log/logger_impl.h @@ -31,8 +31,7 @@ // BIND-10 logger files #include #include - -#include +#include namespace isc { namespace log { @@ -178,7 +177,7 @@ public: /// synchronizing output of log messages. It should be deletable and /// the ownership is transferred to the logger implementation. /// If NULL is passed, a BadInterprocessSync exception is thrown. - void setInterprocessSync(isc::util::InterprocessSync* sync); + void setInterprocessSync(isc::log::interprocess::InterprocessSync* sync); /// \brief Equality /// @@ -193,7 +192,7 @@ public: private: std::string name_; ///< Full name of this logger log4cplus::Logger logger_; ///< Underlying log4cplus logger - isc::util::InterprocessSync* sync_; + isc::log::interprocess::InterprocessSync* sync_; }; } // namespace log diff --git a/src/lib/log/logger_manager.cc b/src/lib/log/logger_manager.cc index 085744163c..047c7dcfff 100644 --- a/src/lib/log/logger_manager.cc +++ b/src/lib/log/logger_manager.cc @@ -28,7 +28,7 @@ #include #include #include -#include "util/interprocess_sync_null.h" +#include using namespace std; @@ -157,7 +157,8 @@ LoggerManager::readLocalMessageFile(const char* file) { // be used by standalone programs which may not have write access to // the local state directory (to create lock files). So we switch to // using a null interprocess sync object here. - logger.setInterprocessSync(new isc::util::InterprocessSyncNull("logger")); + logger.setInterprocessSync( + new isc::log::interprocess::InterprocessSyncNull("logger")); try { diff --git a/src/lib/log/tests/Makefile.am b/src/lib/log/tests/Makefile.am index 306d5f91e4..36582e6d23 100644 --- a/src/lib/log/tests/Makefile.am +++ b/src/lib/log/tests/Makefile.am @@ -25,7 +25,6 @@ logger_example_CPPFLAGS = $(AM_CPPFLAGS) logger_example_LDFLAGS = $(AM_LDFLAGS) logger_example_LDADD = $(top_builddir)/src/lib/log/libb10-log.la logger_example_LDADD += $(top_builddir)/src/lib/util/libb10-util.la -logger_example_LDADD += $(top_builddir)/src/lib/util/threads/libb10-threads.la logger_example_LDADD += $(top_builddir)/src/lib/exceptions/libb10-exceptions.la logger_example_LDADD += $(AM_LDADD) $(LOG4CPLUS_LIBS) @@ -35,7 +34,6 @@ init_logger_test_CPPFLAGS = $(AM_CPPFLAGS) init_logger_test_LDFLAGS = $(AM_LDFLAGS) init_logger_test_LDADD = $(top_builddir)/src/lib/log/libb10-log.la init_logger_test_LDADD += $(top_builddir)/src/lib/util/libb10-util.la -init_logger_test_LDADD += $(top_builddir)/src/lib/util/threads/libb10-threads.la init_logger_test_LDADD += $(top_builddir)/src/lib/exceptions/libb10-exceptions.la init_logger_test_LDADD += $(AM_LDADD) $(LOG4CPLUS_LIBS) @@ -45,10 +43,11 @@ buffer_logger_test_CPPFLAGS = $(AM_CPPFLAGS) buffer_logger_test_LDFLAGS = $(AM_LDFLAGS) buffer_logger_test_LDADD = $(top_builddir)/src/lib/log/libb10-log.la buffer_logger_test_LDADD += $(top_builddir)/src/lib/util/libb10-util.la -buffer_logger_test_LDADD += $(top_builddir)/src/lib/util/threads/libb10-threads.la buffer_logger_test_LDADD += $(top_builddir)/src/lib/exceptions/libb10-exceptions.la buffer_logger_test_LDADD += $(AM_LDADD) $(LOG4CPLUS_LIBS) +# This test directly uses libb10-threads, and on some systems it seems to +# require explicit LDADD (even if libb10-log has indirect dependencies) noinst_PROGRAMS += logger_lock_test logger_lock_test_SOURCES = logger_lock_test.cc nodist_logger_lock_test_SOURCES = log_test_messages.cc log_test_messages.h @@ -75,7 +74,6 @@ AM_CPPFLAGS += $(GTEST_INCLUDES) $(LOG4CPLUS_INCLUDES) AM_LDFLAGS += $(GTEST_LDFLAGS) AM_LDADD += $(top_builddir)/src/lib/util/libb10-util.la -AM_LDADD += $(top_builddir)/src/lib/util/threads/libb10-threads.la AM_LDADD += $(top_builddir)/src/lib/log/libb10-log.la AM_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la AM_LDADD += $(top_builddir)/src/lib/exceptions/libb10-exceptions.la diff --git a/src/lib/log/tests/buffer_logger_test.cc b/src/lib/log/tests/buffer_logger_test.cc index 8d1b3cf519..d703e04dae 100644 --- a/src/lib/log/tests/buffer_logger_test.cc +++ b/src/lib/log/tests/buffer_logger_test.cc @@ -16,7 +16,7 @@ #include #include #include -#include +#include using namespace isc::log; @@ -58,7 +58,8 @@ main(int argc, char** argv) { initLogger("buffertest", isc::log::INFO, 0, NULL, true); Logger logger("log"); // No need for file interprocess locking in this test - logger.setInterprocessSync(new isc::util::InterprocessSyncNull("logger")); + logger.setInterprocessSync( + new isc::log::interprocess::InterprocessSyncNull("logger")); LOG_INFO(logger, LOG_BAD_SEVERITY).arg("info"); LOG_DEBUG(logger, 50, LOG_BAD_DESTINATION).arg("debug-50"); LOG_INFO(logger, LOG_BAD_SEVERITY).arg("info"); diff --git a/src/lib/log/tests/logger_example.cc b/src/lib/log/tests/logger_example.cc index 4b2042951c..daadb7c4ff 100644 --- a/src/lib/log/tests/logger_example.cc +++ b/src/lib/log/tests/logger_example.cc @@ -41,11 +41,11 @@ // Include a set of message definitions. #include -#include "util/interprocess_sync_null.h" +#include using namespace isc::log; using namespace std; - +using isc::log::interprocess::InterprocessSyncNull; // Print usage information @@ -286,11 +286,11 @@ int main(int argc, char** argv) { // have write access to a local state directory to create // lockfiles). isc::log::Logger logger_ex(ROOT_NAME); - logger_ex.setInterprocessSync(new isc::util::InterprocessSyncNull("logger")); + logger_ex.setInterprocessSync(new InterprocessSyncNull("logger")); isc::log::Logger logger_alpha("alpha"); - logger_alpha.setInterprocessSync(new isc::util::InterprocessSyncNull("logger")); + logger_alpha.setInterprocessSync(new InterprocessSyncNull("logger")); isc::log::Logger logger_beta("beta"); - logger_beta.setInterprocessSync(new isc::util::InterprocessSyncNull("logger")); + logger_beta.setInterprocessSync(new InterprocessSyncNull("logger")); LOG_FATAL(logger_ex, LOG_WRITE_ERROR).arg("test1").arg("42"); LOG_ERROR(logger_ex, LOG_READING_LOCAL_FILE).arg("dummy/file"); diff --git a/src/lib/log/tests/logger_lock_test.cc b/src/lib/log/tests/logger_lock_test.cc index 7fed5c7921..9b9ee17993 100644 --- a/src/lib/log/tests/logger_lock_test.cc +++ b/src/lib/log/tests/logger_lock_test.cc @@ -16,15 +16,17 @@ #include #include #include -#include "util/interprocess_sync.h" +#include #include "log_test_messages.h" + +#include #include using namespace std; using namespace isc::log; using isc::util::thread::Mutex; -class MockLoggingSync : public isc::util::InterprocessSync { +class MockLoggingSync : public isc::log::interprocess::InterprocessSync { public: /// \brief Constructor MockLoggingSync(const std::string& component_name) : diff --git a/src/lib/log/tests/logger_unittest.cc b/src/lib/log/tests/logger_unittest.cc index 7b62d7923a..77a9d2a3d1 100644 --- a/src/lib/log/tests/logger_unittest.cc +++ b/src/lib/log/tests/logger_unittest.cc @@ -20,10 +20,9 @@ #include #include #include +#include #include "log/tests/log_test_messages.h" -#include - #include #include @@ -391,7 +390,7 @@ TEST_F(LoggerTest, setInterprocessSync) { EXPECT_THROW(logger.setInterprocessSync(NULL), BadInterprocessSync); } -class MockSync : public isc::util::InterprocessSync { +class MockSync : public isc::log::interprocess::InterprocessSync { public: /// \brief Constructor MockSync(const std::string& component_name) : diff --git a/src/lib/util/Makefile.am b/src/lib/util/Makefile.am index 32a93415ff..ff5ef40bc8 100644 --- a/src/lib/util/Makefile.am +++ b/src/lib/util/Makefile.am @@ -4,7 +4,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib AM_CPPFLAGS += -I$(top_srcdir)/src/lib/util -I$(top_builddir)/src/lib/util AM_CPPFLAGS += -I$(top_srcdir)/src/lib/exceptions -I$(top_builddir)/src/lib/exceptions AM_CPPFLAGS += $(BOOST_INCLUDES) -AM_CPPFLAGS += -DLOCKFILE_DIR=\"${localstatedir}/${PACKAGE_NAME}\" AM_CXXFLAGS = $(B10_CXXFLAGS) # If we use the shared-memory support, corresponding Boost library may # cause build failures especially if it's strict about warnings. We've @@ -25,9 +24,6 @@ libb10_util_la_SOURCES += locks.h lru_list.h libb10_util_la_SOURCES += strutil.h strutil.cc libb10_util_la_SOURCES += buffer.h io_utilities.h libb10_util_la_SOURCES += time_utilities.h time_utilities.cc -libb10_util_la_SOURCES += interprocess_sync.h -libb10_util_la_SOURCES += interprocess_sync_file.h interprocess_sync_file.cc -libb10_util_la_SOURCES += interprocess_sync_null.h interprocess_sync_null.cc libb10_util_la_SOURCES += memory_segment.h libb10_util_la_SOURCES += memory_segment_local.h memory_segment_local.cc if USE_SHARED_MEMORY diff --git a/src/lib/util/tests/Makefile.am b/src/lib/util/tests/Makefile.am index 3ee16f9280..ab85fa2021 100644 --- a/src/lib/util/tests/Makefile.am +++ b/src/lib/util/tests/Makefile.am @@ -31,8 +31,6 @@ run_unittests_SOURCES += filename_unittest.cc run_unittests_SOURCES += hex_unittest.cc run_unittests_SOURCES += io_utilities_unittest.cc run_unittests_SOURCES += lru_list_unittest.cc -run_unittests_SOURCES += interprocess_sync_file_unittest.cc -run_unittests_SOURCES += interprocess_sync_null_unittest.cc run_unittests_SOURCES += memory_segment_local_unittest.cc if USE_SHARED_MEMORY run_unittests_SOURCES += memory_segment_mapped_unittest.cc @@ -46,7 +44,6 @@ run_unittests_SOURCES += socketsession_unittest.cc run_unittests_SOURCES += strutil_unittest.cc run_unittests_SOURCES += time_utilities_unittest.cc run_unittests_SOURCES += range_utilities_unittest.cc -run_unittests_SOURCES += interprocess_util.h interprocess_util.cc run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) diff --git a/src/lib/util/tests/memory_segment_mapped_unittest.cc b/src/lib/util/tests/memory_segment_mapped_unittest.cc index dc8dffc95a..475d3e514b 100644 --- a/src/lib/util/tests/memory_segment_mapped_unittest.cc +++ b/src/lib/util/tests/memory_segment_mapped_unittest.cc @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include @@ -42,7 +42,7 @@ using namespace isc::util; using boost::scoped_ptr; -using isc::util::test::parentReadState; +using isc::util::unittests::parentReadState; namespace { // Shortcut to keep code shorter diff --git a/src/lib/util/tests/run_unittests.cc b/src/lib/util/tests/run_unittests.cc index 8789a9c116..41761ca272 100644 --- a/src/lib/util/tests/run_unittests.cc +++ b/src/lib/util/tests/run_unittests.cc @@ -20,6 +20,5 @@ int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); - setenv("B10_LOCKFILE_DIR_FROM_BUILD", TEST_DATA_TOPBUILDDIR, 1); return (isc::util::unittests::run_all()); } diff --git a/src/lib/util/unittests/Makefile.am b/src/lib/util/unittests/Makefile.am index 55e0372977..657c2aabb3 100644 --- a/src/lib/util/unittests/Makefile.am +++ b/src/lib/util/unittests/Makefile.am @@ -11,6 +11,7 @@ libutil_unittests_la_SOURCES += check_valgrind.h check_valgrind.cc libutil_unittests_la_SOURCES += run_all.h run_all.cc libutil_unittests_la_SOURCES += textdata.h libutil_unittests_la_SOURCES += wiredata.h wiredata.cc +libutil_unittests_la_SOURCES += interprocess_util.h interprocess_util.cc endif # For now, this isn't needed for libutil_unittests diff --git a/src/lib/util/tests/interprocess_util.cc b/src/lib/util/unittests/interprocess_util.cc similarity index 98% rename from src/lib/util/tests/interprocess_util.cc rename to src/lib/util/unittests/interprocess_util.cc index dfb04b7146..ce858d4971 100644 --- a/src/lib/util/tests/interprocess_util.cc +++ b/src/lib/util/unittests/interprocess_util.cc @@ -19,7 +19,7 @@ namespace isc { namespace util { -namespace test { +namespace unittests { unsigned char parentReadState(int fd) { diff --git a/src/lib/util/tests/interprocess_util.h b/src/lib/util/unittests/interprocess_util.h similarity index 98% rename from src/lib/util/tests/interprocess_util.h rename to src/lib/util/unittests/interprocess_util.h index 286f9cf8ef..f25ad3e820 100644 --- a/src/lib/util/tests/interprocess_util.h +++ b/src/lib/util/unittests/interprocess_util.h @@ -14,7 +14,7 @@ namespace isc { namespace util { -namespace test { +namespace unittests { /// \brief A helper utility for a simple synchronization with another process. /// /// It waits for incoming data on a given file descriptor up to 5 seconds