Kea: lib_load_test_fixture.h Source File

| Kea 2.2.0

lib_load_test_fixture.h
Go to the documentation of this file.
1// Copyright (C) 2022 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef ISC_TESTUTILS_LIB_LOAD_TEST_FIXTURE_H
8#define ISC_TESTUTILS_LIB_LOAD_TEST_FIXTURE_H
9
10#include <cc/data.h>
11
12#include <gtest/gtest.h>
13
14namespace isc {
15namespace test {
16
18 struct LibLoadTest : ::testing::Test {
20 LibLoadTest() {
21 unloadLibraries();
22 }
23
25 ~LibLoadTest() {
26 unloadLibraries();
27 }
28
33 void addLibrary(const std::string& library, isc::data::ConstElementPtr parameters) {
34 libraries_.push_back({library, parameters});
35 }
36
37 void clearLibraries() {
38 libraries_.clear();
39 }
40
45 bool loadLibraries() {
46 bool result(false);
47 EXPECT_NO_THROW(result = isc::hooks::HooksManager::loadLibraries(libraries_));
48 return result;
49 }
50
55 bool unloadLibraries() {
56 bool result(false);
57 EXPECT_NO_THROW(result = isc::hooks::HooksManager::unloadLibraries());
58 return result;
59 }
60
62 isc::hooks::HookLibsCollection libraries_;
63};
64
65} // namespace test
66} // namespace isc
67
68#endif // ISC_TESTUTILS_LIB_LOAD_TEST_FIXTURE_H
isc::hooks::HooksManager::unloadLibraries
static bool unloadLibraries()
Unload libraries.
Definition: hooks_manager.cc:174
isc::hooks::HooksManager::loadLibraries
static bool loadLibraries(const HookLibsCollection &libraries)
Load and reload libraries.
Definition: hooks_manager.cc:132
data.h
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
isc::hooks::HookLibsCollection
std::vector< HookLibInfo > HookLibsCollection
A storage for information about hook libraries.
Definition: libinfo.h:31
isc
Defines the logger used by the top-level component of kea-lfc.
Definition: agent_parser.cc:143
isc::test::LibLoadTest
Test fixture for testing loading and unloading of hook libraries.
Definition: lib_load_test_fixture.h:18
isc::test::LibLoadTest::unloadLibraries
bool unloadLibraries()
Unloads all libraries.
Definition: lib_load_test_fixture.h:55
isc::test::LibLoadTest::addLibrary
void addLibrary(const std::string &library, isc::data::ConstElementPtr parameters)
Adds a library along with its parameters to the list of libraries to be loaded.
Definition: lib_load_test_fixture.h:33
isc::test::LibLoadTest::loadLibraries
bool loadLibraries()
Load all libraries.
Definition: lib_load_test_fixture.h:45
isc::test::LibLoadTest::~LibLoadTest
~LibLoadTest()
Destructor. Unloads any previously loaded libraries.
Definition: lib_load_test_fixture.h:25
isc::test::LibLoadTest::clearLibraries
void clearLibraries()
Definition: lib_load_test_fixture.h:37
isc::test::LibLoadTest::libraries_
isc::hooks::HookLibsCollection libraries_
Libraries.
Definition: lib_load_test_fixture.h:62
isc::test::LibLoadTest::LibLoadTest
LibLoadTest()
Constructor. Unloads any previously loaded libraries.
Definition: lib_load_test_fixture.h:20