2020-02-12 17:08:27 +02:00
|
|
|
// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC")
|
2013-06-17 19:41:33 +01:00
|
|
|
//
|
2015-12-15 21:37:34 +01:00
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2013-06-17 19:41:33 +01:00
|
|
|
|
2016-12-14 16:15:52 +02:00
|
|
|
#include <config.h>
|
|
|
|
|
2013-06-17 19:41:33 +01:00
|
|
|
#include <hooks/callout_handle.h>
|
|
|
|
#include <hooks/callout_manager.h>
|
|
|
|
#include <hooks/library_manager.h>
|
|
|
|
#include <hooks/server_hooks.h>
|
2013-06-21 16:45:42 +01:00
|
|
|
|
2013-06-21 17:46:10 +01:00
|
|
|
#include <hooks/tests/common_test_class.h>
|
2013-06-19 20:38:50 +01:00
|
|
|
#include <hooks/tests/marker_file.h>
|
2013-06-21 16:45:42 +01:00
|
|
|
#include <hooks/tests/test_libraries.h>
|
2013-06-17 19:41:33 +01:00
|
|
|
|
2015-04-14 13:50:19 +02:00
|
|
|
#include <log/message_dictionary.h>
|
|
|
|
#include <log/message_initializer.h>
|
|
|
|
|
2019-10-23 00:48:28 +02:00
|
|
|
#include <util/multi_threading_mgr.h>
|
|
|
|
|
2013-06-17 19:41:33 +01:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include <algorithm>
|
2013-06-19 20:38:50 +01:00
|
|
|
#include <fstream>
|
2013-06-17 19:41:33 +01:00
|
|
|
#include <string>
|
|
|
|
|
2013-06-19 20:38:50 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2013-06-19 16:44:19 +01:00
|
|
|
|
2013-06-17 19:41:33 +01:00
|
|
|
using namespace isc;
|
|
|
|
using namespace isc::hooks;
|
2015-04-14 13:50:19 +02:00
|
|
|
using namespace isc::log;
|
2019-10-23 23:06:55 +02:00
|
|
|
using namespace isc::util;
|
2013-06-17 19:41:33 +01:00
|
|
|
using namespace std;
|
|
|
|
|
2013-06-20 14:57:35 +01:00
|
|
|
namespace {
|
|
|
|
|
2013-06-18 11:30:07 +01:00
|
|
|
/// @brief Library manager test class
|
|
|
|
|
2013-06-21 17:46:10 +01:00
|
|
|
class LibraryManagerTest : public ::testing::Test,
|
|
|
|
public HooksCommonTestClass {
|
2013-06-18 11:30:07 +01:00
|
|
|
public:
|
|
|
|
/// @brief Constructor
|
|
|
|
///
|
2013-06-21 17:46:10 +01:00
|
|
|
/// Initializes the CalloutManager object used in the tests. It sets it
|
|
|
|
/// up with the hooks initialized in the HooksCommonTestClass object and
|
|
|
|
/// with four libraries.
|
2013-06-18 11:30:07 +01:00
|
|
|
LibraryManagerTest() {
|
2013-06-20 13:30:38 +01:00
|
|
|
callout_manager_.reset(new CalloutManager(4));
|
2013-06-18 11:30:07 +01:00
|
|
|
|
2013-06-20 14:57:35 +01:00
|
|
|
// Ensure the marker file is not present at the start of a test.
|
2015-05-12 22:51:43 +02:00
|
|
|
static_cast<void>(remove(MARKER_FILE));
|
2019-10-23 23:06:55 +02:00
|
|
|
|
|
|
|
// Disable multi-threading.
|
2020-02-12 17:49:42 +02:00
|
|
|
MultiThreadingMgr::instance().setMode(false);
|
2013-06-19 20:38:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/// @brief Destructor
|
|
|
|
///
|
2013-06-20 13:30:38 +01:00
|
|
|
/// Ensures a marker file is removed after each test.
|
2013-06-19 20:38:50 +01:00
|
|
|
~LibraryManagerTest() {
|
2015-05-12 22:51:43 +02:00
|
|
|
static_cast<void>(remove(MARKER_FILE));
|
2020-02-12 17:49:42 +02:00
|
|
|
|
|
|
|
// Disable multi-threading.
|
2019-10-23 23:06:55 +02:00
|
|
|
MultiThreadingMgr::instance().setMode(false);
|
2013-06-18 11:30:07 +01:00
|
|
|
}
|
|
|
|
|
2013-06-21 17:46:10 +01:00
|
|
|
/// @brief Marker file present
|
2013-06-20 13:30:38 +01:00
|
|
|
///
|
2013-06-21 17:46:10 +01:00
|
|
|
/// Convenience function to check whether a marker file is present. It
|
|
|
|
/// does this by opening the file.
|
2013-06-20 13:30:38 +01:00
|
|
|
///
|
2013-06-21 17:46:10 +01:00
|
|
|
/// @return true if the marker file is present.
|
|
|
|
bool markerFilePresent() const {
|
|
|
|
|
|
|
|
// Try to open it.
|
|
|
|
std::fstream marker;
|
|
|
|
marker.open(MARKER_FILE, std::fstream::in);
|
|
|
|
|
|
|
|
// Check if it is open and close it if so.
|
|
|
|
bool exists = marker.is_open();
|
|
|
|
if (exists) {
|
|
|
|
marker.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
return (exists);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// @brief Call callouts test
|
2013-06-20 14:57:35 +01:00
|
|
|
///
|
2013-06-21 17:46:10 +01:00
|
|
|
/// A wrapper around the method of the same name in the HooksCommonTestClass
|
|
|
|
/// object, this passes this class's CalloutManager to that method.
|
2013-06-20 13:30:38 +01:00
|
|
|
///
|
|
|
|
/// @param r0...r3, d1..d3 Values and intermediate values expected. They
|
2013-06-20 14:57:35 +01:00
|
|
|
/// are ordered so that the variables appear in the argument list in
|
2013-06-21 17:46:10 +01:00
|
|
|
/// the order they are used. See HooksCommonTestClass::execute for
|
2013-07-03 20:13:39 +01:00
|
|
|
/// a full description. (rN is used to indicate an expected result,
|
|
|
|
/// dN is data to be passed to the calculation.)
|
2013-06-20 13:30:38 +01:00
|
|
|
void executeCallCallouts(int r0, int d1, int r1, int d2, int r2, int d3,
|
|
|
|
int r3) {
|
2013-06-21 17:46:10 +01:00
|
|
|
HooksCommonTestClass::executeCallCallouts(callout_manager_, r0, d1,
|
|
|
|
r1, d2, r2, d3, r3);
|
2013-06-20 13:30:38 +01:00
|
|
|
}
|
|
|
|
|
2017-07-13 10:29:10 +02:00
|
|
|
/// @brief Call command handlers test.
|
|
|
|
///
|
|
|
|
/// A wrapper around the method of the same name in the HooksCommonTestClass
|
|
|
|
/// object, this passes this class's CalloutManager to that method.
|
|
|
|
///
|
|
|
|
/// @param r1..r2, d1..d2 Values and intermediate values expected.
|
|
|
|
void executeCallCommandHandlers(int d1, int r1, int d2, int r2) {
|
|
|
|
HooksCommonTestClass::executeCallCommandHandlers(callout_manager_,
|
|
|
|
d1, r1, d2, r2);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:57:35 +01:00
|
|
|
/// Callout manager used for the test.
|
2013-06-18 11:30:07 +01:00
|
|
|
boost::shared_ptr<CalloutManager> callout_manager_;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// @brief Library manager class
|
|
|
|
///
|
|
|
|
/// This is an instance of the LibraryManager class but with the protected
|
|
|
|
/// methods made public for test purposes.
|
|
|
|
|
|
|
|
class PublicLibraryManager : public isc::hooks::LibraryManager {
|
|
|
|
public:
|
|
|
|
/// @brief Constructor
|
|
|
|
///
|
|
|
|
/// Stores the library name. The actual loading is done in loadLibrary().
|
|
|
|
///
|
|
|
|
/// @param name Name of the library to load. This should be an absolute
|
|
|
|
/// path name.
|
2013-06-19 16:44:19 +01:00
|
|
|
/// @param index Index of this library. For all these tests, it will be
|
|
|
|
/// zero, as we are only using one library.
|
2013-06-18 11:30:07 +01:00
|
|
|
/// @param manager CalloutManager object
|
|
|
|
PublicLibraryManager(const std::string& name, int index,
|
|
|
|
const boost::shared_ptr<CalloutManager>& manager)
|
|
|
|
: LibraryManager(name, index, manager)
|
|
|
|
{}
|
|
|
|
|
2013-06-19 16:44:19 +01:00
|
|
|
/// Public methods that call protected methods on the superclass.
|
2020-06-25 02:08:46 +02:00
|
|
|
using LibraryManager::unloadLibrary;
|
2013-06-19 16:44:19 +01:00
|
|
|
using LibraryManager::openLibrary;
|
|
|
|
using LibraryManager::closeLibrary;
|
|
|
|
using LibraryManager::checkVersion;
|
2019-10-23 00:48:28 +02:00
|
|
|
using LibraryManager::checkMultiThreadingCompatible;
|
2013-06-19 16:44:19 +01:00
|
|
|
using LibraryManager::registerStandardCallouts;
|
2013-06-19 19:52:26 +01:00
|
|
|
using LibraryManager::runLoad;
|
2020-06-25 02:08:46 +02:00
|
|
|
using LibraryManager::prepareUnloadLibrary;
|
2013-06-18 11:30:07 +01:00
|
|
|
};
|
|
|
|
|
2013-06-17 19:41:33 +01:00
|
|
|
|
2017-03-01 23:53:42 +01:00
|
|
|
// Check that LibraryManager constructor requires a not null manager
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, NullManager) {
|
2017-04-23 19:49:37 +02:00
|
|
|
boost::shared_ptr<CalloutManager> null_manager;
|
|
|
|
EXPECT_THROW(PublicLibraryManager(std::string("foo"), 0, null_manager),
|
2017-03-01 23:53:42 +01:00
|
|
|
NoCalloutManager);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:57:35 +01:00
|
|
|
// Check that openLibrary() reports an error when it can't find the specified
|
|
|
|
// library.
|
2013-06-18 11:30:07 +01:00
|
|
|
|
2013-06-20 13:30:38 +01:00
|
|
|
TEST_F(LibraryManagerTest, NoLibrary) {
|
2013-06-18 11:30:07 +01:00
|
|
|
PublicLibraryManager lib_manager(std::string(NOT_PRESENT_LIBRARY),
|
2013-06-19 16:44:19 +01:00
|
|
|
0, callout_manager_);
|
2013-06-18 11:30:07 +01:00
|
|
|
EXPECT_FALSE(lib_manager.openLibrary());
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:57:35 +01:00
|
|
|
// Check that the openLibrary() and closeLibrary() methods work.
|
2013-06-19 16:44:19 +01:00
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, OpenClose) {
|
|
|
|
PublicLibraryManager lib_manager(std::string(BASIC_CALLOUT_LIBRARY),
|
|
|
|
0, callout_manager_);
|
|
|
|
|
|
|
|
// Open and close the library
|
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
|
2013-06-20 14:57:35 +01:00
|
|
|
// Check that a second close on an already closed library does not report
|
|
|
|
// an error.
|
2013-06-19 16:44:19 +01:00
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that the code handles the case of a library with no version function.
|
2013-06-18 11:30:07 +01:00
|
|
|
|
2013-06-20 13:30:38 +01:00
|
|
|
TEST_F(LibraryManagerTest, NoVersion) {
|
2013-06-18 11:30:07 +01:00
|
|
|
PublicLibraryManager lib_manager(std::string(NO_VERSION_LIBRARY),
|
2013-06-19 16:44:19 +01:00
|
|
|
0, callout_manager_);
|
2013-06-18 11:30:07 +01:00
|
|
|
// Open should succeed.
|
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
|
|
|
// Version check should fail.
|
|
|
|
EXPECT_FALSE(lib_manager.checkVersion());
|
|
|
|
|
|
|
|
// Tidy up.
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
2013-06-19 16:44:19 +01:00
|
|
|
// Check that the code handles the case of a library with a version function
|
|
|
|
// that returns an incorrect version number.
|
2013-06-18 11:30:07 +01:00
|
|
|
|
2013-06-20 13:30:38 +01:00
|
|
|
TEST_F(LibraryManagerTest, WrongVersion) {
|
2013-06-18 11:30:07 +01:00
|
|
|
PublicLibraryManager lib_manager(std::string(INCORRECT_VERSION_LIBRARY),
|
2013-06-19 16:44:19 +01:00
|
|
|
0, callout_manager_);
|
2013-06-18 11:30:07 +01:00
|
|
|
// Open should succeed.
|
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
|
|
|
// Version check should fail.
|
|
|
|
EXPECT_FALSE(lib_manager.checkVersion());
|
|
|
|
|
|
|
|
// Tidy up.
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
2013-07-03 20:13:39 +01:00
|
|
|
// Check that the code handles the case of a library where the version function
|
|
|
|
// throws an exception.
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, VersionException) {
|
|
|
|
PublicLibraryManager lib_manager(std::string(FRAMEWORK_EXCEPTION_LIBRARY),
|
|
|
|
0, callout_manager_);
|
|
|
|
// Open should succeed.
|
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
|
|
|
// Version check should fail.
|
|
|
|
EXPECT_FALSE(lib_manager.checkVersion());
|
|
|
|
|
|
|
|
// Tidy up.
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
2013-06-19 16:44:19 +01:00
|
|
|
// Tests that checkVersion() function succeeds in the case of a library with a
|
|
|
|
// version function that returns the correct version number.
|
2013-06-18 11:30:07 +01:00
|
|
|
|
2013-06-19 16:44:19 +01:00
|
|
|
TEST_F(LibraryManagerTest, CorrectVersionReturned) {
|
2013-06-18 11:30:07 +01:00
|
|
|
PublicLibraryManager lib_manager(std::string(BASIC_CALLOUT_LIBRARY),
|
2013-06-19 16:44:19 +01:00
|
|
|
0, callout_manager_);
|
|
|
|
// Open should succeed.
|
2013-06-18 11:30:07 +01:00
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
2013-06-19 16:44:19 +01:00
|
|
|
|
|
|
|
// Version check should succeed.
|
|
|
|
EXPECT_TRUE(lib_manager.checkVersion());
|
|
|
|
|
|
|
|
// Tidy up.
|
2013-06-18 11:30:07 +01:00
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
2019-10-23 00:48:28 +02:00
|
|
|
// Checks that the code handles the case of a library with no
|
|
|
|
// multi_threading_compatible function.
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, NoMultiThreadingCompatible) {
|
|
|
|
PublicLibraryManager lib_manager(std::string(BASIC_CALLOUT_LIBRARY),
|
|
|
|
0, callout_manager_);
|
|
|
|
|
|
|
|
// Open should succeed.
|
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
|
|
|
// Not multi-threading compatible: does not matter without MT.
|
|
|
|
EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible());
|
|
|
|
|
|
|
|
// Not multi-threading compatible: does matter with MT.
|
2019-10-23 23:06:55 +02:00
|
|
|
MultiThreadingMgr::instance().setMode(true);
|
2019-10-23 00:48:28 +02:00
|
|
|
EXPECT_FALSE(lib_manager.checkMultiThreadingCompatible());
|
|
|
|
|
|
|
|
// Tidy up.
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checks that the code handles the case of a library with a
|
|
|
|
// multi_threading_compatible function returning 0 (not compatible).
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, multiThreadingNotCompatible) {
|
|
|
|
PublicLibraryManager lib_manager(std::string(LOAD_ERROR_CALLOUT_LIBRARY),
|
|
|
|
0, callout_manager_);
|
|
|
|
|
|
|
|
// Open should succeed.
|
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
|
|
|
// Not multi-threading compatible: does not matter without MT.
|
|
|
|
EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible());
|
|
|
|
|
|
|
|
// Not multi-threading compatible: does matter with MT.
|
2019-10-23 23:06:55 +02:00
|
|
|
MultiThreadingMgr::instance().setMode(true);
|
2019-10-23 00:48:28 +02:00
|
|
|
EXPECT_FALSE(lib_manager.checkMultiThreadingCompatible());
|
|
|
|
|
|
|
|
// Tidy up.
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checks that the code handles the case of a library with a
|
|
|
|
// multi_threading_compatible function returning 1 (compatible)
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, multiThreadingCompatible) {
|
|
|
|
PublicLibraryManager lib_manager(std::string(FULL_CALLOUT_LIBRARY),
|
|
|
|
0, callout_manager_);
|
|
|
|
|
|
|
|
// Open should succeed.
|
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
|
|
|
// Multi-threading compatible: does not matter without MT.
|
|
|
|
EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible());
|
|
|
|
|
|
|
|
// Multi-threading compatible: does matter with MT.
|
2019-10-23 23:06:55 +02:00
|
|
|
MultiThreadingMgr::instance().setMode(true);
|
2019-10-23 00:48:28 +02:00
|
|
|
EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible());
|
|
|
|
|
|
|
|
// Tidy up.
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checks that the code handles the case of a library with a
|
|
|
|
// multi_threading_compatible function returning 1 (compatible)
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, multiThreadingCompatibleException) {
|
|
|
|
PublicLibraryManager lib_manager(std::string(FRAMEWORK_EXCEPTION_LIBRARY),
|
|
|
|
0, callout_manager_);
|
|
|
|
|
|
|
|
// Open should succeed.
|
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
|
|
|
// Throw exception: does not matter without MT.
|
2019-10-23 23:06:55 +02:00
|
|
|
EXPECT_TRUE(lib_manager.checkMultiThreadingCompatible());
|
2019-10-23 00:48:28 +02:00
|
|
|
|
|
|
|
// Throw exception: does matter with MT.
|
2019-10-23 23:06:55 +02:00
|
|
|
MultiThreadingMgr::instance().setMode(true);
|
2019-10-23 00:48:28 +02:00
|
|
|
EXPECT_FALSE(lib_manager.checkMultiThreadingCompatible());
|
|
|
|
|
|
|
|
// Tidy up.
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
2013-06-19 16:44:19 +01:00
|
|
|
// Checks the registration of standard callouts.
|
2013-06-17 19:41:33 +01:00
|
|
|
|
2013-06-19 16:44:19 +01:00
|
|
|
TEST_F(LibraryManagerTest, RegisterStandardCallouts) {
|
2013-06-17 19:41:33 +01:00
|
|
|
|
|
|
|
// Load the only library, specifying the index of 0 as it's the only
|
|
|
|
// library. This should load all callouts.
|
2013-06-19 16:44:19 +01:00
|
|
|
PublicLibraryManager lib_manager(std::string(BASIC_CALLOUT_LIBRARY),
|
2020-06-25 02:08:46 +02:00
|
|
|
0, callout_manager_);
|
2013-06-19 16:44:19 +01:00
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
|
|
|
// Check the version of the library.
|
|
|
|
EXPECT_TRUE(lib_manager.checkVersion());
|
|
|
|
|
|
|
|
// Load the standard callouts
|
|
|
|
EXPECT_NO_THROW(lib_manager.registerStandardCallouts());
|
2013-06-17 19:41:33 +01:00
|
|
|
|
2013-06-20 13:30:38 +01:00
|
|
|
// Now execute the callouts in the order expected. The library performs
|
|
|
|
// the calculation:
|
|
|
|
//
|
|
|
|
// r3 = (10 + d1) * d2 - d3
|
|
|
|
executeCallCallouts(10, 5, 15, 7, 105, 17, 88);
|
2013-06-19 16:44:19 +01:00
|
|
|
|
|
|
|
// Tidy up
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
2013-06-17 19:41:33 +01:00
|
|
|
}
|
|
|
|
|
2013-06-19 19:52:26 +01:00
|
|
|
// Test that the "load" function is called correctly.
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, CheckLoadCalled) {
|
|
|
|
|
|
|
|
// Load the only library, specifying the index of 0 as it's the only
|
|
|
|
// library. This should load all callouts.
|
|
|
|
PublicLibraryManager lib_manager(std::string(LOAD_CALLOUT_LIBRARY),
|
|
|
|
0, callout_manager_);
|
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
|
|
|
// Check the version of the library.
|
|
|
|
EXPECT_TRUE(lib_manager.checkVersion());
|
|
|
|
|
|
|
|
// Load the standard callouts
|
|
|
|
EXPECT_NO_THROW(lib_manager.registerStandardCallouts());
|
|
|
|
|
2013-07-04 12:24:47 +01:00
|
|
|
// Check that only context_create and hookpt_one have callouts registered.
|
2013-06-19 19:52:26 +01:00
|
|
|
EXPECT_TRUE(callout_manager_->calloutsPresent(
|
|
|
|
ServerHooks::CONTEXT_CREATE));
|
2013-07-04 12:24:47 +01:00
|
|
|
EXPECT_TRUE(callout_manager_->calloutsPresent(hookpt_one_index_));
|
|
|
|
EXPECT_FALSE(callout_manager_->calloutsPresent(hookpt_two_index_));
|
|
|
|
EXPECT_FALSE(callout_manager_->calloutsPresent(hookpt_three_index_));
|
2017-07-13 10:29:10 +02:00
|
|
|
EXPECT_FALSE(callout_manager_->commandHandlersPresent("command-one"));
|
|
|
|
EXPECT_FALSE(callout_manager_->commandHandlersPresent("command-two"));
|
2013-06-19 19:52:26 +01:00
|
|
|
EXPECT_FALSE(callout_manager_->calloutsPresent(
|
|
|
|
ServerHooks::CONTEXT_DESTROY));
|
|
|
|
|
|
|
|
// Call the runLoad() method to run the load() function.
|
|
|
|
EXPECT_TRUE(lib_manager.runLoad());
|
|
|
|
EXPECT_TRUE(callout_manager_->calloutsPresent(
|
|
|
|
ServerHooks::CONTEXT_CREATE));
|
2013-07-04 12:24:47 +01:00
|
|
|
EXPECT_TRUE(callout_manager_->calloutsPresent(hookpt_one_index_));
|
|
|
|
EXPECT_TRUE(callout_manager_->calloutsPresent(hookpt_two_index_));
|
|
|
|
EXPECT_TRUE(callout_manager_->calloutsPresent(hookpt_three_index_));
|
2017-07-13 10:29:10 +02:00
|
|
|
EXPECT_TRUE(callout_manager_->commandHandlersPresent("command-one"));
|
|
|
|
EXPECT_TRUE(callout_manager_->commandHandlersPresent("command-two"));
|
2013-06-19 19:52:26 +01:00
|
|
|
EXPECT_FALSE(callout_manager_->calloutsPresent(
|
|
|
|
ServerHooks::CONTEXT_DESTROY));
|
|
|
|
|
2013-06-20 13:30:38 +01:00
|
|
|
// Now execute the callouts in the order expected. The library performs
|
|
|
|
// the calculation:
|
|
|
|
//
|
|
|
|
// r3 = (5 * d1 + d2) * d3
|
|
|
|
executeCallCallouts(5, 5, 25, 7, 32, 10, 320);
|
2013-06-19 19:52:26 +01:00
|
|
|
|
2017-07-13 10:29:10 +02:00
|
|
|
// Execute command handlers for 'command-one' and 'command-two'.
|
|
|
|
//
|
|
|
|
// r2 = d1 * d2 * 10;
|
|
|
|
executeCallCommandHandlers(5, 5, 7, 350);
|
|
|
|
|
2013-06-19 19:52:26 +01:00
|
|
|
// Tidy up
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
2013-07-03 20:13:39 +01:00
|
|
|
// Check handling of a "load" function that throws an exception
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, CheckLoadException) {
|
|
|
|
|
|
|
|
// Load the only library, specifying the index of 0 as it's the only
|
|
|
|
// library. This should load all callouts.
|
|
|
|
PublicLibraryManager lib_manager(std::string(FRAMEWORK_EXCEPTION_LIBRARY),
|
|
|
|
0, callout_manager_);
|
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
2013-07-04 12:24:47 +01:00
|
|
|
// Running the load function should fail.
|
2013-07-03 20:13:39 +01:00
|
|
|
EXPECT_FALSE(lib_manager.runLoad());
|
|
|
|
|
|
|
|
// Tidy up
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
2013-06-19 19:52:26 +01:00
|
|
|
// Check handling of a "load" function that returns an error.
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, CheckLoadError) {
|
|
|
|
|
|
|
|
// Load the only library, specifying the index of 0 as it's the only
|
|
|
|
// library. This should load all callouts.
|
|
|
|
PublicLibraryManager lib_manager(std::string(LOAD_ERROR_CALLOUT_LIBRARY),
|
|
|
|
0, callout_manager_);
|
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
|
|
|
// Check that we catch a load error
|
|
|
|
EXPECT_FALSE(lib_manager.runLoad());
|
|
|
|
|
|
|
|
// Tidy up
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
2013-06-19 20:38:50 +01:00
|
|
|
// No unload function
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, CheckNoUnload) {
|
|
|
|
|
|
|
|
// Load the only library, specifying the index of 0 as it's the only
|
|
|
|
// library. This should load all callouts.
|
|
|
|
PublicLibraryManager lib_manager(std::string(BASIC_CALLOUT_LIBRARY),
|
|
|
|
0, callout_manager_);
|
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
|
|
|
// Check that no unload function returns true.
|
2020-06-25 02:08:46 +02:00
|
|
|
EXPECT_TRUE(lib_manager.prepareUnloadLibrary());
|
2013-06-19 20:38:50 +01:00
|
|
|
|
|
|
|
// Tidy up
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unload function returns an error
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, CheckUnloadError) {
|
|
|
|
|
|
|
|
// Load the only library, specifying the index of 0 as it's the only
|
|
|
|
// library. This should load all callouts.
|
|
|
|
PublicLibraryManager lib_manager(std::string(LOAD_ERROR_CALLOUT_LIBRARY),
|
|
|
|
0, callout_manager_);
|
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
|
|
|
// Check that unload function returning an error returns false.
|
2020-06-25 02:08:46 +02:00
|
|
|
EXPECT_FALSE(lib_manager.prepareUnloadLibrary());
|
2013-06-19 20:38:50 +01:00
|
|
|
|
|
|
|
// Tidy up
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
2013-07-03 20:13:39 +01:00
|
|
|
// Unload function throws an exception.
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, CheckUnloadException) {
|
|
|
|
|
|
|
|
// Load the only library, specifying the index of 0 as it's the only
|
|
|
|
// library. This should load all callouts.
|
|
|
|
PublicLibraryManager lib_manager(std::string(FRAMEWORK_EXCEPTION_LIBRARY),
|
|
|
|
0, callout_manager_);
|
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
2013-07-04 12:24:47 +01:00
|
|
|
// Check that we detect that the unload function throws an exception.
|
2020-06-25 02:08:46 +02:00
|
|
|
EXPECT_FALSE(lib_manager.prepareUnloadLibrary());
|
2013-07-03 20:13:39 +01:00
|
|
|
|
|
|
|
// Tidy up
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
2013-06-20 13:30:38 +01:00
|
|
|
// Check that the case of the library's unload() function returning a
|
2015-03-14 20:11:23 +01:00
|
|
|
// success is handled correctly.
|
2013-06-19 20:38:50 +01:00
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, CheckUnload) {
|
|
|
|
|
|
|
|
// Load the only library, specifying the index of 0 as it's the only
|
|
|
|
// library. This should load all callouts.
|
|
|
|
PublicLibraryManager lib_manager(std::string(UNLOAD_CALLOUT_LIBRARY),
|
|
|
|
0, callout_manager_);
|
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
2013-06-21 17:46:10 +01:00
|
|
|
|
2013-06-19 20:38:50 +01:00
|
|
|
// Check that the marker file is not present (at least that the file
|
|
|
|
// open fails).
|
2013-06-21 17:46:10 +01:00
|
|
|
EXPECT_FALSE(markerFilePresent());
|
2013-06-19 20:38:50 +01:00
|
|
|
|
|
|
|
// Check that unload function runs and returns a success
|
2020-06-25 02:08:46 +02:00
|
|
|
EXPECT_TRUE(lib_manager.prepareUnloadLibrary());
|
2013-06-19 20:38:50 +01:00
|
|
|
|
2013-06-21 17:46:10 +01:00
|
|
|
// Check that the marker file was created.
|
|
|
|
EXPECT_TRUE(markerFilePresent());
|
2013-06-19 20:38:50 +01:00
|
|
|
|
|
|
|
// Tidy up
|
|
|
|
EXPECT_TRUE(lib_manager.closeLibrary());
|
|
|
|
}
|
|
|
|
|
2013-06-20 13:30:38 +01:00
|
|
|
// Test the operation of unloadLibrary(). We load a library with a set
|
|
|
|
// of callouts then unload it. We need to check that the callouts have been
|
|
|
|
// removed. We'll also check that the library's unload() function was called
|
|
|
|
// as well.
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, LibUnload) {
|
|
|
|
|
|
|
|
// Load the only library, specifying the index of 0 as it's the only
|
|
|
|
// library. This should load all callouts.
|
2017-07-13 10:29:10 +02:00
|
|
|
PublicLibraryManager lib_manager(std::string(LOAD_CALLOUT_LIBRARY),
|
2020-06-25 02:08:46 +02:00
|
|
|
0, callout_manager_);
|
2013-06-20 13:30:38 +01:00
|
|
|
EXPECT_TRUE(lib_manager.openLibrary());
|
|
|
|
|
|
|
|
// Check the version of the library.
|
|
|
|
EXPECT_TRUE(lib_manager.checkVersion());
|
|
|
|
|
|
|
|
// No callouts should be registered at the moment.
|
2013-07-04 12:24:47 +01:00
|
|
|
EXPECT_FALSE(callout_manager_->calloutsPresent(hookpt_one_index_));
|
|
|
|
EXPECT_FALSE(callout_manager_->calloutsPresent(hookpt_two_index_));
|
|
|
|
EXPECT_FALSE(callout_manager_->calloutsPresent(hookpt_three_index_));
|
2017-07-13 10:29:10 +02:00
|
|
|
EXPECT_FALSE(callout_manager_->commandHandlersPresent("command-one"));
|
|
|
|
EXPECT_FALSE(callout_manager_->commandHandlersPresent("command-two"));
|
2013-06-20 13:30:38 +01:00
|
|
|
|
|
|
|
// Load the single standard callout and check it is registered correctly.
|
|
|
|
EXPECT_NO_THROW(lib_manager.registerStandardCallouts());
|
2013-07-04 12:24:47 +01:00
|
|
|
EXPECT_TRUE(callout_manager_->calloutsPresent(hookpt_one_index_));
|
|
|
|
EXPECT_FALSE(callout_manager_->calloutsPresent(hookpt_two_index_));
|
|
|
|
EXPECT_FALSE(callout_manager_->calloutsPresent(hookpt_three_index_));
|
2017-07-13 10:29:10 +02:00
|
|
|
EXPECT_FALSE(callout_manager_->commandHandlersPresent("command-one"));
|
|
|
|
EXPECT_FALSE(callout_manager_->commandHandlersPresent("command-two"));
|
2013-06-20 13:30:38 +01:00
|
|
|
|
|
|
|
// Call the load function to load the other callouts.
|
|
|
|
EXPECT_TRUE(lib_manager.runLoad());
|
2013-07-04 12:24:47 +01:00
|
|
|
EXPECT_TRUE(callout_manager_->calloutsPresent(hookpt_one_index_));
|
|
|
|
EXPECT_TRUE(callout_manager_->calloutsPresent(hookpt_two_index_));
|
|
|
|
EXPECT_TRUE(callout_manager_->calloutsPresent(hookpt_three_index_));
|
2017-07-13 10:29:10 +02:00
|
|
|
EXPECT_TRUE(callout_manager_->commandHandlersPresent("command-one"));
|
|
|
|
EXPECT_TRUE(callout_manager_->commandHandlersPresent("command-two"));
|
2013-06-20 13:30:38 +01:00
|
|
|
|
|
|
|
// Unload the library and check that the callouts have been removed from
|
|
|
|
// the CalloutManager.
|
|
|
|
lib_manager.unloadLibrary();
|
2013-07-04 12:24:47 +01:00
|
|
|
EXPECT_FALSE(callout_manager_->calloutsPresent(hookpt_one_index_));
|
|
|
|
EXPECT_FALSE(callout_manager_->calloutsPresent(hookpt_two_index_));
|
|
|
|
EXPECT_FALSE(callout_manager_->calloutsPresent(hookpt_three_index_));
|
2017-07-13 10:29:10 +02:00
|
|
|
EXPECT_FALSE(callout_manager_->commandHandlersPresent("command-one"));
|
|
|
|
EXPECT_FALSE(callout_manager_->commandHandlersPresent("command-two"));
|
2013-06-20 13:30:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now come the loadLibrary() tests that make use of all the methods tested
|
|
|
|
// above. These tests are really to make sure that the methods have been
|
2013-07-03 20:13:39 +01:00
|
|
|
// tied together correctly.
|
2013-06-20 13:30:38 +01:00
|
|
|
|
|
|
|
// First test the basic error cases - no library, no version function, version
|
|
|
|
// function returning an error.
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, LoadLibraryNoLibrary) {
|
|
|
|
LibraryManager lib_manager(std::string(NOT_PRESENT_LIBRARY), 0,
|
|
|
|
callout_manager_);
|
|
|
|
EXPECT_FALSE(lib_manager.loadLibrary());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that the code handles the case of a library with no version function.
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, LoadLibraryNoVersion) {
|
|
|
|
LibraryManager lib_manager(std::string(NO_VERSION_LIBRARY), 0,
|
|
|
|
callout_manager_);
|
|
|
|
EXPECT_FALSE(lib_manager.loadLibrary());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that the code handles the case of a library with a version function
|
|
|
|
// that returns an incorrect version number.
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, LoadLibraryWrongVersion) {
|
|
|
|
LibraryManager lib_manager(std::string(INCORRECT_VERSION_LIBRARY), 0,
|
|
|
|
callout_manager_);
|
|
|
|
EXPECT_FALSE(lib_manager.loadLibrary());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that the full loadLibrary call works.
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, LoadLibrary) {
|
2020-06-29 14:35:39 +02:00
|
|
|
PublicLibraryManager lib_manager(std::string(FULL_CALLOUT_LIBRARY), 0,
|
|
|
|
callout_manager_);
|
2013-06-20 13:30:38 +01:00
|
|
|
EXPECT_TRUE(lib_manager.loadLibrary());
|
|
|
|
|
|
|
|
// Now execute the callouts in the order expected. The library performs
|
|
|
|
// the calculation:
|
|
|
|
//
|
|
|
|
// r3 = (7 * d1 - d2) * d3
|
|
|
|
executeCallCallouts(7, 5, 35, 9, 26, 3, 78);
|
|
|
|
|
|
|
|
EXPECT_TRUE(lib_manager.unloadLibrary());
|
|
|
|
|
|
|
|
// Check that the callouts have been removed from the callout manager.
|
2013-07-04 12:24:47 +01:00
|
|
|
EXPECT_FALSE(callout_manager_->calloutsPresent(hookpt_one_index_));
|
|
|
|
EXPECT_FALSE(callout_manager_->calloutsPresent(hookpt_two_index_));
|
|
|
|
EXPECT_FALSE(callout_manager_->calloutsPresent(hookpt_three_index_));
|
2013-06-20 13:30:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now test for multiple libraries. We'll load the full callout library
|
|
|
|
// first, then load some of the libraries with missing framework functions.
|
|
|
|
// This will check that when searching for framework functions, only the
|
|
|
|
// specified library is checked, not other loaded libraries. We will
|
|
|
|
// load a second library with suitable callouts and check that the callouts
|
|
|
|
// are added correctly. Finally, we'll unload one of the libraries and
|
|
|
|
// check that only the callouts belonging to that library were removed.
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, LoadMultipleLibraries) {
|
|
|
|
// Load a library with all framework functions.
|
2020-06-25 02:08:46 +02:00
|
|
|
PublicLibraryManager lib_manager_1(std::string(FULL_CALLOUT_LIBRARY),
|
|
|
|
0, callout_manager_);
|
2013-06-20 13:30:38 +01:00
|
|
|
EXPECT_TRUE(lib_manager_1.loadLibrary());
|
|
|
|
|
|
|
|
// Attempt to load a library with no version() function. We should detect
|
|
|
|
// this and not end up calling the function from the already loaded
|
|
|
|
// library.
|
2020-06-25 02:08:46 +02:00
|
|
|
PublicLibraryManager lib_manager_2(std::string(NO_VERSION_LIBRARY),
|
|
|
|
1, callout_manager_);
|
2013-06-20 13:30:38 +01:00
|
|
|
EXPECT_FALSE(lib_manager_2.loadLibrary());
|
|
|
|
|
|
|
|
// Attempt to load the library with an incorrect version. This should
|
|
|
|
// be detected.
|
2020-06-25 02:08:46 +02:00
|
|
|
PublicLibraryManager lib_manager_3(std::string(INCORRECT_VERSION_LIBRARY),
|
|
|
|
1, callout_manager_);
|
2013-06-20 13:30:38 +01:00
|
|
|
EXPECT_FALSE(lib_manager_3.loadLibrary());
|
|
|
|
|
|
|
|
// Load the basic callout library. This only has standard callouts so,
|
|
|
|
// if the first library's load() function gets called, some callouts
|
|
|
|
// will be registered twice and lead to incorrect results.
|
2020-06-25 02:08:46 +02:00
|
|
|
PublicLibraryManager lib_manager_4(std::string(BASIC_CALLOUT_LIBRARY),
|
|
|
|
1, callout_manager_);
|
2013-06-20 13:30:38 +01:00
|
|
|
EXPECT_TRUE(lib_manager_4.loadLibrary());
|
|
|
|
|
|
|
|
// Execute the callouts. The first library implements the calculation.
|
|
|
|
//
|
|
|
|
// r3 = (7 * d1 - d2) * d3
|
2013-07-04 12:24:47 +01:00
|
|
|
//
|
2013-06-20 13:30:38 +01:00
|
|
|
// The last-loaded library implements the calculation
|
|
|
|
//
|
|
|
|
// r3 = (10 + d1) * d2 - d3
|
|
|
|
//
|
|
|
|
// Putting the processing for each library together in the appropriate
|
|
|
|
// order, we get:
|
|
|
|
//
|
|
|
|
// r3 = ((10 * d1 + d1) - d2) * d2 * d3 - d3
|
|
|
|
executeCallCallouts(10, 3, 33, 2, 62, 3, 183);
|
|
|
|
|
2013-06-20 14:57:35 +01:00
|
|
|
// All done, so unload the first library.
|
2013-06-20 13:30:38 +01:00
|
|
|
EXPECT_TRUE(lib_manager_1.unloadLibrary());
|
|
|
|
|
|
|
|
// Now execute the callouts again and check that the results are as
|
|
|
|
// expected for the new calculation.
|
|
|
|
executeCallCallouts(10, 5, 15, 7, 105, 17, 88);
|
|
|
|
|
|
|
|
// ... and tidy up.
|
|
|
|
EXPECT_TRUE(lib_manager_4.unloadLibrary());
|
|
|
|
}
|
|
|
|
|
2013-07-15 14:39:49 +01:00
|
|
|
// Check that libraries can be validated.
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, validateLibraries) {
|
|
|
|
EXPECT_TRUE(LibraryManager::validateLibrary(BASIC_CALLOUT_LIBRARY));
|
|
|
|
EXPECT_TRUE(LibraryManager::validateLibrary(FULL_CALLOUT_LIBRARY));
|
|
|
|
EXPECT_FALSE(LibraryManager::validateLibrary(FRAMEWORK_EXCEPTION_LIBRARY));
|
|
|
|
EXPECT_FALSE(LibraryManager::validateLibrary(INCORRECT_VERSION_LIBRARY));
|
|
|
|
EXPECT_TRUE(LibraryManager::validateLibrary(LOAD_CALLOUT_LIBRARY));
|
|
|
|
EXPECT_TRUE(LibraryManager::validateLibrary(LOAD_ERROR_CALLOUT_LIBRARY));
|
|
|
|
EXPECT_FALSE(LibraryManager::validateLibrary(NOT_PRESENT_LIBRARY));
|
|
|
|
EXPECT_FALSE(LibraryManager::validateLibrary(NO_VERSION_LIBRARY));
|
|
|
|
EXPECT_TRUE(LibraryManager::validateLibrary(UNLOAD_CALLOUT_LIBRARY));
|
2016-03-10 16:33:17 +01:00
|
|
|
EXPECT_TRUE(LibraryManager::validateLibrary(CALLOUT_PARAMS_LIBRARY));
|
2019-10-23 23:06:55 +02:00
|
|
|
|
|
|
|
MultiThreadingMgr::instance().setMode(true);
|
|
|
|
|
|
|
|
EXPECT_FALSE(LibraryManager::validateLibrary(BASIC_CALLOUT_LIBRARY));
|
|
|
|
EXPECT_TRUE(LibraryManager::validateLibrary(FULL_CALLOUT_LIBRARY));
|
|
|
|
EXPECT_FALSE(LibraryManager::validateLibrary(FRAMEWORK_EXCEPTION_LIBRARY));
|
|
|
|
EXPECT_FALSE(LibraryManager::validateLibrary(INCORRECT_VERSION_LIBRARY));
|
|
|
|
EXPECT_FALSE(LibraryManager::validateLibrary(LOAD_CALLOUT_LIBRARY));
|
|
|
|
EXPECT_FALSE(LibraryManager::validateLibrary(LOAD_ERROR_CALLOUT_LIBRARY));
|
|
|
|
EXPECT_FALSE(LibraryManager::validateLibrary(NOT_PRESENT_LIBRARY));
|
|
|
|
EXPECT_FALSE(LibraryManager::validateLibrary(NO_VERSION_LIBRARY));
|
|
|
|
EXPECT_FALSE(LibraryManager::validateLibrary(UNLOAD_CALLOUT_LIBRARY));
|
|
|
|
EXPECT_FALSE(LibraryManager::validateLibrary(CALLOUT_PARAMS_LIBRARY));
|
2013-07-15 14:39:49 +01:00
|
|
|
}
|
|
|
|
|
2015-04-14 13:50:19 +02:00
|
|
|
// Check that log messages are properly registered and unregistered.
|
|
|
|
|
|
|
|
TEST_F(LibraryManagerTest, libraryLoggerSetup) {
|
|
|
|
// Load a library with all framework functions.
|
2020-06-25 02:08:46 +02:00
|
|
|
PublicLibraryManager lib_manager(std::string(BASIC_CALLOUT_LIBRARY),
|
|
|
|
0, callout_manager_);
|
2015-04-14 13:50:19 +02:00
|
|
|
EXPECT_TRUE(lib_manager.loadLibrary());
|
|
|
|
|
|
|
|
// After loading the library, the global logging dictionary should
|
2017-01-24 20:14:22 +01:00
|
|
|
// contain log messages registered for this library.
|
2015-04-14 13:50:19 +02:00
|
|
|
const MessageDictionaryPtr& dict = MessageDictionary::globalDictionary();
|
|
|
|
EXPECT_EQ("basic callout load %1", dict->getText("BCL_LOAD_START"));
|
|
|
|
EXPECT_EQ("basic callout load end", dict->getText("BCL_LOAD_END"));
|
|
|
|
// Some of the messages defined by the hook library are duplicates. But,
|
|
|
|
// the loadLibrary function should have logged the duplicates and clear
|
|
|
|
// the duplicates list. By checking that the list of duplicates is empty
|
|
|
|
// we test that the LibraryManager handles the duplicates (logs and
|
|
|
|
// clears them).
|
|
|
|
EXPECT_TRUE(MessageInitializer::getDuplicates().empty());
|
|
|
|
|
|
|
|
// After unloading the library, the messages should be unregistered.
|
|
|
|
EXPECT_TRUE(lib_manager.unloadLibrary());
|
2020-04-11 17:40:26 +02:00
|
|
|
// The musl libc does not implement dlclose
|
|
|
|
#ifndef LIBC_MUSL
|
2015-04-14 13:50:19 +02:00
|
|
|
EXPECT_TRUE(dict->getText("BCL_LOAD_START").empty());
|
|
|
|
EXPECT_TRUE(dict->getText("BCL_LOAD_END").empty());
|
2020-04-11 17:40:26 +02:00
|
|
|
#endif
|
2015-04-14 13:50:19 +02:00
|
|
|
}
|
|
|
|
|
2013-06-17 19:41:33 +01:00
|
|
|
} // Anonymous namespace
|