diff options
author | Razvan Becheriu <razvan@isc.org> | 2024-04-02 14:38:43 +0200 |
---|---|---|
committer | Razvan Becheriu <razvan@isc.org> | 2024-04-03 22:11:45 +0200 |
commit | 027674fa54a986a745d238d15a9c26ea5c35cb43 (patch) | |
tree | 575cc788eb736b6f7873ef1980854b24779901a9 /src | |
parent | [#3297] Removed extra line in ChangeLog (diff) | |
download | kea-027674fa54a986a745d238d15a9c26ea5c35cb43.tar.xz kea-027674fa54a986a745d238d15a9c26ea5c35cb43.zip |
[#3316] fixed doxygen
Diffstat (limited to 'src')
169 files changed, 1095 insertions, 2439 deletions
diff --git a/src/bin/dhcp4/tests/dhcp4_unittests.cc b/src/bin/dhcp4/tests/dhcp4_unittests.cc index 3a7d4ec2a3..5e94bb40ce 100644 --- a/src/bin/dhcp4/tests/dhcp4_unittests.cc +++ b/src/bin/dhcp4/tests/dhcp4_unittests.cc @@ -7,7 +7,7 @@ #include <config.h> #include <log/logger_support.h> -#include <dhcp4/dhcp4_log.h> + #include <gtest/gtest.h> int diff --git a/src/bin/dhcp6/tests/dhcp6_unittests.cc b/src/bin/dhcp6/tests/dhcp6_unittests.cc index a98f513ba1..e551602789 100644 --- a/src/bin/dhcp6/tests/dhcp6_unittests.cc +++ b/src/bin/dhcp6/tests/dhcp6_unittests.cc @@ -14,10 +14,13 @@ int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); + + // See the documentation of the KEA_* environment variables in + // src/lib/log/README for info on how to tweak logging isc::log::initLogger(); setenv("KEA_PIDFILE_DIR", TEST_DATA_BUILDDIR, 1); int result = RUN_ALL_TESTS(); - return result; + return (result); } diff --git a/src/hooks/dhcp/bootp/libloadtests/run_unittests.cc b/src/hooks/dhcp/bootp/libloadtests/run_unittests.cc index d9e195d96f..96a0ba7bb7 100644 --- a/src/hooks/dhcp/bootp/libloadtests/run_unittests.cc +++ b/src/hooks/dhcp/bootp/libloadtests/run_unittests.cc @@ -1,19 +1,18 @@ // Copyright (C) 2022 Internet Systems Consortium, Inc. ("ISC") // -// This Source Code Form is subject to the terms of the End User License -// Agreement. See COPYING file in the premium/ directory. +// 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/. #include <config.h> #include <log/logger_support.h> - #include <gtest/gtest.h> int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - int result = RUN_ALL_TESTS(); return (result); diff --git a/src/hooks/dhcp/lease_cmds/libloadtests/run_unittests.cc b/src/hooks/dhcp/lease_cmds/libloadtests/run_unittests.cc index d9e195d96f..96a0ba7bb7 100644 --- a/src/hooks/dhcp/lease_cmds/libloadtests/run_unittests.cc +++ b/src/hooks/dhcp/lease_cmds/libloadtests/run_unittests.cc @@ -1,19 +1,18 @@ // Copyright (C) 2022 Internet Systems Consortium, Inc. ("ISC") // -// This Source Code Form is subject to the terms of the End User License -// Agreement. See COPYING file in the premium/ directory. +// 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/. #include <config.h> #include <log/logger_support.h> - #include <gtest/gtest.h> int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - int result = RUN_ALL_TESTS(); return (result); diff --git a/src/hooks/dhcp/mysql_cb/libloadtests/run_unittests.cc b/src/hooks/dhcp/mysql_cb/libloadtests/run_unittests.cc index d9e195d96f..96a0ba7bb7 100644 --- a/src/hooks/dhcp/mysql_cb/libloadtests/run_unittests.cc +++ b/src/hooks/dhcp/mysql_cb/libloadtests/run_unittests.cc @@ -1,19 +1,18 @@ // Copyright (C) 2022 Internet Systems Consortium, Inc. ("ISC") // -// This Source Code Form is subject to the terms of the End User License -// Agreement. See COPYING file in the premium/ directory. +// 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/. #include <config.h> #include <log/logger_support.h> - #include <gtest/gtest.h> int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - int result = RUN_ALL_TESTS(); return (result); diff --git a/src/hooks/dhcp/mysql_cb/tests/run_unittests.cc b/src/hooks/dhcp/mysql_cb/tests/run_unittests.cc index 6ec23da404..906418008a 100644 --- a/src/hooks/dhcp/mysql_cb/tests/run_unittests.cc +++ b/src/hooks/dhcp/mysql_cb/tests/run_unittests.cc @@ -7,7 +7,6 @@ #include <config.h> #include <log/logger_support.h> - #include <gtest/gtest.h> int diff --git a/src/hooks/dhcp/perfmon/libloadtests/run_unittests.cc b/src/hooks/dhcp/perfmon/libloadtests/run_unittests.cc index 0500503ac2..755b9e4e88 100644 --- a/src/hooks/dhcp/perfmon/libloadtests/run_unittests.cc +++ b/src/hooks/dhcp/perfmon/libloadtests/run_unittests.cc @@ -1,19 +1,18 @@ // Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC") // -// This Source Code Form is subject to the terms of the End User License -// Agreement. See COPYING file in the premium/ directory. +// 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/. #include <config.h> #include <log/logger_support.h> - #include <gtest/gtest.h> int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - int result = RUN_ALL_TESTS(); return (result); diff --git a/src/hooks/dhcp/pgsql_cb/libloadtests/run_unittests.cc b/src/hooks/dhcp/pgsql_cb/libloadtests/run_unittests.cc index d9e195d96f..96a0ba7bb7 100644 --- a/src/hooks/dhcp/pgsql_cb/libloadtests/run_unittests.cc +++ b/src/hooks/dhcp/pgsql_cb/libloadtests/run_unittests.cc @@ -1,19 +1,18 @@ // Copyright (C) 2022 Internet Systems Consortium, Inc. ("ISC") // -// This Source Code Form is subject to the terms of the End User License -// Agreement. See COPYING file in the premium/ directory. +// 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/. #include <config.h> #include <log/logger_support.h> - #include <gtest/gtest.h> int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - int result = RUN_ALL_TESTS(); return (result); diff --git a/src/hooks/dhcp/pgsql_cb/tests/run_unittests.cc b/src/hooks/dhcp/pgsql_cb/tests/run_unittests.cc index 74904a3d92..1b4d40ccbb 100644 --- a/src/hooks/dhcp/pgsql_cb/tests/run_unittests.cc +++ b/src/hooks/dhcp/pgsql_cb/tests/run_unittests.cc @@ -7,7 +7,6 @@ #include <config.h> #include <log/logger_support.h> - #include <gtest/gtest.h> int diff --git a/src/hooks/dhcp/stat_cmds/libloadtests/run_unittests.cc b/src/hooks/dhcp/stat_cmds/libloadtests/run_unittests.cc index d9e195d96f..96a0ba7bb7 100644 --- a/src/hooks/dhcp/stat_cmds/libloadtests/run_unittests.cc +++ b/src/hooks/dhcp/stat_cmds/libloadtests/run_unittests.cc @@ -1,19 +1,18 @@ // Copyright (C) 2022 Internet Systems Consortium, Inc. ("ISC") // -// This Source Code Form is subject to the terms of the End User License -// Agreement. See COPYING file in the premium/ directory. +// 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/. #include <config.h> #include <log/logger_support.h> - #include <gtest/gtest.h> int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - int result = RUN_ALL_TESTS(); return (result); diff --git a/src/hooks/dhcp/user_chk/tests/run_unittests.cc b/src/hooks/dhcp/user_chk/tests/run_unittests.cc index 83d8a9fa8e..1dc48fd090 100644 --- a/src/hooks/dhcp/user_chk/tests/run_unittests.cc +++ b/src/hooks/dhcp/user_chk/tests/run_unittests.cc @@ -7,14 +7,12 @@ #include <config.h> #include <log/logger_support.h> - #include <gtest/gtest.h> int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - int result = RUN_ALL_TESTS(); return (result); diff --git a/src/lib/asiodns/Makefile.am b/src/lib/asiodns/Makefile.am index b7802cd63c..5ac221b393 100644 --- a/src/lib/asiodns/Makefile.am +++ b/src/lib/asiodns/Makefile.am @@ -1,12 +1,14 @@ SUBDIRS = . tests -AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib +AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib AM_CPPFLAGS += $(BOOST_INCLUDES) AM_CXXFLAGS = $(KEA_CXXFLAGS) CLEANFILES = *.gcno *.gcda +EXTRA_DIST = asiodns_messages.mes + lib_LTLIBRARIES = libkea-asiodns.la libkea_asiodns_la_LDFLAGS = -no-undefined -version-info 47:0:0 @@ -15,10 +17,7 @@ libkea_asiodns_la_SOURCES = io_fetch.cc io_fetch.h libkea_asiodns_la_SOURCES += logger.h logger.cc libkea_asiodns_la_SOURCES += asiodns_messages.cc asiodns_messages.h -EXTRA_DIST = asiodns_messages.mes - -# Note: the ordering matters: -Wno-... must follow -Wextra (defined in -# KEA_CXXFLAGS) +# Note: the ordering matters: -Wno-... must follow -Wextra (defined in KEA_CXXFLAGS) libkea_asiodns_la_CXXFLAGS = $(AM_CXXFLAGS) libkea_asiodns_la_CPPFLAGS = $(AM_CPPFLAGS) libkea_asiodns_la_LIBADD = $(top_builddir)/src/lib/asiolink/libkea-asiolink.la diff --git a/src/lib/asiodns/README b/src/lib/asiodns/README deleted file mode 100644 index e785845342..0000000000 --- a/src/lib/asiodns/README +++ /dev/null @@ -1,154 +0,0 @@ -The asiodns library is intended to provide an abstraction layer between -BIND10 modules and asiolink library. - -These DNS server and client routines are written using the "stackless -coroutine" pattern invented by Chris Kohlhoff and described at -http://blog.think-async.com/2010/03/potted-guide-to-stackless-coroutines.html. -This is intended to simplify development a bit, since it allows the -routines to be written in a straightforward step-step-step fashion rather -than as a complex chain of separate handler functions. - -Coroutine objects (i.e., UDPServer, TCPServer and IOFetch) are objects -with reentrant operator() members. When an instance of one of these -classes is called as a function, it resumes at the position where it left -off. Thus, a UDPServer can issue an asynchronous I/O call and specify -itself as the handler object; when the call completes, the UDPServer -carries on at the same position. As a result, the code can look as -if it were using synchronous, not asynchronous, I/O, providing some of -the benefit of threading but with minimal switching overhead. - -So, in simplified form, the behavior of a DNS Server is: - - REENTER: - while true: - YIELD packet = read_packet - FORK - if not parent: - break - - YIELD answer = DNSLookup(packet, this) - response = DNSAnswer(answer) - YIELD send(response) - -At each "YIELD" point, the coroutine initiates an asynchronous operation, -then pauses and turns over control to some other task on the ASIO service -queue. When the operation completes, the coroutine resumes. - -DNSLookup and DNSAnswer define callback methods -used by a DNS Server to communicate with the module that called it. -They are abstract-only classes whose concrete implementations -are supplied by the calling module. - -The DNSLookup callback always runs asynchronously. Concrete -implementations must be sure to call the server's "resume" method when -it is finished. - -In an authoritative server, the DNSLookup implementation would examine -the query, look up the answer, then call "resume". (See the diagram -in doc/auth_process.jpg.) - -In a recursive server, the DNSLookup implementation would initiate a -DNSQuery, which in turn would be responsible for calling the server's -"resume" method. (See the diagram in doc/recursive_process.jpg.) - -A DNSQuery object is intended to handle resolution of a query over -the network when the local authoritative data sources or cache are not -sufficient. The plan is that it will make use of subsidiary DNSFetch -calls to get data from particular authoritative servers, and when it has -gotten a complete answer, it calls "resume". - -In current form, however, DNSQuery is much simpler; it forwards queries -to a single upstream resolver and passes the answers back to the client. -It is constructed with the address of the forward server. Queries are -initiated with the question to ask the forward server, a buffer into -which to write the answer, and a pointer to the coroutine to be resumed -when the answer has arrived. In simplified form, the DNSQuery routine is: - - REENTER: - render the question into a wire-format query packet - YIELD send(query) - YIELD response = read_packet - server->resume - -Currently, DNSQuery is only implemented for UDP queries. In future work -it will be necessary to write code to fall back to TCP when circumstances -require it. - - -Upstream Fetches -================ -Upstream fetches (queries by the resolver on behalf of a client) are made -using a slightly-modified version of the pattern described above. - -Sockets -------- -First, it will be useful to understand the class hierarchy used in the -fetch logic: - - IOSocket - | - IOAsioSocket - | - +-----+-----+ - | | -UDPSocket TCPSocket - -IOSocket is a wrapper class for a socket and is used by the authoritative -server code. It is an abstract base class, providing little more that the ability to hold the socket and to return the protocol in use. - -Built on this is IOAsioSocket, which adds the open, close, asyncSend and -asyncReceive methods. This is a template class, which takes as template -argument the class of the object that will be used as the callback when the -asynchronous operation completes. This object can be of any type, but must -include an operator() method with the signature: - - operator()(boost::system::error_code ec, size_t length) - -... the two arguments being the status of the completed I/O operation and -the number of bytes transferred. (In the case of the open method, the second -argument will be zero.) - -Finally, the TCPSocket and UDPSocket classes provide the body of the -asynchronous operations. - -Fetch Sequence --------------- -The fetch is implemented by the IOFetch class, which takes as argument the -protocol to use. The sequence is: - - REENTER: - render the question into a wire-format query packet - open() // Open socket and optionally connect - if (! synchronous) { - YIELD; - } - YIELD asyncSend(query) // Send query - do { - YIELD asyncReceive(response) // Read response - } while (! complete(response)) - close() // Drop connection and close socket - server->resume - -The open() method opens a socket for use. On TCP, it also makes a -connection to the remote end. So under UDP the operation will complete -immediately, but under TCP it could take a long time. One solution would be -for the open operation to post an event to the I/O queue; then both cases -could be regarded as being equivalent, with the completion being signalled -by the posting of the completion event. However UDP is the most common case -and that would involve extra overhead. So the open() returns a status -indicating whether the operation completed asynchronously. If it did, the -code yields back to the coroutine; if not the yield is bypassed. - -The asynchronous send is straightforward, invoking the underlying ASIO -function. (Note that the address/port is supplied to both the open() and -asyncSend() methods - it is used by the TCPSocket in open() and by the -UDPSocket in asyncSend().) - -The asyncReceive() method issues an asynchronous read and waits for completion. -The fetch object keeps track of the amount of data received so far and when -the receive completes it calls a method on the socket to determine if the -entire message has been received. (This will always be the case for UDP. On -TCP though, the message is preceded by a count field as several reads may be -required to read all the data.) The fetch loops until all the data is read. - -Finally, the socket is closed and the server called to resume operation. diff --git a/src/lib/asiodns/asiodns.dox b/src/lib/asiodns/asiodns.dox new file mode 100644 index 0000000000..e27c05d4b5 --- /dev/null +++ b/src/lib/asiodns/asiodns.dox @@ -0,0 +1,150 @@ +The asiodns library is intended to provide an abstraction layer between Kea +modules and asiolink library. + +These DNS server and client routines are written using the "stackless coroutine" +pattern invented by Chris Kohlhoff and described at: +http://blog.think-async.com/2010/03/potted-guide-to-stackless-coroutines.html. +This is intended to simplify development a bit, since it allows the routines to +be written in a straightforward step-step-step fashion rather than as a complex +chain of separate handler functions. + +Coroutine objects (i.e., UDPServer, TCPServer and IOFetch) are objects with +reentrant operator() members. When an instance of one of these classes is +called as a function, it resumes at the position where it left off. Thus, an +UDPServer can issue an asynchronous I/O call and specify itself as the handler +object; when the call completes, the UDPServer carries on at the same position. +As a result, the code can look as if it were using synchronous, not asynchronous +I/O, providing some of the benefit of threading but with minimal switching +overhead. + +So, in simplified form, the behavior of a DNS Server is: + + REENTER: + while true: + YIELD packet = read_packet + FORK + if not parent: + break + + YIELD answer = DNSLookup(packet, this) + response = DNSAnswer(answer) + YIELD send(response) + +At each "YIELD" point, the coroutine initiates an asynchronous operation, then +pauses and turns over control to some other task on the ASIO service queue. When +the operation completes, the coroutine resumes. + +The DNSLookup and DNSAnswer define callback methods used by a DNS Server to +communicate with the module that called it. They are abstract-only classes whose +concrete implementations are supplied by the calling module. + +The DNSLookup callback always runs asynchronously. Concrete implementations must +be sure to call the server's "resume" method when it is finished. + +In an authoritative server, the DNSLookup implementation would examine the query, +look up the answer, then call "resume" (See the diagram in doc/auth_process.jpg). + +In a recursive server, the DNSLookup implementation would initiate a DNSQuery, +which in turn would be responsible for calling the server's "resume" method +(See the diagram in doc/recursive_process.jpg). + +A DNSQuery object is intended to handle resolution of a query over the network +when the local authoritative data sources or cache are not sufficient. The plan +is that it will make use of subsidiary DNSFetch calls to get data from\ +particular authoritative servers, and when it has gotten a complete answer, it +calls "resume". + +In current form, however, DNSQuery is much simpler; it forwards queries to a +single upstream resolver and passes the answers back to the client. It is +constructed with the address of the forward server. Queries are initiated with +the question to ask the forward server, a buffer into which to write the answer, +and a pointer to the coroutine to be resumed when the answer has arrived. In +simplified form, the DNSQuery routine is: + + REENTER: + render the question into a wire-format query packet + YIELD send(query) + YIELD response = read_packet + server->resume + +Currently, DNSQuery is only implemented for UDP queries. In future work it will +be necessary to write code to fall back to TCP when circumstances require it. + +Upstream Fetches +================ +Upstream fetches (queries by the resolver on behalf of a client) are made using +a slightly-modified version of the pattern described above. + +Sockets +------- +First, it will be useful to understand the class hierarchy used in the fetch +logic: + + IOSocket + | + IOAsioSocket + | + +-----+-----+ + | | + UDPSocket TCPSocket + +IOSocket is a wrapper class for a socket and is used by the authoritative server +code. It is an abstract base class, providing little more that the ability to +hold the socket and to return the protocol in use. + +Built on this is the IOAsioSocket, which adds the open, close, asyncSend and +asyncReceive methods. This is a template class, which takes as template argument +the class of the object that will be used as the callback when the asynchronous +operation completes. This object can be of any type, but must include an +operator() method with the signature: + + operator()(boost::system::error_code ec, size_t length) + +... the two arguments being the status of the completed I/O operation and the +number of bytes transferred (in the case of the open method, the second argument +will be zero). + +Finally, the TCPSocket and UDPSocket classes provide the body of the +asynchronous operations. + +Fetch Sequence +-------------- +The fetch is implemented by the IOFetch class which takes as argument the +protocol to use. The sequence is: + + REENTER: + render the question into a wire-format query packet + open() // Open socket and optionally connect + if (! synchronous) { + YIELD; + } + YIELD asyncSend(query) // Send query + do { + YIELD asyncReceive(response) // Read response + } while (! complete(response)) + close() // Drop connection and close socket + server->resume + +The open() method opens a socket for use. On TCP, it also makes a connection to +the remote end. So under UDP the operation will complete immediately, but under +TCP it could take a long time. One solution would befor the open operation to +post an event to the I/O queue; then both cases could be regarded as being +equivalent, with the completion being signalled by the posting of the completion +event. However UDP is the most common case and that would involve extra overhead. +So the open() returns a status indicating whether the operation completed +asynchronously. If it did, the code yields back to the coroutine; if not the +yield is bypassed. + +The asynchronous send is straightforward, invoking the underlying ASIO function. +Note that the address/port is supplied to both the open() and asyncSend() +methods - it is used by the TCPSocket in open() and by the UDPSocket in +asyncSend(). + +The asyncReceive() method issues an asynchronous read and waits for completion. +The fetch object keeps track of the amount of data received so far and when the +receive completes it calls a method on the socket to determine if the entire +message has been received. This will always be the case for UDP. On TCP though, +the message is preceded by a count field as several reads may be required to +read all the data. The fetch loops until all the data is read. + +Finally, the socket is closed and the server called to resume operation. diff --git a/src/lib/asiodns/io_fetch.cc b/src/lib/asiodns/io_fetch.cc index 1041e24999..742abc66e9 100644 --- a/src/lib/asiodns/io_fetch.cc +++ b/src/lib/asiodns/io_fetch.cc @@ -20,7 +20,6 @@ #include <dns/opcode.h> #include <cryptolink/crypto_rng.h> #include <dns/rcode.h> -#include <util/buffer.h> #include <util/io.h> #include <boost/scoped_ptr.hpp> @@ -32,23 +31,24 @@ #include <stdint.h> #include <sys/socket.h> -using namespace boost::asio; using namespace isc::asiolink; using namespace isc::dns; -using namespace isc::util; using namespace isc::log; +using namespace isc::util; + +using namespace boost::asio; using namespace std; namespace isc { namespace asiodns { -// Log debug verbosity +// Log debug verbosity. const int DBG_IMPORTANT = DBGLVL_TRACE_BASIC; const int DBG_COMMON = DBGLVL_TRACE_DETAIL; const int DBG_ALL = DBGLVL_TRACE_DETAIL + 20; -/// \brief IOFetch Data +/// @brief IOFetch Data /// /// The data for IOFetch is held in a separate struct pointed to by a shared_ptr /// object. This is because the IOFetch object will be copied often (it is used @@ -56,111 +56,94 @@ const int DBG_ALL = DBGLVL_TRACE_DETAIL + 20; /// want keep the same data). Organising the data in this way keeps copying to /// a minimum. struct IOFetchData : boost::noncopyable { - IOServicePtr io_service_; ///< The IO service + IOServicePtr io_service_; // The IO service // The first two members are shared pointers to a base class because what is // actually instantiated depends on whether the fetch is over UDP or TCP, // which is not known until construction of the IOFetch. Use of a shared // pointer here is merely to ensure deletion when the data object is deleted. - boost::scoped_ptr<IOAsioSocket<IOFetch>> socket; ///< Socket to use for I/O - boost::scoped_ptr<IOEndpoint> remote_snd; ///< Where the fetch is sent - boost::scoped_ptr<IOEndpoint> remote_rcv; ///< Where the response came from - OutputBufferPtr msgbuf; ///< Wire buffer for question - OutputBufferPtr received; ///< Received data put here - IOFetch::Callback* callback; ///< Called on I/O Completion - boost::asio::deadline_timer timer; ///< Timer to measure timeouts - IOFetch::Protocol protocol; ///< Protocol being used - size_t cumulative; ///< Cumulative received amount - size_t expected; ///< Expected amount of data - size_t offset; ///< Offset to receive data - bool stopped; ///< Have we stopped running? - int timeout; ///< Timeout in ms - bool packet; ///< true if packet was supplied + boost::scoped_ptr<IOAsioSocket<IOFetch>> socket; // Socket to use for I/O + boost::scoped_ptr<IOEndpoint> remote_snd; // Where the fetch is sent + boost::scoped_ptr<IOEndpoint> remote_rcv; // Where the response came from + OutputBufferPtr msgbuf; // Wire buffer for question + OutputBufferPtr received; // Received data put here + IOFetch::Callback* callback; // Called on I/O Completion + boost::asio::deadline_timer timer; // Timer to measure timeouts + IOFetch::Protocol protocol; // Protocol being used + size_t cumulative; // Cumulative received amount + size_t expected; // Expected amount of data + size_t offset; // Offset to receive data + bool stopped; // Have we stopped running? + int timeout; // Timeout in ms + bool packet; // true if packet was supplied // In case we need to log an error, the origin of the last asynchronous // I/O is recorded. To save time and simplify the code, this is recorded // as the ID of the error message that would be generated if the I/O failed. // This means that we must make sure that all possible "origins" take the // same arguments in their message in the same order. - isc::log::MessageID origin; ///< Origin of last asynchronous I/O + isc::log::MessageID origin; // Origin of last asynchronous I/O uint8_t staging[IOFetch::STAGING_LENGTH]; - ///< Temporary array for received data - isc::dns::qid_t qid; ///< The QID set in the query + // Temporary array for received data + isc::dns::qid_t qid; // The QID set in the query - /// \brief Constructor + /// @brief Constructor. /// - /// Just fills in the data members of the IOFetchData structure + /// Just fills in the data members of the IOFetchData structure. /// - /// \param proto Either IOFetch::TCP or IOFetch::UDP. - /// \param service I/O Service object to handle the asynchronous + /// @param proto Either IOFetch::TCP or IOFetch::UDP. + /// @param service I/O Service object to handle the asynchronous /// operations. - /// \param address IP address of upstream server - /// \param port Port to use for the query - /// \param buff Output buffer into which the response (in wire format) + /// @param address IP address of upstream server. + /// @param port Port to use for the query. + /// @param buff Output buffer into which the response (in wire format) /// is written (if a response is received). - /// \param cb Callback object containing the callback to be called + /// @param cb Callback object containing the callback to be called /// when we terminate. The caller is responsible for managing this /// object and deleting it if necessary. - /// \param wait Timeout for the fetch (in ms). + /// @param wait Timeout for the fetch (in ms). /// - /// TODO: May need to alter constructor (see comment 4 in Trac ticket #554) + /// TODO: May need to alter constructor (see comment 4 in Trac ticket #554). IOFetchData(IOFetch::Protocol proto, const IOServicePtr& service, - const IOAddress& address, uint16_t port, OutputBufferPtr& buff, - IOFetch::Callback* cb, int wait) : io_service_(service), - socket((proto == IOFetch::UDP) ? - static_cast<IOAsioSocket<IOFetch>*>( - new UDPSocket<IOFetch>(io_service_)) : - static_cast<IOAsioSocket<IOFetch>*>( - new TCPSocket<IOFetch>(io_service_)) - ), + const IOAddress& address, uint16_t port, OutputBufferPtr& buff, + IOFetch::Callback* cb, int wait) : + io_service_(service), socket((proto == IOFetch::UDP) ? + static_cast<IOAsioSocket<IOFetch>*>(new UDPSocket<IOFetch>(io_service_)) : + static_cast<IOAsioSocket<IOFetch>*>(new TCPSocket<IOFetch>(io_service_))), remote_snd((proto == IOFetch::UDP) ? static_cast<IOEndpoint*>(new UDPEndpoint(address, port)) : - static_cast<IOEndpoint*>(new TCPEndpoint(address, port)) - ), + static_cast<IOEndpoint*>(new TCPEndpoint(address, port))), remote_rcv((proto == IOFetch::UDP) ? static_cast<IOEndpoint*>(new UDPEndpoint(address, port)) : - static_cast<IOEndpoint*>(new TCPEndpoint(address, port)) - ), - msgbuf(new OutputBuffer(512)), - received(buff), - callback(cb), - timer(io_service_->getInternalIOService()), - protocol(proto), - cumulative(0), - expected(0), - offset(0), - stopped(false), - timeout(wait), - packet(false), - origin(ASIODNS_UNKNOWN_ORIGIN), - staging(), - qid(cryptolink::generateQid()) { + static_cast<IOEndpoint*>(new TCPEndpoint(address, port))), + msgbuf(new OutputBuffer(512)), received(buff), callback(cb), + timer(io_service_->getInternalIOService()), protocol(proto), cumulative(0), + expected(0), offset(0), stopped(false), timeout(wait), packet(false), + origin(ASIODNS_UNKNOWN_ORIGIN), staging(), qid(cryptolink::generateQid()) { } - /// \brief Destructor + /// @brief Destructor ~IOFetchData() { timer.cancel(); } - // Checks if the response we received was ok; - // - data contains the buffer we read, as well as the address - // we sent to and the address we received from. - // length is provided by the operator() in IOFetch. - // Addresses must match, number of octets read must be at least - // 2, and the first two octets must match the qid of the message - // we sent. + /// @brief Checks if the response we received was ok. + /// + /// The data member contains the buffer we read, as well as the address we + /// sent to and the address we received from, length is provided by the + /// operator() in IOFetch. + /// The addresses must match, number of octets read must be at least two, + /// and they must match the qid of the message we sent. bool responseOK() { return (*remote_snd == *remote_rcv && cumulative >= 2 && readUint16(received->getData(), received->getLength()) == qid); } }; -/// IOFetch Constructor - just initialize the private data - IOFetch::IOFetch(Protocol protocol, const IOServicePtr& service, const isc::dns::Question& question, const IOAddress& address, uint16_t port, OutputBufferPtr& buff, Callback* cb, int wait, bool edns) { - MessagePtr query_msg(new Message(Message::RENDER)); - initIOFetch(query_msg, protocol, service, question, address, port, buff, + MessagePtr query(new Message(Message::RENDER)); + initIOFetch(query, protocol, service, question, address, port, buff, cb, wait, edns); } @@ -174,57 +157,46 @@ IOFetch::IOFetch(Protocol protocol, const IOServicePtr& service, } IOFetch::IOFetch(Protocol protocol, const IOServicePtr& service, - ConstMessagePtr query_message, const IOAddress& address, uint16_t port, - OutputBufferPtr& buff, Callback* cb, int wait) { - MessagePtr msg(new Message(Message::RENDER)); - - msg->setHeaderFlag(Message::HEADERFLAG_RD, - query_message->getHeaderFlag(Message::HEADERFLAG_RD)); - msg->setHeaderFlag(Message::HEADERFLAG_CD, - query_message->getHeaderFlag(Message::HEADERFLAG_CD)); - - initIOFetch(msg, protocol, service, - **(query_message->beginQuestion()), - address, port, buff, cb, wait); + ConstMessagePtr query_message, const IOAddress& address, + uint16_t port, OutputBufferPtr& buff, Callback* cb, int wait) { + MessagePtr question(new Message(Message::RENDER)); + question->setHeaderFlag(Message::HEADERFLAG_RD, + query_message->getHeaderFlag(Message::HEADERFLAG_RD)); + question->setHeaderFlag(Message::HEADERFLAG_CD, + query_message->getHeaderFlag(Message::HEADERFLAG_CD)); + + initIOFetch(question, protocol, service, **(query_message->beginQuestion()), address, + port, buff, cb, wait); } void -IOFetch::initIOFetch(MessagePtr& query_msg, Protocol protocol, - const IOServicePtr& service, - const isc::dns::Question& question, - const IOAddress& address, uint16_t port, +IOFetch::initIOFetch(MessagePtr& query, Protocol protocol, const IOServicePtr& service, + const isc::dns::Question& question, const IOAddress& address, uint16_t port, OutputBufferPtr& buff, Callback* cb, int wait, bool edns) { - data_ = boost::shared_ptr<IOFetchData>(new IOFetchData( - protocol, service, address, port, buff, cb, wait)); - - query_msg->setQid(data_->qid); - query_msg->setOpcode(Opcode::QUERY()); - query_msg->setRcode(Rcode::NOERROR()); - query_msg->setHeaderFlag(Message::HEADERFLAG_RD); - query_msg->addQuestion(question); + data_ = boost::shared_ptr<IOFetchData>(new IOFetchData(protocol, service, address, port, buff, cb, wait)); + query->setQid(data_->qid); + query->setOpcode(Opcode::QUERY()); + query->setRcode(Rcode::NOERROR()); + query->setHeaderFlag(Message::HEADERFLAG_RD); + query->addQuestion(question); if (edns) { EDNSPtr edns_query(new EDNS()); edns_query->setUDPSize(Message::DEFAULT_MAX_EDNS0_UDPSIZE); - query_msg->setEDNS(edns_query); + query->setEDNS(edns_query); } - MessageRenderer renderer; - renderer.setBuffer(data_->msgbuf.get()); - query_msg->toWire(renderer); - renderer.setBuffer(NULL); + MessageRenderer r; + r.setBuffer(data_->msgbuf.get()); + query->toWire(r); + r.setBuffer(NULL); } -// Return protocol in use. - IOFetch::Protocol IOFetch::getProtocol() const { return (data_->protocol); } -/// The function operator is implemented with the "stackless coroutine" -/// pattern; see boost/asio/coroutine.hpp for details. - void IOFetch::operator()(boost::system::error_code ec, size_t length) { if (data_->stopped) { @@ -320,13 +292,6 @@ IOFetch::operator()(boost::system::error_code ec, size_t length) { } } -// Function that stops the coroutine sequence. It is called either when the -// query finishes or when the timer times out. Either way, it sets the -// "stopped_" flag and cancels anything that is in progress. -// -// As the function may be entered multiple times as things wind down, it checks -// if the stopped_ flag is already set. If it is, the call is a no-op. - void IOFetch::stop(Result result) { if (!data_->stopped) { @@ -385,8 +350,6 @@ IOFetch::stop(Result result) { } } -// Log an error - called on I/O failure - void IOFetch::logIOFailure(boost::system::error_code ec) { // Should only get here with a known error code. if ((data_->origin != ASIODNS_OPEN_SOCKET) && @@ -403,5 +366,5 @@ void IOFetch::logIOFailure(boost::system::error_code ec) { arg(data_->remote_snd->getPort()); } -} // namespace asiodns -} // namespace isc { +} // namespace asiodns +} // namespace isc diff --git a/src/lib/asiodns/io_fetch.h b/src/lib/asiodns/io_fetch.h index 57ed3c050e..22ace29c4f 100644 --- a/src/lib/asiodns/io_fetch.h +++ b/src/lib/asiodns/io_fetch.h @@ -5,14 +5,10 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef IO_FETCH_H -#define IO_FETCH_H 1 +#define IO_FETCH_H #include <config.h> -#include <boost/shared_array.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/date_time/posix_time/posix_time_types.hpp> - // We want to use coroutine.hpp from the system's boost headers if possible. // However, very old Boost versions (provided by RHEL 7 or CentOS 7) didn't have // this header. So we can resort to our bundled version, but only if necessary. @@ -22,13 +18,16 @@ #include <ext/coroutine/coroutine.hpp> #endif -#include <boost/system/error_code.hpp> #include <asiolink/io_address.h> #include <asiolink/io_service.h> - -#include <util/buffer.h> -#include <dns/question.h> #include <dns/message.h> +#include <dns/question.h> +#include <util/buffer.h> + +#include <boost/shared_array.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/date_time/posix_time/posix_time_types.hpp> +#include <boost/system/error_code.hpp> namespace isc { namespace asiodns { @@ -36,211 +35,226 @@ namespace asiodns { // Forward declarations struct IOFetchData; -/// \brief Upstream Fetch Processing +/// @brief Upstream Fetch Processing. /// /// IOFetch is the class used to send upstream fetches and to handle responses. -/// -/// \param E Endpoint type to use. - class IOFetch : public boost::asio::coroutine { public: - /// \brief Protocol to use on the fetch + /// @brief Protocol to use on the fetch enum Protocol { UDP = 0, TCP = 1 }; - /// \brief Origin of Asynchronous I/O Call + /// @brief Origin of Asynchronous I/O Call. /// - /// Indicates what initiated an asynchronous I/O call and used in deciding - /// what error message to output if the I/O fails. + /// Indicates what initiated an asynchronous I/O call and used in deciding what + /// error message to output if the I/O fails. enum Origin { - NONE = 0, ///< No asynchronous call outstanding + NONE = 0, // No asynchronous call outstanding OPEN = 1, SEND = 2, RECEIVE = 3, CLOSE = 4 }; - /// \brief Result of Upstream Fetch + /// @brief Result of Upstream Fetch. /// - /// Note that this applies to the status of I/Os in the fetch - a fetch - /// that resulted in a packet being received from the server is a SUCCESS, - /// even if the contents of the packet indicate that some error occurred. + /// @note that this applies to the status of I/Os in the fetch - a fetch that + /// resulted in a packet being received from the server is a SUCCESS, even if + /// the contents of the packet indicate that some error occurred. enum Result { - SUCCESS = 0, ///< Success, fetch completed - TIME_OUT = 1, ///< Failure, fetch timed out - STOPPED = 2, ///< Control code, fetch has been stopped - NOTSET = 3 ///< For testing, indicates value not set + SUCCESS = 0, // Success, fetch completed + TIME_OUT = 1, // Failure, fetch timed out + STOPPED = 2, // Control code, fetch has been stopped + NOTSET = 3 // For testing, indicates value not set }; - // The next enum is a "trick" to allow constants to be defined in a class - // declaration. + /// @note The next enum is a "trick" to allow constants to be defined in a class + /// declaration. - /// \brief Integer Constants + /// @brief Integer Constants. enum { - STAGING_LENGTH = 8192 ///< Size of staging buffer + STAGING_LENGTH = 8192 // Size of staging buffer }; - /// \brief I/O Fetch Callback + /// @brief I/O Fetch Callback. /// - /// Class of callback object for when the fetch itself has completed - an - /// object of this class is passed to the IOFetch constructor and its - /// operator() method called when the fetch completes. + /// Class of callback object for when the fetch itself has completed - an object + /// of this class is passed to the IOFetch constructor and its operator() method + /// called when the fetch completes. /// - /// Note the difference between the two operator() methods: - /// - IOFetch::operator() callback is called when an asynchronous I/O has - /// completed. - /// - IOFetch::Callback::operator() is called when an upstream fetch - which - /// may have involved several asynchronous I/O operations - has completed. + /// @note The difference between the two operator() methods: + /// - IOFetch::operator() callback is called when an asynchronous I/O has completed. + /// - IOFetch::Callback::operator() is called when an upstream fetch - which may + /// have involved several asynchronous I/O operations - has completed. /// /// This is an abstract class. class Callback { public: - /// \brief Default Constructor - Callback() - {} + /// @brief Constructor. + Callback() = default; - /// \brief Virtual Destructor - virtual ~Callback() - {} + /// @brief Destructor. + virtual ~Callback() = default; - /// \brief Callback method + /// @brief Callback method. /// - /// This is the method called when the fetch completes. + /// This method is called when the fetch completes. /// - /// \param result Result of the fetch + /// @param result Result of the fetch. virtual void operator()(Result result) = 0; }; - /// \brief Constructor. + /// @brief Constructor. /// /// Creates the object that will handle the upstream fetch. /// - /// \param protocol Fetch protocol, either IOFetch::TCP or IOFetch::UDP - /// \param service I/O Service object to handle the asynchronous + /// @param protocol Fetch protocol, either IOFetch::TCP or IOFetch::UDP. + /// @param service I/O Service object to handle the asynchronous /// operations. - /// \param question DNS question to send to the upstream server. - /// \param address IP address of upstream server - /// \param port Port to which to connect on the upstream server - /// \param buff Output buffer into which the response (in wire format) + /// @param question DNS question to send to the upstream server. + /// @param address IP address of upstream server. + /// @param port Port to which to connect on the upstream server. + /// @param buff Output buffer into which the response (in wire format) /// is written (if a response is received). - /// \param cb Callback object containing the callback to be called when we + /// @param cb Callback object containing the callback to be called when we /// terminate. The caller is responsible for managing this object /// and deleting it if necessary. - /// \param wait Timeout for the fetch (in ms). The default value of + /// @param wait Timeout for the fetch (in ms). The default value of /// -1 indicates no timeout. - /// \param edns true if the request should be EDNS. The default value is + /// @param edns true if the request should be EDNS. The default value is /// true. - IOFetch(Protocol protocol, const isc::asiolink::IOServicePtr& service, + IOFetch(Protocol protocol, + const isc::asiolink::IOServicePtr& service, const isc::dns::Question& question, const isc::asiolink::IOAddress& address, - uint16_t port, isc::util::OutputBufferPtr& buff, Callback* cb, + uint16_t port, + isc::util::OutputBufferPtr& buff, + Callback* cb, int wait = -1, bool edns = true); - /// \brief Constructor - /// This constructor has one parameter "query_message", which - /// is the shared_ptr to a full query message. It's different - /// with above constructor which has only question section. All - /// other parameters are same. + /// @brief Constructor /// - /// \param protocol Fetch protocol, either IOFetch::TCP or IOFetch::UDP - /// \param service I/O Service object to handle the asynchronous + /// This constructor has one parameter "query_message", which is the shared_ptr + /// to a full query message. It's different with above constructor which has only + /// question section. All other parameters are the same. + /// + /// @param protocol Fetch protocol, either IOFetch::TCP or IOFetch::UDP. + /// @param service I/O Service object to handle the asynchronous /// operations. - /// \param query_message the shared_ptr to a full query message - /// got from a query client. - /// \param address IP address of upstream server - /// \param port Port to which to connect on the upstream server - /// \param buff Output buffer into which the response (in wire format) + /// @param query_message the shared_ptr to a full query message got from a + /// query client. + /// @param address IP address of upstream server. + /// @param port Port to which to connect on the upstream server. + /// @param buff Output buffer into which the response (in wire format) /// is written (if a response is received). - /// \param cb Callback object containing the callback to be called when we + /// @param cb Callback object containing the callback to be called when we /// terminate. The caller is responsible for managing this object /// and deleting it if necessary. - /// \param wait Timeout for the fetch (in ms). The default value of - /// -1 indicates no timeout. - IOFetch(Protocol protocol, const isc::asiolink::IOServicePtr& service, + /// @param wait Timeout for the fetch (in ms). The default value of -1 + /// indicates no timeout. + IOFetch(Protocol protocol, + const isc::asiolink::IOServicePtr& service, isc::dns::ConstMessagePtr query_message, const isc::asiolink::IOAddress& address, - uint16_t port, isc::util::OutputBufferPtr& buff, Callback* cb, + uint16_t port, + isc::util::OutputBufferPtr& buff, + Callback* cb, int wait = -1); - /// \brief Constructor. + /// @brief Constructor. /// /// Creates the object that will handle the upstream fetch. /// - /// \param protocol Fetch protocol, either IOFetch::TCP or IOFetch::UDP - /// \param service I/O Service object to handle the asynchronous + /// @param protocol Fetch protocol, either IOFetch::TCP or IOFetch::UDP + /// @param service I/O Service object to handle the asynchronous /// operations. - /// \param outpkt Packet to send to upstream server. Note that the + /// @param outpkt Packet to send to upstream server. Note that the /// QID (first two bytes of the packet) may be altered in the sending. - /// \param buff Output buffer into which the response (in wire format) + /// @param buff Output buffer into which the response (in wire format) /// is written (if a response is received). - /// \param cb Callback object containing the callback to be called + /// @param cb Callback object containing the callback to be called /// when we terminate. The caller is responsible for managing this /// object and deleting it if necessary. - /// \param address IP address of upstream server - /// \param port Port to which to connect on the upstream server - /// (default = 53) - /// \param wait Timeout for the fetch (in ms). The default value of + /// @param address IP address of upstream server. + /// @param port Port to which to connect on the upstream server + /// (default = 53). + /// @param wait Timeout for the fetch (in ms). The default value of /// -1 indicates no timeout. - IOFetch(Protocol protocol, const isc::asiolink::IOServicePtr& service, + IOFetch(Protocol protocol, + const isc::asiolink::IOServicePtr& service, isc::util::OutputBufferPtr& outpkt, const isc::asiolink::IOAddress& address, - uint16_t port, isc::util::OutputBufferPtr& buff, Callback* cb, + uint16_t port, + isc::util::OutputBufferPtr& buff, + Callback* cb, int wait = -1); - /// \brief Return Current Protocol + /// @brief Return Current Protocol. /// - /// \return Protocol associated with this IOFetch object. + /// @return Protocol associated with this IOFetch object. Protocol getProtocol() const; - /// \brief Coroutine entry point + /// @brief Coroutine entry point. /// /// The operator() method is the method in which the coroutine code enters /// this object when an operation has been completed. /// - /// \param ec Error code, the result of the last asynchronous I/O operation. - /// \param length Amount of data received on the last asynchronous read - void operator()(boost::system::error_code ec = boost::system::error_code(), size_t length = 0); + /// @param ec Error code, the result of the last asynchronous I/O operation. + /// @param length Amount of data received on the last asynchronous read. + void operator()(boost::system::error_code ec = boost::system::error_code(), + size_t length = 0); - /// \brief Terminate query + /// @brief Terminate query. /// /// This method can be called at any point. It terminates the current /// query with the specified reason. + /// This function stops the coroutine sequence. It is called either when the + /// query finishes or when the timer times out. Either way, it sets the + /// "stopped_" flag and cancels anything that is in progress. + /// + /// As the function may be entered multiple times as things wind down, it checks + /// if the stopped_ flag is already set. If it is, the call is a no-op. /// - /// \param reason Reason for terminating the query + /// @param reason Reason for terminating the query. void stop(Result reason = STOPPED); private: - /// \brief IOFetch Initialization Function. - /// All the parameters are same with the constructor, except - /// parameter "query_message" - /// \param query_message the message to be sent out. - void initIOFetch(isc::dns::MessagePtr& query_message, Protocol protocol, + /// @brief IOFetch Initialization Function. + /// + /// All the parameters are same with the constructor, except parameter + /// "query_message". + /// + /// @param query_message the message to be sent out. + void initIOFetch(isc::dns::MessagePtr& query_message, + Protocol protocol, const isc::asiolink::IOServicePtr& service, const isc::dns::Question& question, - const isc::asiolink::IOAddress& address, uint16_t port, - isc::util::OutputBufferPtr& buff, Callback* cb, int wait, + const isc::asiolink::IOAddress& address, + uint16_t port, + isc::util::OutputBufferPtr& buff, + Callback* cb, int wait, bool edns = true); - /// \brief Log I/O Failure + /// @brief Log I/O Failure. /// - /// Records an I/O failure to the log file + /// Records an I/O failure to the log file. /// - /// \param ec ASIO error code + /// @param ec ASIO error code. void logIOFailure(boost::system::error_code ec); - // Member variables. All data is in a structure pointed to by a shared - // pointer. The IOFetch object is copied a number of times during its - // life, and only requiring a pointer to be copied reduces overhead. + /// @brief data which is a structure pointed to by a shared pointer. The IOFetch + /// object is copied a number of times during its life, and only requiring a + /// pointer to be copied reduces overhead. boost::shared_ptr<IOFetchData> data_; ///< Private data }; -/// \brief Defines a pointer to an IOFetch. +/// @brief Defines a pointer to an IOFetch. typedef boost::shared_ptr<IOFetch> IOFetchPtr; -} // namespace asiodns -} // namespace isc +} // namespace asiodns +} // namespace isc #endif // IO_FETCH_H diff --git a/src/lib/asiodns/tests/Makefile.am b/src/lib/asiodns/tests/Makefile.am index 74517c10ea..323e453660 100644 --- a/src/lib/asiodns/tests/Makefile.am +++ b/src/lib/asiodns/tests/Makefile.am @@ -32,8 +32,7 @@ run_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD) run_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS) -# Note: the ordering matters: -Wno-... must follow -Wextra (defined in -# KEA_CXXFLAGS) +# Note: the ordering matters: -Wno-... must follow -Wextra (defined in KEA_CXXFLAGS) run_unittests_CXXFLAGS = $(AM_CXXFLAGS) if USE_GXX run_unittests_CXXFLAGS += -Wno-unused-parameter diff --git a/src/lib/asiodns/tests/io_fetch_unittest.cc b/src/lib/asiodns/tests/io_fetch_unittest.cc index 0fcb652812..4fe94d421b 100644 --- a/src/lib/asiodns/tests/io_fetch_unittest.cc +++ b/src/lib/asiodns/tests/io_fetch_unittest.cc @@ -31,12 +31,14 @@ #include <iterator> #include <vector> -using namespace boost::asio::ip; -using namespace boost::asio; using namespace isc::asiolink; using namespace isc::dns; using namespace isc::util; + +using namespace boost::asio; +using namespace boost::asio::ip; using namespace std; + namespace ph = std::placeholders; namespace isc { @@ -760,5 +762,5 @@ TEST_F(IOFetchTest, TcpSendReceive8192ShortSend) { } -} // namespace asiodns -} // namespace isc +} // namespace asiodns +} // namespace isc diff --git a/src/lib/asiodns/tests/run_unittests.cc b/src/lib/asiodns/tests/run_unittests.cc index 5d71cc9b74..cf3f2040f2 100644 --- a/src/lib/asiodns/tests/run_unittests.cc +++ b/src/lib/asiodns/tests/run_unittests.cc @@ -7,15 +7,13 @@ #include <config.h> #include <gtest/gtest.h> -#include <util/unittests/run_all.h> +#include <util/unittests/run_all.h> #include <log/logger_support.h> int -main(int argc, char* argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); // Initialize Google test - isc::log::initLogger(); // Initialize logging - +main(int argc, char* argv[]) { + ::testing::InitGoogleTest(&argc, argv); + isc::log::initLogger(); return (isc::util::unittests::run_all()); } diff --git a/src/lib/asiolink/Makefile.am b/src/lib/asiolink/Makefile.am index a72728b156..213322cb6a 100644 --- a/src/lib/asiolink/Makefile.am +++ b/src/lib/asiolink/Makefile.am @@ -56,8 +56,7 @@ if HAVE_OPENSSL libkea_asiolink_la_SOURCES += openssl_tls.cc endif -# Note: the ordering matters: -Wno-... must follow -Wextra (defined in -# KEA_CXXFLAGS) +# Note: the ordering matters: -Wno-... must follow -Wextra (defined in KEA_CXXFLAGS) libkea_asiolink_la_CXXFLAGS = $(AM_CXXFLAGS) libkea_asiolink_la_CPPFLAGS = $(AM_CPPFLAGS) libkea_asiolink_la_LIBADD = $(top_builddir)/src/lib/util/libkea-util.la diff --git a/src/lib/asiolink/dummy_io_cb.h b/src/lib/asiolink/dummy_io_cb.h index 795fad970d..8bf33449aa 100644 --- a/src/lib/asiolink/dummy_io_cb.h +++ b/src/lib/asiolink/dummy_io_cb.h @@ -59,7 +59,7 @@ public: } }; -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc #endif // DUMMY_IO_CB_H diff --git a/src/lib/asiolink/interval_timer.cc b/src/lib/asiolink/interval_timer.cc index 4b97929619..fa0d9e1b67 100644 --- a/src/lib/asiolink/interval_timer.cc +++ b/src/lib/asiolink/interval_timer.cc @@ -200,5 +200,5 @@ IntervalTimer::getInterval() const { return (impl_->getInterval()); } -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc diff --git a/src/lib/asiolink/interval_timer.h b/src/lib/asiolink/interval_timer.h index 494fddd11d..0b1c10c788 100644 --- a/src/lib/asiolink/interval_timer.h +++ b/src/lib/asiolink/interval_timer.h @@ -137,6 +137,7 @@ private: typedef boost::shared_ptr<isc::asiolink::IntervalTimer> IntervalTimerPtr; -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc + #endif // ASIOLINK_INTERVAL_TIMER_H diff --git a/src/lib/asiolink/io_address.cc b/src/lib/asiolink/io_address.cc index 0f96240342..43459bfe5a 100644 --- a/src/lib/asiolink/io_address.cc +++ b/src/lib/asiolink/io_address.cc @@ -189,5 +189,5 @@ hash_value(const IOAddress& address) { } } -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc diff --git a/src/lib/asiolink/io_address.h b/src/lib/asiolink/io_address.h index 897a27f8b4..3544ebe125 100644 --- a/src/lib/asiolink/io_address.h +++ b/src/lib/asiolink/io_address.h @@ -324,6 +324,7 @@ operator<<(std::ostream& os, const IOAddress& address); /// \return The hash of the IOAddress. size_t hash_value(const IOAddress& address); -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc + #endif // IO_ADDRESS_H diff --git a/src/lib/asiolink/io_asio_socket.h b/src/lib/asiolink/io_asio_socket.h index 29ca97f226..f44f2c9135 100644 --- a/src/lib/asiolink/io_asio_socket.h +++ b/src/lib/asiolink/io_asio_socket.h @@ -12,17 +12,16 @@ // See the description of the namespace below. #include <config.h> -#include <unistd.h> // for some network system calls - -#include <functional> -#include <string> #include <exceptions/exceptions.h> - -#include <util/buffer.h> - #include <asiolink/io_error.h> #include <asiolink/io_socket.h> +#include <util/buffer.h> + +#include <functional> +#include <string> + +#include <unistd.h> // for some network system calls // We want to use coroutine.hpp from the system's boost headers if possible. // However, very old Boost versions (provided by RHEL 7 or CentOS 7) didn't have @@ -106,7 +105,7 @@ protected: IOAsioSocket() {} public: /// The destructor. - virtual ~IOAsioSocket() {} + virtual ~IOAsioSocket() = default; //@} /// \brief Return the "native" representation of the socket. @@ -258,20 +257,20 @@ public: /// really the TCP count field and is set to that value when enough /// of a TCP message is received. It should be initialized to -1 /// before the first read is executed. - /// \param outbuff Output buffer. Data in the staging buffer may be copied + /// \param buff Output buffer. Data in the staging buffer may be copied /// to this output buffer in the call. /// /// \return true if the receive is complete, false if another receive is - /// needed. This is always true for UDP, but for TCP involves - /// checking the amount of data received so far against the amount - /// expected (as indicated by the two-byte count field). If this - /// method returns false, another read should be queued and data - /// should be read into the staging buffer at offset given by the - /// "offset" parameter. + /// needed. This is always true for UDP, but for TCP involves + /// checking the amount of data received so far against the amount + /// expected (as indicated by the two-byte count field). If this + /// method returns false, another read should be queued and data + /// should be read into the staging buffer at offset given by the + /// "offset" parameter. virtual bool processReceivedData(const void* staging, size_t length, - size_t& cumulative, size_t& offset, - size_t& expected, - isc::util::OutputBufferPtr& outbuff) = 0; + size_t& cumulative, + size_t& offset, size_t& expected, + isc::util::OutputBufferPtr& buff) = 0; /// \brief Cancel I/O On AsioSocket virtual void cancel() = 0; @@ -375,7 +374,7 @@ private: const int protocol_; }; -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc #endif // IO_ASIO_SOCKET_H diff --git a/src/lib/asiolink/io_endpoint.cc b/src/lib/asiolink/io_endpoint.cc index d236aa809f..975372fe27 100644 --- a/src/lib/asiolink/io_endpoint.cc +++ b/src/lib/asiolink/io_endpoint.cc @@ -64,5 +64,6 @@ operator<<(ostream& os, const IOEndpoint& endpoint) { os << ":" << boost::lexical_cast<string>(endpoint.getPort()); return (os); } -} // namespace asiolink -} // namespace isc + +} // namespace asiolink +} // namespace isc diff --git a/src/lib/asiolink/io_endpoint.h b/src/lib/asiolink/io_endpoint.h index 8421a305ee..0f5ddf701d 100644 --- a/src/lib/asiolink/io_endpoint.h +++ b/src/lib/asiolink/io_endpoint.h @@ -174,10 +174,7 @@ public: /// \return A reference to the same \c std::ostream object referenced by /// parameter \c os after the insertion operation. std::ostream& operator<<(std::ostream& os, const IOEndpoint& endpoint); -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc #endif // IO_ENDPOINT_H -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/asiolink/io_error.h b/src/lib/asiolink/io_error.h index 692070c7c4..125cdd6b80 100644 --- a/src/lib/asiolink/io_error.h +++ b/src/lib/asiolink/io_error.h @@ -22,8 +22,7 @@ public: isc::Exception(file, line, what) {} }; - -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc #endif // IO_ERROR_H diff --git a/src/lib/asiolink/io_service.cc b/src/lib/asiolink/io_service.cc index 6fc65f49de..3cc6012fe2 100644 --- a/src/lib/asiolink/io_service.cc +++ b/src/lib/asiolink/io_service.cc @@ -175,5 +175,5 @@ IOService::post(const std::function<void ()>& callback) { return (io_impl_->post(callback)); } -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc diff --git a/src/lib/asiolink/io_service.h b/src/lib/asiolink/io_service.h index 100099f7f1..7da1f9e108 100644 --- a/src/lib/asiolink/io_service.h +++ b/src/lib/asiolink/io_service.h @@ -121,6 +121,7 @@ private: /// @brief Defines a smart pointer to an IOService instance. typedef boost::shared_ptr<IOService> IOServicePtr; -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc + #endif // ASIOLINK_IO_SERVICE_H diff --git a/src/lib/asiolink/io_socket.cc b/src/lib/asiolink/io_socket.cc index f7792a9fb2..8d399fbc23 100644 --- a/src/lib/asiolink/io_socket.cc +++ b/src/lib/asiolink/io_socket.cc @@ -53,5 +53,5 @@ IOSocket::getDummyTCPSocket() { return (socket); } -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc diff --git a/src/lib/asiolink/io_socket.h b/src/lib/asiolink/io_socket.h index 9c9cee16fd..cb07c886ea 100644 --- a/src/lib/asiolink/io_socket.h +++ b/src/lib/asiolink/io_socket.h @@ -122,7 +122,7 @@ public: static IOSocket& getDummyTCPSocket(); }; -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc #endif // IO_SOCKET_H diff --git a/src/lib/asiolink/tcp_endpoint.h b/src/lib/asiolink/tcp_endpoint.h index 7cbb73b2ab..453e629673 100644 --- a/src/lib/asiolink/tcp_endpoint.h +++ b/src/lib/asiolink/tcp_endpoint.h @@ -106,10 +106,6 @@ private: boost::asio::ip::tcp::endpoint& asio_endpoint_; }; -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc #endif // TCP_ENDPOINT_H - -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/asiolink/tcp_socket.h b/src/lib/asiolink/tcp_socket.h index 346d249897..e56abe412d 100644 --- a/src/lib/asiolink/tcp_socket.h +++ b/src/lib/asiolink/tcp_socket.h @@ -5,30 +5,28 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef TCP_SOCKET_H -#define TCP_SOCKET_H 1 +#define TCP_SOCKET_H #ifndef BOOST_ASIO_HPP #error "asio.hpp must be included before including this, see asiolink.h as to why" #endif -#include <netinet/in.h> -#include <sys/socket.h> -#include <unistd.h> // for some IPC/network system calls +#include <asiolink/io_asio_socket.h> +#include <asiolink/io_endpoint.h> +#include <asiolink/io_service.h> +#include <asiolink/tcp_endpoint.h> +#include <exceptions/isc_assert.h> +#include <util/buffer.h> +#include <util/io.h> #include <algorithm> #include <cstddef> #include <boost/numeric/conversion/cast.hpp> -#include <util/buffer.h> -#include <util/io.h> - -#include <asiolink/io_asio_socket.h> -#include <asiolink/io_endpoint.h> -#include <asiolink/io_service.h> -#include <asiolink/tcp_endpoint.h> - -#include <exceptions/isc_assert.h> +#include <netinet/in.h> +#include <sys/socket.h> +#include <unistd.h> // for some IPC/network system calls namespace isc { namespace asiolink { @@ -199,14 +197,14 @@ public: /// processed. /// \param offset Unused. /// \param expected unused. - /// \param outbuff Output buffer. Data in the staging buffer is be copied + /// \param buff Output buffer. Data in the staging buffer is be copied /// to this output buffer in the call. /// /// \return Always true virtual bool processReceivedData(const void* staging, size_t length, size_t& cumulative, size_t& offset, size_t& expected, - isc::util::OutputBufferPtr& outbuff); + isc::util::OutputBufferPtr& buff); /// \brief Cancel I/O On Socket virtual void cancel(); @@ -495,7 +493,7 @@ TCPSocket<C>::close() { } } -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc #endif // TCP_SOCKET_H diff --git a/src/lib/asiolink/tests/Makefile.am b/src/lib/asiolink/tests/Makefile.am index cad0d6d160..eac8ea73bd 100644 --- a/src/lib/asiolink/tests/Makefile.am +++ b/src/lib/asiolink/tests/Makefile.am @@ -64,8 +64,7 @@ run_unittests_LDADD += $(GTEST_LDADD) run_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS) -# Note: the ordering matters: -Wno-... must follow -Wextra (defined in -# KEA_CXXFLAGS) +# Note: the ordering matters: -Wno-... must follow -Wextra (defined in KEA_CXXFLAGS) run_unittests_CXXFLAGS = $(AM_CXXFLAGS) if USE_GXX run_unittests_CXXFLAGS += -Wno-unused-parameter -Wno-unused-private-field diff --git a/src/lib/asiolink/tests/interval_timer_unittest.cc b/src/lib/asiolink/tests/interval_timer_unittest.cc index 1376e63283..214dd4da04 100644 --- a/src/lib/asiolink/tests/interval_timer_unittest.cc +++ b/src/lib/asiolink/tests/interval_timer_unittest.cc @@ -11,14 +11,14 @@ #include <boost/date_time/posix_time/posix_time.hpp> #include <gtest/gtest.h> +using namespace isc::asiolink; + namespace { // TODO: Consider this margin const boost::posix_time::time_duration TIMER_MARGIN_MSEC = boost::posix_time::milliseconds(50); } -using namespace isc::asiolink; - // This fixture is for testing IntervalTimer. Some callback functors are // registered as callback function of the timer to test if they are called // or not. diff --git a/src/lib/asiolink/tests/run_unittests.cc b/src/lib/asiolink/tests/run_unittests.cc index 566c7c9faa..33e10dbc39 100644 --- a/src/lib/asiolink/tests/run_unittests.cc +++ b/src/lib/asiolink/tests/run_unittests.cc @@ -7,13 +7,13 @@ #include <config.h> #include <gtest/gtest.h> + #include <util/unittests/run_all.h> -#include <log/logger_manager.h> +#include <log/logger_support.h> int -main(int argc, char* argv[]) -{ - ::testing::InitGoogleTest(&argc, argv); // Initialize Google test - isc::log::LoggerManager::init("unittest"); // Set a root logger name +main(int argc, char* argv[]) { + ::testing::InitGoogleTest(&argc, argv); + isc::log::initLogger(); return (isc::util::unittests::run_all()); } diff --git a/src/lib/asiolink/tests/tcp_socket_unittest.cc b/src/lib/asiolink/tests/tcp_socket_unittest.cc index 82c74ca66e..f97a8f6665 100644 --- a/src/lib/asiolink/tests/tcp_socket_unittest.cc +++ b/src/lib/asiolink/tests/tcp_socket_unittest.cc @@ -32,11 +32,12 @@ #include <string> #include <vector> -using namespace boost::asio; -using namespace boost::asio::ip; -using namespace isc::util; using namespace isc::asiolink; +using namespace isc::util; + using namespace std; +using namespace boost::asio; +using namespace boost::asio::ip; namespace { diff --git a/src/lib/asiolink/tests/udp_socket_unittest.cc b/src/lib/asiolink/tests/udp_socket_unittest.cc index a3ea985ba3..c607fce92a 100644 --- a/src/lib/asiolink/tests/udp_socket_unittest.cc +++ b/src/lib/asiolink/tests/udp_socket_unittest.cc @@ -32,9 +32,10 @@ #include <vector> -using namespace boost::asio; -using namespace isc::util; using namespace isc::asiolink; +using namespace isc::util; + +using namespace boost::asio; using namespace std; namespace { diff --git a/src/lib/asiolink/udp_endpoint.h b/src/lib/asiolink/udp_endpoint.h index 894032b221..f2e040ee03 100644 --- a/src/lib/asiolink/udp_endpoint.h +++ b/src/lib/asiolink/udp_endpoint.h @@ -106,10 +106,6 @@ private: boost::asio::ip::udp::endpoint& asio_endpoint_; }; -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc #endif // UDP_ENDPOINT_H - -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/asiolink/udp_socket.h b/src/lib/asiolink/udp_socket.h index 9ed3c197ee..380d344e36 100644 --- a/src/lib/asiolink/udp_socket.h +++ b/src/lib/asiolink/udp_socket.h @@ -130,14 +130,14 @@ public: /// processed. /// \param offset Unused. /// \param expected unused. - /// \param outbuff Output buffer. Data in the staging buffer is be copied + /// \param buff Output buffer. Data in the staging buffer is be copied /// to this output buffer in the call. /// /// \return Always true virtual bool processReceivedData(const void* staging, size_t length, size_t& cumulative, size_t& offset, size_t& expected, - isc::util::OutputBufferPtr& outbuff); + isc::util::OutputBufferPtr& buff); /// \brief Cancel I/O On Socket virtual void cancel(); @@ -315,7 +315,7 @@ UDPSocket<C>::close() { } } -} // namespace asiolink -} // namespace isc +} // namespace asiolink +} // namespace isc #endif // UDP_SOCKET_H diff --git a/src/lib/cc/data.h b/src/lib/cc/data.h index e954ea9009..1b1e8eb3cf 100644 --- a/src/lib/cc/data.h +++ b/src/lib/cc/data.h @@ -1069,7 +1069,3 @@ bool operator<(const Element& a, const Element& b); } // namespace isc #endif // ISC_DATA_H - -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/cc/tests/command_interpreter_unittests.cc b/src/lib/cc/tests/command_interpreter_unittests.cc index 8738b925c5..c15bc5627b 100644 --- a/src/lib/cc/tests/command_interpreter_unittests.cc +++ b/src/lib/cc/tests/command_interpreter_unittests.cc @@ -9,7 +9,6 @@ #include <gtest/gtest.h> #include <cc/command_interpreter.h> -#include <config/tests/data_def_unittests_config.h> #include <log/logger_name.h> #include <boost/scoped_ptr.hpp> diff --git a/src/lib/cc/tests/run_unittests.cc b/src/lib/cc/tests/run_unittests.cc index 40c051fba2..cf3f2040f2 100644 --- a/src/lib/cc/tests/run_unittests.cc +++ b/src/lib/cc/tests/run_unittests.cc @@ -7,14 +7,13 @@ #include <config.h> #include <gtest/gtest.h> + #include <util/unittests/run_all.h> #include <log/logger_support.h> int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); - isc::log::initLogger(); - return (isc::util::unittests::run_all()); } diff --git a/src/lib/config/tests/.gitignore b/src/lib/config/tests/.gitignore index abdfa8a5a6..d6d1ec87a1 100644 --- a/src/lib/config/tests/.gitignore +++ b/src/lib/config/tests/.gitignore @@ -1,2 +1 @@ -/data_def_unittests_config.h /run_unittests diff --git a/src/lib/config/tests/Makefile.am b/src/lib/config/tests/Makefile.am index 546c35748a..547d0ef132 100644 --- a/src/lib/config/tests/Makefile.am +++ b/src/lib/config/tests/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = testdata . +SUBDIRS = . AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib AM_CPPFLAGS += $(BOOST_INCLUDES) $(CRYPTO_CFLAGS) $(CRYPTO_INCLUDES) @@ -12,7 +12,6 @@ AM_LDFLAGS = -static endif CLEANFILES = *.gcno *.gcda -DISTCLEANFILES = data_def_unittests_config.h TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND) diff --git a/src/lib/config/tests/data_def_unittests_config.h.in b/src/lib/config/tests/data_def_unittests_config.h.in deleted file mode 100644 index 0837f846d8..0000000000 --- a/src/lib/config/tests/data_def_unittests_config.h.in +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (C) 2009-2015 Internet Systems Consortium, Inc. ("ISC") -// -// 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/. - -#define TEST_DATA_PATH "@abs_srcdir@/testdata" diff --git a/src/lib/config/tests/run_unittests.cc b/src/lib/config/tests/run_unittests.cc index fc385f9f5e..cf3f2040f2 100644 --- a/src/lib/config/tests/run_unittests.cc +++ b/src/lib/config/tests/run_unittests.cc @@ -7,6 +7,7 @@ #include <config.h> #include <gtest/gtest.h> + #include <util/unittests/run_all.h> #include <log/logger_support.h> diff --git a/src/lib/config/tests/testdata/Makefile.am b/src/lib/config/tests/testdata/Makefile.am deleted file mode 100644 index 641a142632..0000000000 --- a/src/lib/config/tests/testdata/Makefile.am +++ /dev/null @@ -1,59 +0,0 @@ -EXTRA_DIST = data22_1.data -EXTRA_DIST += data22_2.data -EXTRA_DIST += data22_3.data -EXTRA_DIST += data22_4.data -EXTRA_DIST += data22_5.data -EXTRA_DIST += data22_6.data -EXTRA_DIST += data22_7.data -EXTRA_DIST += data22_8.data -EXTRA_DIST += data22_9.data -EXTRA_DIST += data22_10.data -EXTRA_DIST += data32_1.data -EXTRA_DIST += data32_2.data -EXTRA_DIST += data32_3.data -EXTRA_DIST += data33_1.data -EXTRA_DIST += data33_2.data -EXTRA_DIST += data41_1.data -EXTRA_DIST += data41_2.data -EXTRA_DIST += spec1.spec -EXTRA_DIST += spec2.spec -EXTRA_DIST += spec3.spec -EXTRA_DIST += spec4.spec -EXTRA_DIST += spec5.spec -EXTRA_DIST += spec6.spec -EXTRA_DIST += spec7.spec -EXTRA_DIST += spec8.spec -EXTRA_DIST += spec9.spec -EXTRA_DIST += spec10.spec -EXTRA_DIST += spec11.spec -EXTRA_DIST += spec12.spec -EXTRA_DIST += spec13.spec -EXTRA_DIST += spec14.spec -EXTRA_DIST += spec15.spec -EXTRA_DIST += spec16.spec -EXTRA_DIST += spec17.spec -EXTRA_DIST += spec18.spec -EXTRA_DIST += spec19.spec -EXTRA_DIST += spec20.spec -EXTRA_DIST += spec21.spec -EXTRA_DIST += spec22.spec -EXTRA_DIST += spec23.spec -EXTRA_DIST += spec24.spec -EXTRA_DIST += spec25.spec -EXTRA_DIST += spec26.spec -EXTRA_DIST += spec27.spec -EXTRA_DIST += spec28.spec -EXTRA_DIST += spec29.spec -EXTRA_DIST += spec30.spec -EXTRA_DIST += spec31.spec -EXTRA_DIST += spec32.spec -EXTRA_DIST += spec33.spec -EXTRA_DIST += spec34.spec -EXTRA_DIST += spec35.spec -EXTRA_DIST += spec36.spec -EXTRA_DIST += spec37.spec -EXTRA_DIST += spec38.spec -EXTRA_DIST += spec39.spec -EXTRA_DIST += spec40.spec -EXTRA_DIST += spec41.spec -EXTRA_DIST += spec42.spec diff --git a/src/lib/config/tests/testdata/data22_1.data b/src/lib/config/tests/testdata/data22_1.data deleted file mode 100644 index 18732c7af4..0000000000 --- a/src/lib/config/tests/testdata/data22_1.data +++ /dev/null @@ -1,9 +0,0 @@ -{ - "value1": 1, - "value2": 2.3, - "value3": true, - "value4": "foo", - "value5": [ 1, 2, 3 ], - "value6": { "v61": "bar", "v62": true }, - "value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } } -} diff --git a/src/lib/config/tests/testdata/data22_10.data b/src/lib/config/tests/testdata/data22_10.data deleted file mode 100644 index fed4001143..0000000000 --- a/src/lib/config/tests/testdata/data22_10.data +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": 123, - "value1": 1, - "value2": 2.3, - "value3": true, - "value4": "foo", - "value5": [ 1, 2, 3 ], - "value6": { "v61": "bar", "v62": true }, - "value8": [ { "a": "d" }, { "a": "e" } ], - "value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } } -} diff --git a/src/lib/config/tests/testdata/data22_2.data b/src/lib/config/tests/testdata/data22_2.data deleted file mode 100644 index c82070673e..0000000000 --- a/src/lib/config/tests/testdata/data22_2.data +++ /dev/null @@ -1,8 +0,0 @@ -{ - "value1": "asdf", - "value2": 2.3, - "value3": true, - "value4": "foo", - "value5": [ 1, 2, 3 ], - "value6": { "v61": "bar", "v62": true } -} diff --git a/src/lib/config/tests/testdata/data22_3.data b/src/lib/config/tests/testdata/data22_3.data deleted file mode 100644 index 7d57dfee2e..0000000000 --- a/src/lib/config/tests/testdata/data22_3.data +++ /dev/null @@ -1,8 +0,0 @@ -{ - "value1": 1, - "value2": false, - "value3": true, - "value4": "foo", - "value5": [ 1, 2, 3 ], - "value6": { "v61": "bar", "v62": true } -} diff --git a/src/lib/config/tests/testdata/data22_4.data b/src/lib/config/tests/testdata/data22_4.data deleted file mode 100644 index 52862d59d7..0000000000 --- a/src/lib/config/tests/testdata/data22_4.data +++ /dev/null @@ -1,8 +0,0 @@ -{ - "value1": 1, - "value2": 2.3, - "value3": true, - "value4": "foo", - "value5": [ 1, 2, "a" ], - "value6": { "v61": "bar", "v62": true } -} diff --git a/src/lib/config/tests/testdata/data22_5.data b/src/lib/config/tests/testdata/data22_5.data deleted file mode 100644 index 43937d6ae8..0000000000 --- a/src/lib/config/tests/testdata/data22_5.data +++ /dev/null @@ -1,8 +0,0 @@ -{ - "value1": 1, - "value2": 2.3, - "value3": true, - "value4": "foo", - "value5": [ 1, 2, 3 ], - "value6": { "v61": "bar", "v62": "Break" } -} diff --git a/src/lib/config/tests/testdata/data22_6.data b/src/lib/config/tests/testdata/data22_6.data deleted file mode 100644 index 7b53490e5a..0000000000 --- a/src/lib/config/tests/testdata/data22_6.data +++ /dev/null @@ -1,10 +0,0 @@ -{ - "value1": 1, - "value2": 2.3, - "value3": true, - "value4": "foo", - "value5": [ 1, 2, 3 ], - "value6": { "v61": "bar", "v62": true }, - "value7": [ 1, 2.2, "str", true ], - "value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } } -} diff --git a/src/lib/config/tests/testdata/data22_7.data b/src/lib/config/tests/testdata/data22_7.data deleted file mode 100644 index 98f537b074..0000000000 --- a/src/lib/config/tests/testdata/data22_7.data +++ /dev/null @@ -1,10 +0,0 @@ -{ - "value1": 1, - "value2": 2.3, - "value3": true, - "value4": "foo", - "value5": [ 1, 2, 3 ], - "value6": { "v61": "bar", "v62": true }, - "value8": [ { "a": "d" }, { "a": "e" } ], - "value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } } -} diff --git a/src/lib/config/tests/testdata/data22_8.data b/src/lib/config/tests/testdata/data22_8.data deleted file mode 100644 index 8bc0aa9024..0000000000 --- a/src/lib/config/tests/testdata/data22_8.data +++ /dev/null @@ -1,10 +0,0 @@ -{ - "value1": 1, - "value2": 2.3, - "value3": true, - "value4": "foo", - "value5": [ 1, 2, 3 ], - "value6": { "v61": "bar", "v62": true }, - "value8": [ { "a": "d" }, { "a": 1 } ], - "value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } } -} diff --git a/src/lib/config/tests/testdata/data22_9.data b/src/lib/config/tests/testdata/data22_9.data deleted file mode 100644 index f115194bf4..0000000000 --- a/src/lib/config/tests/testdata/data22_9.data +++ /dev/null @@ -1,11 +0,0 @@ -{ - "value1": 1, - "value2": 2.3, - "value3": true, - "value4": "foo", - "value5": [ 1, 2, 3 ], - "value6": { "v61": "bar", "v62": true }, - "value8": [ { "a": "d" }, { "a": "e" } ], - "value9": { "v91": "hi", "v92": { "v92a": "Hi", "v92b": 3 } }, - "value_does_not_exist": 1 -} diff --git a/src/lib/config/tests/testdata/data32_1.data b/src/lib/config/tests/testdata/data32_1.data deleted file mode 100644 index 5695b523a9..0000000000 --- a/src/lib/config/tests/testdata/data32_1.data +++ /dev/null @@ -1,3 +0,0 @@ -{ - "named_set_item": { "foo": 1, "bar": 2 } -} diff --git a/src/lib/config/tests/testdata/data32_2.data b/src/lib/config/tests/testdata/data32_2.data deleted file mode 100644 index d5b9765ffb..0000000000 --- a/src/lib/config/tests/testdata/data32_2.data +++ /dev/null @@ -1,3 +0,0 @@ -{ - "named_set_item": { "foo": "wrongtype", "bar": 2 } -} diff --git a/src/lib/config/tests/testdata/data32_3.data b/src/lib/config/tests/testdata/data32_3.data deleted file mode 100644 index 85f32feed6..0000000000 --- a/src/lib/config/tests/testdata/data32_3.data +++ /dev/null @@ -1,3 +0,0 @@ -{ - "named_set_item": [] -} diff --git a/src/lib/config/tests/testdata/data33_1.data b/src/lib/config/tests/testdata/data33_1.data deleted file mode 100644 index 429852c974..0000000000 --- a/src/lib/config/tests/testdata/data33_1.data +++ /dev/null @@ -1,7 +0,0 @@ -{ - "dummy_str": "Dummy String", - "dummy_int": 118, - "dummy_datetime": "2011-05-27T19:42:57Z", - "dummy_date": "2011-05-27", - "dummy_time": "19:42:57" -} diff --git a/src/lib/config/tests/testdata/data33_2.data b/src/lib/config/tests/testdata/data33_2.data deleted file mode 100644 index eb0615c1c9..0000000000 --- a/src/lib/config/tests/testdata/data33_2.data +++ /dev/null @@ -1,7 +0,0 @@ -{ - "dummy_str": "Dummy String", - "dummy_int": 118, - "dummy_datetime": "xxxx", - "dummy_date": "xxxx", - "dummy_time": "xxxx" -} diff --git a/src/lib/config/tests/testdata/data41_1.data b/src/lib/config/tests/testdata/data41_1.data deleted file mode 100644 index d309854eaa..0000000000 --- a/src/lib/config/tests/testdata/data41_1.data +++ /dev/null @@ -1,12 +0,0 @@ -{ - "zones": { - "example.org": { - "queries.tcp": 100, - "queries.udp": 200 - }, - "example.net": { - "queries.tcp": 300, - "queries.udp": 400 - } - } -} diff --git a/src/lib/config/tests/testdata/data41_2.data b/src/lib/config/tests/testdata/data41_2.data deleted file mode 100644 index c64e931dec..0000000000 --- a/src/lib/config/tests/testdata/data41_2.data +++ /dev/null @@ -1,16 +0,0 @@ -{ - "zones": [ - { - "example.org": { - "queries.tcp": 100, - "queries.udp": 200 - } - }, - { - "example.net": { - "queries.tcp": 300, - "queries.udp": 400 - } - } - ] -} diff --git a/src/lib/config/tests/testdata/spec1.spec b/src/lib/config/tests/testdata/spec1.spec deleted file mode 100644 index 05a3794cdf..0000000000 --- a/src/lib/config/tests/testdata/spec1.spec +++ /dev/null @@ -1,6 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec1" - } -} - diff --git a/src/lib/config/tests/testdata/spec10.spec b/src/lib/config/tests/testdata/spec10.spec deleted file mode 100644 index d2bac77fb7..0000000000 --- a/src/lib/config/tests/testdata/spec10.spec +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "config_data": [ - { "item_name": "item1", - "item_type": "real", - "item_optional": false, - "item_default": 1 - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec11.spec b/src/lib/config/tests/testdata/spec11.spec deleted file mode 100644 index 61cb2c3841..0000000000 --- a/src/lib/config/tests/testdata/spec11.spec +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "config_data": [ - { "item_name": "item1", - "item_type": "boolean", - "item_optional": false, - "item_default": 1 - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec12.spec b/src/lib/config/tests/testdata/spec12.spec deleted file mode 100644 index 9083a66beb..0000000000 --- a/src/lib/config/tests/testdata/spec12.spec +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "config_data": [ - { "item_name": "item1", - "item_type": "string", - "item_optional": false, - "item_default": 1 - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec13.spec b/src/lib/config/tests/testdata/spec13.spec deleted file mode 100644 index c13be46706..0000000000 --- a/src/lib/config/tests/testdata/spec13.spec +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "config_data": [ - { "item_name": "item1", - "item_type": "list", - "item_optional": false, - "item_default": 1 - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec14.spec b/src/lib/config/tests/testdata/spec14.spec deleted file mode 100644 index 3ce1852937..0000000000 --- a/src/lib/config/tests/testdata/spec14.spec +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "config_data": [ - { "item_name": "item1", - "item_type": "map", - "item_optional": false, - "item_default": 1 - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec15.spec b/src/lib/config/tests/testdata/spec15.spec deleted file mode 100644 index a9ef085805..0000000000 --- a/src/lib/config/tests/testdata/spec15.spec +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "config_data": [ - { "item_name": "item1", - "item_type": "badname", - "item_optional": false, - "item_default": 1 - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec16.spec b/src/lib/config/tests/testdata/spec16.spec deleted file mode 100644 index e78bc2edc0..0000000000 --- a/src/lib/config/tests/testdata/spec16.spec +++ /dev/null @@ -1,7 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "config_data": 1 - } -} - diff --git a/src/lib/config/tests/testdata/spec17.spec b/src/lib/config/tests/testdata/spec17.spec deleted file mode 100644 index 74a1c257df..0000000000 --- a/src/lib/config/tests/testdata/spec17.spec +++ /dev/null @@ -1,17 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "commands": [ - { - "command_description": "Print the given message to stdout", - "command_args": [ { - "item_name": "message", - "item_type": "string", - "item_optional": false, - "item_default": "" - } ] - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec18.spec b/src/lib/config/tests/testdata/spec18.spec deleted file mode 100644 index e3854aa927..0000000000 --- a/src/lib/config/tests/testdata/spec18.spec +++ /dev/null @@ -1,12 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "commands": [ - { - "command_name": "print_message", - "command_description": "Print the given message to stdout" - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec19.spec b/src/lib/config/tests/testdata/spec19.spec deleted file mode 100644 index 1b3c703656..0000000000 --- a/src/lib/config/tests/testdata/spec19.spec +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "commands": [ - { - "command_name": "print_message", - "command_description": "Print the given message to stdout", - "command_args": 1 - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec2.spec b/src/lib/config/tests/testdata/spec2.spec deleted file mode 100644 index 482c2069bc..0000000000 --- a/src/lib/config/tests/testdata/spec2.spec +++ /dev/null @@ -1,83 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "config_data": [ - { "item_name": "item1", - "item_type": "integer", - "item_optional": false, - "item_default": 1 - }, - { "item_name": "item2", - "item_type": "real", - "item_optional": false, - "item_default": 1.1 - }, - { "item_name": "item3", - "item_type": "boolean", - "item_optional": false, - "item_default": true - }, - { "item_name": "item4", - "item_type": "string", - "item_optional": false, - "item_default": "test" - }, - { "item_name": "item5", - "item_type": "list", - "item_optional": false, - "item_default": [ "a", "b" ], - "list_item_spec": { - "item_name": "list_element", - "item_type": "string", - "item_optional": false, - "item_default": "" - } - }, - { "item_name": "item6", - "item_type": "map", - "item_optional": false, - "item_default": {}, - "map_item_spec": [ - { "item_name": "value1", - "item_type": "string", - "item_optional": true, - "item_default": "default" - }, - { "item_name": "value2", - "item_type": "integer", - "item_optional": true - } - ] - } - ], - "commands": [ - { - "command_name": "print_message", - "command_description": "Print the given message to stdout", - "command_args": [ { - "item_name": "message", - "item_type": "string", - "item_optional": false, - "item_default": "" - } ] - }, - { - "command_name": "shutdown", - "command_description": "Shut down Kea", - "command_args": [] - } - ], - "statistics": [ - { - "item_name": "dummy_time", - "item_type": "string", - "item_optional": false, - "item_default": "1970-01-01T00:00:00Z", - "item_title": "Dummy Time", - "item_description": "A dummy date time", - "item_format": "date-time" - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec20.spec b/src/lib/config/tests/testdata/spec20.spec deleted file mode 100644 index c9d32a7d94..0000000000 --- a/src/lib/config/tests/testdata/spec20.spec +++ /dev/null @@ -1,18 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "commands": [ - { - "command_name": "print_message", - "command_description": "Print the given message to stdout", - "command_args": [ { - "item_name": "message", - "item_type": "somethingbad", - "item_optional": false, - "item_default": "" - } ] - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec21.spec b/src/lib/config/tests/testdata/spec21.spec deleted file mode 100644 index 0af430252d..0000000000 --- a/src/lib/config/tests/testdata/spec21.spec +++ /dev/null @@ -1,7 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "commands": 1 - } -} - diff --git a/src/lib/config/tests/testdata/spec22.spec b/src/lib/config/tests/testdata/spec22.spec deleted file mode 100644 index 687db08bee..0000000000 --- a/src/lib/config/tests/testdata/spec22.spec +++ /dev/null @@ -1,114 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec22", - "config_data": [ - { "item_name": "value1", - "item_type": "integer", - "item_optional": false, - "item_default": 9 - }, - { "item_name": "value2", - "item_type": "real", - "item_optional": false, - "item_default": 9.9 - }, - { "item_name": "value3", - "item_type": "boolean", - "item_optional": false, - "item_default": false - }, - { "item_name": "value4", - "item_type": "string", - "item_optional": false, - "item_default": "default_string" - }, - { "item_name": "value5", - "item_type": "list", - "item_optional": false, - "item_default": [ "a", "b" ], - "list_item_spec": { - "item_name": "list_element", - "item_type": "integer", - "item_optional": false, - "item_default": 8 - } - }, - { "item_name": "value6", - "item_type": "map", - "item_optional": false, - "item_default": {}, - "map_item_spec": [ - { "item_name": "v61", - "item_type": "string", - "item_optional": false, - "item_default": "def" - }, - { "item_name": "v62", - "item_type": "boolean", - "item_optional": false, - "item_default": false - } - ] - }, - { "item_name": "value7", - "item_type": "list", - "item_optional": true, - "item_default": [ ], - "list_item_spec": { - "item_name": "list_element", - "item_type": "any", - "item_optional": true - } - }, - { "item_name": "value8", - "item_type": "list", - "item_optional": true, - "item_default": [ ], - "list_item_spec": { - "item_name": "list_element", - "item_type": "map", - "item_optional": true, - "item_default": { "a": "b" }, - "map_item_spec": [ - { "item_name": "a", - "item_type": "string", - "item_optional": true, - "item_default": "empty" - } - ] - } - }, - { "item_name": "value9", - "item_type": "map", - "item_optional": false, - "item_default": { "v91": "def", "v92": {} }, - "map_item_spec": [ - { "item_name": "v91", - "item_type": "string", - "item_optional": false, - "item_default": "def" - }, - { "item_name": "v92", - "item_type": "map", - "item_optional": false, - "item_default": {}, - "map_item_spec": [ - { "item_name": "v92a", - "item_type": "string", - "item_optional": false, - "item_default": "Hello" - } , - { - "item_name": "v92b", - "item_type": "integer", - "item_optional": false, - "item_default": 56176 - } - ] - } - ] - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec23.spec b/src/lib/config/tests/testdata/spec23.spec deleted file mode 100644 index 6791b6c046..0000000000 --- a/src/lib/config/tests/testdata/spec23.spec +++ /dev/null @@ -1,18 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "commands": [ - { - "command_name": "print_message", - "command_description": "Print the given message to stdout", - "command_args": [ { - "item_name": "message", - "item_type": "string", - "item_optional": false, - "item_default": "" - } ] - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec24.spec b/src/lib/config/tests/testdata/spec24.spec deleted file mode 100644 index bcb50bacf9..0000000000 --- a/src/lib/config/tests/testdata/spec24.spec +++ /dev/null @@ -1,18 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec24", - "config_data": [ - { "item_name": "item", - "item_type": "list", - "item_optional": true, - "list_item_spec": { - "item_name": "list_element", - "item_type": "string", - "item_optional": false, - "item_default": "" - } - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec25.spec b/src/lib/config/tests/testdata/spec25.spec deleted file mode 100644 index 6a174d5356..0000000000 --- a/src/lib/config/tests/testdata/spec25.spec +++ /dev/null @@ -1,7 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec25", - "module_description": "Just an empty module" - } -} - diff --git a/src/lib/config/tests/testdata/spec26.spec b/src/lib/config/tests/testdata/spec26.spec deleted file mode 100644 index 27f3c5b4de..0000000000 --- a/src/lib/config/tests/testdata/spec26.spec +++ /dev/null @@ -1,6 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec26", - "module_description": 1 - } -} diff --git a/src/lib/config/tests/testdata/spec27.spec b/src/lib/config/tests/testdata/spec27.spec deleted file mode 100644 index 2c73021472..0000000000 --- a/src/lib/config/tests/testdata/spec27.spec +++ /dev/null @@ -1,121 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec27", - "commands": [ - { - "command_name": "cmd1", - "command_description": "command_for_unittest", - "command_args": [ - { - "item_name": "value1", - "item_type": "integer", - "item_optional": false, - "item_default": 9 - }, - { "item_name": "value2", - "item_type": "real", - "item_optional": false, - "item_default": 9.9 - }, - { "item_name": "value3", - "item_type": "boolean", - "item_optional": false, - "item_default": false - }, - { "item_name": "value4", - "item_type": "string", - "item_optional": false, - "item_default": "default_string" - }, - { "item_name": "value5", - "item_type": "list", - "item_optional": false, - "item_default": [ "a", "b" ], - "list_item_spec": { - "item_name": "list_element", - "item_type": "integer", - "item_optional": false, - "item_default": 8 - } - }, - { "item_name": "value6", - "item_type": "map", - "item_optional": false, - "item_default": {}, - "map_item_spec": [ - { "item_name": "v61", - "item_type": "string", - "item_optional": false, - "item_default": "def" - }, - { "item_name": "v62", - "item_type": "boolean", - "item_optional": false, - "item_default": false - } - ] - }, - { "item_name": "value7", - "item_type": "list", - "item_optional": true, - "item_default": [ ], - "list_item_spec": { - "item_name": "list_element", - "item_type": "any", - "item_optional": true - } - }, - { "item_name": "value8", - "item_type": "list", - "item_optional": true, - "item_default": [ ], - "list_item_spec": { - "item_name": "list_element", - "item_type": "map", - "item_optional": true, - "item_default": { "a": "b" }, - "map_item_spec": [ - { "item_name": "a", - "item_type": "string", - "item_optional": true, - "item_default": "empty" - } - ] - } - }, - { "item_name": "value9", - "item_type": "map", - "item_optional": false, - "item_default": {}, - "map_item_spec": [ - { "item_name": "v91", - "item_type": "string", - "item_optional": false, - "item_default": "def" - }, - { "item_name": "v92", - "item_type": "map", - "item_optional": false, - "item_default": {}, - "map_item_spec": [ - { "item_name": "v92a", - "item_type": "string", - "item_optional": false, - "item_default": "Hello" - } , - { - "item_name": "v92b", - "item_type": "integer", - "item_optional": false, - "item_default": 56176 - } - ] - } - ] - } - ] - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec28.spec b/src/lib/config/tests/testdata/spec28.spec deleted file mode 100644 index cc83acb649..0000000000 --- a/src/lib/config/tests/testdata/spec28.spec +++ /dev/null @@ -1,7 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec28", - 'commands': [ ] - } -} - diff --git a/src/lib/config/tests/testdata/spec29.spec b/src/lib/config/tests/testdata/spec29.spec deleted file mode 100644 index c7ae5f82a8..0000000000 --- a/src/lib/config/tests/testdata/spec29.spec +++ /dev/null @@ -1,35 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec29", - "config_data": [ - { "item_name": "item1", - "item_type": "integer", - "item_optional": false, - "item_default": 1 - } - ], - "commands": [ - { - "command_name": "good_command", - "command_description": "A good command", - "command_args": [] - }, - { - "command_name": "bad_command", - "command_description": "A bad command", - "command_args": [] - }, - { - "command_name": "command_with_arg", - "command_description": "A command with an (integer) argument", - "command_args": [ { - "item_name": "number", - "item_type": "integer", - "item_optional": true, - "item_default": 1 - } ] - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec3.spec b/src/lib/config/tests/testdata/spec3.spec deleted file mode 100644 index b59d949c77..0000000000 --- a/src/lib/config/tests/testdata/spec3.spec +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec3", - "config_data": [ - { - "item_type": "integer", - "item_optional": false, - "item_default": 1 - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec30.spec b/src/lib/config/tests/testdata/spec30.spec deleted file mode 100644 index a9e00ad6e5..0000000000 --- a/src/lib/config/tests/testdata/spec30.spec +++ /dev/null @@ -1,45 +0,0 @@ -{ - "module_spec": { - "module_name": "lists", - "module_description": "Logging options", - "config_data": [ - { - "item_name": "first_list_items", - "item_type": "list", - "item_optional": false, - "item_default": [], - "list_item_spec": { - "item_name": "first_list_item", - "item_type": "map", - "item_optional": false, - "item_default": {}, - "map_item_spec": [ - { "item_name": "foo", - "item_type": "string", - "item_optional": false, - "item_default": "foo" - }, - { "item_name": "second_list_items", - "item_type": "list", - "item_optional": false, - "item_default": [], - "list_item_spec": { - "item_name": "second_list_item", - "item_type": "map", - "item_optional": false, - "item_default": {}, - "map_item_spec": [ - { "item_name": "final_element", - "item_type": "string", - "item_optional": false, - "item_default": "hello" - } - ] - } - } - ] - } - } - ] - } -} diff --git a/src/lib/config/tests/testdata/spec31.spec b/src/lib/config/tests/testdata/spec31.spec deleted file mode 100644 index 9eebfd18a9..0000000000 --- a/src/lib/config/tests/testdata/spec31.spec +++ /dev/null @@ -1,63 +0,0 @@ -{ - "module_spec": { - "module_name": "lists", - "module_description": "Logging options", - "config_data": [ - { - "item_name": "first_list_items", - "item_type": "list", - "item_optional": false, - "item_default": [], - "list_item_spec": { - "item_name": "first_list_item", - "item_type": "map", - "item_optional": false, - "item_default": {}, - "map_item_spec": [ - { "item_name": "foo", - "item_type": "string", - "item_optional": false, - "item_default": "foo" - }, - { "item_name": "second_list_items", - "item_type": "list", - "item_optional": false, - "item_default": [], - "list_item_spec": { - "item_name": "second_list_item", - "item_type": "map", - "item_optional": false, - "item_default": {}, - "map_item_spec": [ - { "item_name": "map_element", - "item_type": "map", - "item_optional": false, - "item_default": {}, - "map_item_spec": [ - { "item_name": "list1", - "item_type": "list", - "item_optional": false, - "item_default": [], - "list_item_spec": - { "item_name": "list2", - "item_type": "list", - "item_optional": false, - "item_default": [], - "list_item_spec": - { "item_name": "number", - "item_type": "integer", - "item_optional": false, - "item_default": 1 - } - } - }] - } - ] - } - } - ] - } - } - ] - } -} diff --git a/src/lib/config/tests/testdata/spec32.spec b/src/lib/config/tests/testdata/spec32.spec deleted file mode 100644 index 2baf1c1f6e..0000000000 --- a/src/lib/config/tests/testdata/spec32.spec +++ /dev/null @@ -1,72 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec32", - "config_data": [ - { "item_name": "named_set_item", - "item_type": "named_set", - "item_optional": false, - "item_default": { "a": 1, "b": 2 }, - "named_set_item_spec": { - "item_name": "named_set_element", - "item_type": "integer", - "item_optional": false, - "item_default": 3 - } - }, - { "item_name": "named_set_item2", - "item_type": "named_set", - "item_optional": true, - "item_default": { }, - "named_set_item_spec": { - "item_name": "named_set_element", - "item_type": "map", - "item_optional": false, - "item_default": {}, - "map_item_spec": [ - { "item_name": "first", - "item_type": "integer", - "item_optional": true - }, - { "item_name": "second", - "item_type": "string", - "item_optional": true - } - ] - } - }, - { "item_name": "named_set_item3", - "item_type": "named_set", - "item_optional": true, - "item_default": { "values": [ 1, 2, 3 ] }, - "named_set_item_spec": { - "item_name": "named_set_element", - "item_type": "list", - "item_optional": false, - "item_default": [], - "list_item_spec": - { "item_name": "list_value", - "item_type": "integer", - "item_optional": true - } - } - }, - { "item_name": "named_set_item4", - "item_type": "named_set", - "item_optional": true, - "item_default": {}, - "named_set_item_spec": { - "item_name": "named_set_element", - "item_type": "named_set", - "item_optional": false, - "item_default": { "a": 1, "b": 2 }, - "named_set_item_spec": - { "item_name": "named_set_element", - "item_type": "integer", - "item_optional": true - } - } - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec33.spec b/src/lib/config/tests/testdata/spec33.spec deleted file mode 100644 index 3002488b72..0000000000 --- a/src/lib/config/tests/testdata/spec33.spec +++ /dev/null @@ -1,50 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec33", - "statistics": [ - { - "item_name": "dummy_str", - "item_type": "string", - "item_optional": false, - "item_default": "Dummy", - "item_title": "Dummy String", - "item_description": "A dummy string" - }, - { - "item_name": "dummy_int", - "item_type": "integer", - "item_optional": false, - "item_default": 0, - "item_title": "Dummy Integer", - "item_description": "A dummy integer" - }, - { - "item_name": "dummy_datetime", - "item_type": "string", - "item_optional": false, - "item_default": "1970-01-01T00:00:00Z", - "item_title": "Dummy DateTime", - "item_description": "A dummy datetime", - "item_format": "date-time" - }, - { - "item_name": "dummy_date", - "item_type": "string", - "item_optional": false, - "item_default": "1970-01-01", - "item_title": "Dummy Date", - "item_description": "A dummy date", - "item_format": "date" - }, - { - "item_name": "dummy_time", - "item_type": "string", - "item_optional": false, - "item_default": "00:00:00", - "item_title": "Dummy Time", - "item_description": "A dummy time", - "item_format": "time" - } - ] - } -} diff --git a/src/lib/config/tests/testdata/spec34.spec b/src/lib/config/tests/testdata/spec34.spec deleted file mode 100644 index dd1f3ca952..0000000000 --- a/src/lib/config/tests/testdata/spec34.spec +++ /dev/null @@ -1,14 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec34", - "statistics": [ - { - "item_name": "dummy_str", - "item_type": "string", - "item_optional": false, - "item_default": "Dummy", - "item_description": "A dummy string" - } - ] - } -} diff --git a/src/lib/config/tests/testdata/spec35.spec b/src/lib/config/tests/testdata/spec35.spec deleted file mode 100644 index 86aaf145a0..0000000000 --- a/src/lib/config/tests/testdata/spec35.spec +++ /dev/null @@ -1,15 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec35", - "statistics": [ - { - "item_name": "dummy_str", - "item_type": "string", - "item_optional": false, - "item_default": "Dummy", - "item_title": "Dummy String" - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec36.spec b/src/lib/config/tests/testdata/spec36.spec deleted file mode 100644 index fb9ce26084..0000000000 --- a/src/lib/config/tests/testdata/spec36.spec +++ /dev/null @@ -1,17 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec36", - "statistics": [ - { - "item_name": "dummy_str", - "item_type": "string", - "item_optional": false, - "item_default": "Dummy", - "item_title": "Dummy String", - "item_description": "A dummy string", - "item_format": "dummy" - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec37.spec b/src/lib/config/tests/testdata/spec37.spec deleted file mode 100644 index bc444d107c..0000000000 --- a/src/lib/config/tests/testdata/spec37.spec +++ /dev/null @@ -1,7 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec37", - "statistics": 8 - } -} - diff --git a/src/lib/config/tests/testdata/spec38.spec b/src/lib/config/tests/testdata/spec38.spec deleted file mode 100644 index 1892e887fb..0000000000 --- a/src/lib/config/tests/testdata/spec38.spec +++ /dev/null @@ -1,17 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec38", - "statistics": [ - { - "item_name": "dummy_datetime", - "item_type": "string", - "item_optional": false, - "item_default": "11", - "item_title": "Dummy DateTime", - "item_description": "A dummy datetime", - "item_format": "date-time" - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec39.spec b/src/lib/config/tests/testdata/spec39.spec deleted file mode 100644 index 1f7231923f..0000000000 --- a/src/lib/config/tests/testdata/spec39.spec +++ /dev/null @@ -1,21 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec39", - "config_data": [ - { "item_name": "list", - "item_type": "list", - "item_optional": false, - "item_default": [], - "list_item_spec": { - "item_name": "list_item", - "item_type": "boolean", - "item_optional": false, - "item_default": false - } - } - ], - "commands": [], - "statistics": [] - } -} - diff --git a/src/lib/config/tests/testdata/spec4.spec b/src/lib/config/tests/testdata/spec4.spec deleted file mode 100644 index 80d9b22ef1..0000000000 --- a/src/lib/config/tests/testdata/spec4.spec +++ /dev/null @@ -1,12 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "config_data": [ - { "item_name": "item1", - "item_optional": false, - "item_default": 1 - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec40.spec b/src/lib/config/tests/testdata/spec40.spec deleted file mode 100644 index 6fbec10f3f..0000000000 --- a/src/lib/config/tests/testdata/spec40.spec +++ /dev/null @@ -1,21 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec40", - "config_data": [ - { "item_name": "item1", - "item_type": "any", - "item_optional": false, - "item_default": "asdf" - }, - { "item_name": "item2", - "item_type": "any", - "item_optional": true - }, - { "item_name": "item3", - "item_type": "any", - "item_optional": true, - "item_default": null - } - ] - } -} diff --git a/src/lib/config/tests/testdata/spec41.spec b/src/lib/config/tests/testdata/spec41.spec deleted file mode 100644 index 1c57cfed59..0000000000 --- a/src/lib/config/tests/testdata/spec41.spec +++ /dev/null @@ -1,35 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec40", - "statistics": [ - { - "item_name": "zones", - "item_type": "named_set", - "item_optional": false, - "item_default": { }, - "item_title": "Dummy name set", - "item_description": "A dummy name set", - "named_set_item_spec": { - "item_name": "zonename", - "item_type": "map", - "item_optional": false, - "item_default": { }, - "map_item_spec": [ - { - "item_name": "queries.tcp", - "item_optional": false, - "item_type": "integer", - "item_default": 0 - }, - { - "item_name": "queries.udp", - "item_optional": false, - "item_type": "integer", - "item_default": 0 - } - ] - } - } - ] - } -} diff --git a/src/lib/config/tests/testdata/spec42.spec b/src/lib/config/tests/testdata/spec42.spec deleted file mode 100644 index d822465363..0000000000 --- a/src/lib/config/tests/testdata/spec42.spec +++ /dev/null @@ -1,17 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec42", - "config_data": [ - { "item_name": "list_item", - "item_type": "list", - "item_optional": true, - "list_item_spec": { - "item_name": "list_element", - "item_type": "string", - "item_optional": false, - "item_default": "" - } - } - ] - } -} diff --git a/src/lib/config/tests/testdata/spec5.spec b/src/lib/config/tests/testdata/spec5.spec deleted file mode 100644 index 515424a9e2..0000000000 --- a/src/lib/config/tests/testdata/spec5.spec +++ /dev/null @@ -1,12 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "config_data": [ - { "item_name": "item1", - "item_type": "integer", - "item_default": 1 - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec6.spec b/src/lib/config/tests/testdata/spec6.spec deleted file mode 100644 index 631d882cea..0000000000 --- a/src/lib/config/tests/testdata/spec6.spec +++ /dev/null @@ -1,12 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "config_data": [ - { "item_name": "item1", - "item_type": "integer", - "item_optional": false - } - ] - } -} - diff --git a/src/lib/config/tests/testdata/spec7.spec b/src/lib/config/tests/testdata/spec7.spec deleted file mode 100644 index 42f8b7aece..0000000000 --- a/src/lib/config/tests/testdata/spec7.spec +++ /dev/null @@ -1,5 +0,0 @@ -{ - "module_spec": { - } -} - diff --git a/src/lib/config/tests/testdata/spec8.spec b/src/lib/config/tests/testdata/spec8.spec deleted file mode 100644 index bfd870e452..0000000000 --- a/src/lib/config/tests/testdata/spec8.spec +++ /dev/null @@ -1,3 +0,0 @@ -{ -} - diff --git a/src/lib/config/tests/testdata/spec9.spec b/src/lib/config/tests/testdata/spec9.spec deleted file mode 100644 index 21018b8e4e..0000000000 --- a/src/lib/config/tests/testdata/spec9.spec +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module_spec": { - "module_name": "Spec2", - "config_data": [ - { "item_name": "item1", - "item_type": "integer", - "item_optional": false, - "item_default": "asdf" - } - ] - } -} - diff --git a/src/lib/config_backend/tests/Makefile.am b/src/lib/config_backend/tests/Makefile.am index a58d143942..3933768c3c 100644 --- a/src/lib/config_backend/tests/Makefile.am +++ b/src/lib/config_backend/tests/Makefile.am @@ -28,6 +28,7 @@ libcb_unittests_LDADD = $(top_builddir)/src/lib/database/libkea-database.la libcb_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la libcb_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la libcb_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la +libcb_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la libcb_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la libcb_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libcb_unittests_LDADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(GTEST_LDADD) diff --git a/src/lib/config_backend/tests/run_unittests.cc b/src/lib/config_backend/tests/run_unittests.cc index 6754d66eb2..1ccf6d1503 100644 --- a/src/lib/config_backend/tests/run_unittests.cc +++ b/src/lib/config_backend/tests/run_unittests.cc @@ -6,14 +6,14 @@ #include <config.h> -#include <log/logger_support.h> #include <gtest/gtest.h> +#include <util/unittests/run_all.h> +#include <log/logger_support.h> + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); - - int result = RUN_ALL_TESTS(); - - return (result); + isc::log::initLogger(); + return (isc::util::unittests::run_all()); } diff --git a/src/lib/cryptolink/cryptolink.h b/src/lib/cryptolink/cryptolink.h index 984119827b..7c2f596978 100644 --- a/src/lib/cryptolink/cryptolink.h +++ b/src/lib/cryptolink/cryptolink.h @@ -19,36 +19,35 @@ namespace isc { namespace cryptolink { -/// \brief Hash algorithm identifiers +/// @brief Hash algorithm identifiers. enum HashAlgorithm { - UNKNOWN_HASH = 0, ///< This value can be used in conversion - /// functions, to be returned when the - /// input is unknown (but a value MUST be - /// returned), for instance when the input - /// is a Name or a string, and the return - /// value is a HashAlgorithm. - MD5 = 1, ///< MD5 - SHA1 = 2, ///< SHA-1 - SHA256 = 3, ///< SHA-256 - SHA224 = 4, ///< SHA-224 - SHA384 = 5, ///< SHA-384 - SHA512 = 6 ///< SHA-512 - + UNKNOWN_HASH = 0, // This value can be used in conversion + // functions, to be returned when the + // input is unknown (but a value MUST be + // returned), for instance when the input + // is a Name or a string, and the return + // value is a HashAlgorithm. + MD5 = 1, // MD5 + SHA1 = 2, // SHA-1 + SHA256 = 3, // SHA-256 + SHA224 = 4, // SHA-224 + SHA384 = 5, // SHA-384 + SHA512 = 6 // SHA-512 }; -/// \brief Forward declaration for createHash() +/// @brief Forward declaration for createHash(). class Hash; -/// \brief Forward declaration for createHMAC() +/// @brief Forward declaration for createHMAC(). class HMAC; -/// \brief Forward declaration for getRNG() +/// @brief Forward declaration for getRNG(). class RNG; -/// \brief Type representing the pointer to the RNG. +/// @brief Type representing the pointer to the RNG. typedef boost::shared_ptr<RNG> RNGPtr; -/// General exception class that is the base for all crypto-related +/// @brief General exception class that is the base for all crypto-related /// exceptions class CryptoLinkError : public Exception { public: @@ -56,7 +55,7 @@ public: isc::Exception(file, line, what) {} }; -/// This exception is thrown if there was a problem initializing the +/// @brief This exception is thrown if there was a problem initializing the /// crypto library class InitializationError : public CryptoLinkError { public: @@ -64,7 +63,7 @@ public: CryptoLinkError(file, line, what) {} }; -/// This exception is thrown when a cryptographic action is requested +/// @brief This exception is thrown when a cryptographic action is requested /// for an algorithm that is not supported by the underlying library. class UnsupportedAlgorithm : public CryptoLinkError { public: @@ -72,7 +71,7 @@ public: CryptoLinkError(file, line, what) {} }; -/// This exception is thrown when the underlying library could not +/// @brief This exception is thrown when the underlying library could not /// handle the key data. class BadKey : public CryptoLinkError { public: @@ -80,7 +79,7 @@ public: CryptoLinkError(file, line, what) {} }; -/// This exception is raised when a general error that was not +/// @brief This exception is raised when a general error that was not /// specifically caught is thrown by the underlying library. It /// is replaced by this one so as not have 'external' exceptions /// bubbling up @@ -90,16 +89,16 @@ public: CryptoLinkError(file, line, what) {} }; -/// \brief Forward declarations for CryptoLink pimpl. +/// @brief Forward declarations for CryptoLink pimpl. class CryptoLinkImpl; -/// \brief Type representing the pointer to the CryptoLinkImpl. +/// @brief Type representing the pointer to the CryptoLinkImpl. typedef boost::shared_ptr<CryptoLinkImpl> CryptoLinkImplPtr; -/// \brief Forward declarations for RNG pimpl. +/// @brief Forward declarations for RNG pimpl. class RNGImpl; -/// \brief Singleton entry point and factory class +/// @brief Singleton entry point and factory class /// /// This is a singleton class that serves as the entry point to /// the underlying cryptography library, and as a factory for objects @@ -128,15 +127,15 @@ class RNGImpl; /// sure you do not forget this, is to place the result of the create /// functions in a shared_ptr with the corresponding deleter function. /// -/// \note All other classes within cryptolink should have private +/// @note All other classes within cryptolink should have private /// constructors as well, and should have a factory function from /// CryptoLink, and a deleter function. /// -// Internal note: we can use this class later to initialize and manage -// dynamic (PKCS#11) libs +/// Internal note: we can use this class later to initialize and manage +/// dynamic (PKCS#11) libs. class CryptoLink : private boost::noncopyable { public: - /// \brief Returns a reference to the singleton instance + /// @brief Returns a reference to the singleton instance. /// /// If the library has not been initialized yet, it will be /// initialized with some default values. @@ -144,15 +143,17 @@ public: /// Since this class is noncopyable, you must use the return /// value directly, or store it in a reference variable. /// - /// \exception InitializationError if initialization fails + /// @throw InitializationError if initialization fails. /// - /// \return Reference to the singleton instance + /// @return Reference to the singleton instance. static CryptoLink& getCryptoLink(); - /// \brief Get version string + /// @brief Get version string. + /// + /// @return The version as string. static std::string getVersion(); - /// \brief Factory function for Hash objects + /// @brief Factory function for Hash objects. /// /// CryptoLink objects cannot be constructed directly. This /// function creates a new Hash object usable for signing or @@ -164,17 +165,19 @@ public: /// /// If you want to safely delete objects created with this method, /// you can use the function deleteHash() as defined in - /// crypto_hash.h + /// crypto_hash.h. + /// + /// @throw UnsupportedAlgorithmException if the given algorithm + /// is unknown or not supported by the underlying library. + /// @throw LibraryError if there was any unexpected exception + /// in the underlying library. /// - /// \exception UnsupportedAlgorithmException if the given algorithm - /// is unknown or not supported by the underlying library - /// \exception LibraryError if there was any unexpected exception - /// in the underlying library + /// @param hash_algorithm The hash algorithm. /// - /// \param hash_algorithm The hash algorithm + /// @return The new hash. Hash* createHash(const HashAlgorithm hash_algorithm); - /// \brief Factory function for HMAC objects + /// @brief Factory function for HMAC objects /// /// CryptoLink objects cannot be constructed directly. This /// function creates a new HMAC object usable for signing or @@ -187,58 +190,62 @@ public: /// Notes: if the secret is longer than the block size of its /// algorithm, the constructor will run it through the hash /// algorithm, and use the digest as the secret for this HMAC - /// operation + /// operation. /// /// If you want to safely delete objects created with this method, /// you can use the function deleteHMAC() as defined in - /// crypto_hmac.h + /// crypto_hmac.h. /// - /// \exception UnsupportedAlgorithmException if the given algorithm - /// is unknown or not supported by the underlying library - /// \exception InvalidKeyLength if the given key secret_len is bad - /// \exception LibraryError if there was any unexpected exception - /// in the underlying library + /// @throw UnsupportedAlgorithmException if the given algorithm + /// is unknown or not supported by the underlying library. + /// @throw InvalidKeyLength if the given key secret_len is bad. + /// @throw LibraryError if there was any unexpected exception + /// in the underlying library. /// - /// \param secret The secret to sign with - /// \param secret_len The length of the secret - /// \param hash_algorithm The hash algorithm + /// @param secret The secret to sign with + /// @param secret_len The length of the secret + /// @param hash_algorithm The hash algorithm + /// + /// @return The new hash. HMAC* createHMAC(const void* secret, size_t secret_len, const HashAlgorithm hash_algorithm); - /// \brief Get the global RNG + /// @brief Get the global RNG. + /// + /// @throw NotImplemented if the method was not implemented + /// in a derived class. + /// @throw LibraryError if there was any unexpected exception + /// in the underlying library. /// - /// \exception NotImplemented if the method was not implemented - /// in a derived class - /// \exception LibraryError if there was any unexpected exception - /// in the underlying library + /// @return The gobal RNG. virtual RNGPtr const& getRNG() const; private: - /// \brief Initialize the library + /// @brief Initialize the library. /// /// If the library has already been initialized (either by a call /// to initialize() or automatically in getCryptoLink()), this /// function does nothing. /// - /// \note A call to initialize() is not strictly necessary with + /// @note A call to initialize() is not strictly necessary with /// the current implementation. /// - /// \exception InitializationError if initialization fails + /// @throw InitializationError if initialization fails. /// - /// \param c the CryptoLink singleton instance which is being initialized. + /// @param c the CryptoLink singleton instance which is being initialized. void initialize(CryptoLink& c); - // To prevent people constructing their own, we make the constructor - // private too. + /// @note To prevent people constructing their own, we make the constructor + /// private too. CryptoLink() { initialize(*this); } ~CryptoLink(); - /// \brief Smart pointer holding the implementation. + /// @brief Smart pointer holding the implementation. CryptoLinkImplPtr impl_; - /// \brief Smart pointer holding the RNG. + /// @brief Smart pointer holding the RNG. RNGPtr rng_; }; diff --git a/src/lib/cryptolink/tests/run_unittests.cc b/src/lib/cryptolink/tests/run_unittests.cc index b2e8e4fccc..935e502483 100644 --- a/src/lib/cryptolink/tests/run_unittests.cc +++ b/src/lib/cryptolink/tests/run_unittests.cc @@ -5,10 +5,11 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include <config.h> + #include <gtest/gtest.h> -#include <log/logger_support.h> #include <util/unittests/run_all.h> +#include <log/logger_support.h> int main(int argc, char* argv[]) { diff --git a/src/lib/d2srv/tests/Makefile.am b/src/lib/d2srv/tests/Makefile.am index 2311b8f597..79c82a4d02 100644 --- a/src/lib/d2srv/tests/Makefile.am +++ b/src/lib/d2srv/tests/Makefile.am @@ -43,6 +43,7 @@ libd2srv_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la libd2srv_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la libd2srv_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la libd2srv_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la +libd2srv_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la libd2srv_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la libd2srv_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libd2srv_unittests_LDADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(GTEST_LDADD) diff --git a/src/lib/d2srv/tests/run_unittests.cc b/src/lib/d2srv/tests/run_unittests.cc index 768319e3fa..84baee26c7 100644 --- a/src/lib/d2srv/tests/run_unittests.cc +++ b/src/lib/d2srv/tests/run_unittests.cc @@ -5,16 +5,15 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include <config.h> -#include <log/logger_support.h> #include <gtest/gtest.h> +#include <util/unittests/run_all.h> +#include <log/logger_support.h> + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - - int result = RUN_ALL_TESTS(); - - return (result); + return (isc::util::unittests::run_all()); } diff --git a/src/lib/database/tests/Makefile.am b/src/lib/database/tests/Makefile.am index f4cf4f0d3e..2301330953 100644 --- a/src/lib/database/tests/Makefile.am +++ b/src/lib/database/tests/Makefile.am @@ -35,6 +35,7 @@ libdatabase_unittests_LDADD += $(top_builddir)/src/lib/testutils/libkea-testutil libdatabase_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la libdatabase_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la libdatabase_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la +libdatabase_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la libdatabase_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la libdatabase_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libdatabase_unittests_LDADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(GTEST_LDADD) diff --git a/src/lib/database/tests/run_unittests.cc b/src/lib/database/tests/run_unittests.cc index 4e83d4bd6c..1ccf6d1503 100644 --- a/src/lib/database/tests/run_unittests.cc +++ b/src/lib/database/tests/run_unittests.cc @@ -6,15 +6,14 @@ #include <config.h> -#include <log/logger_support.h> #include <gtest/gtest.h> +#include <util/unittests/run_all.h> +#include <log/logger_support.h> + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - - int result = RUN_ALL_TESTS(); - - return (result); + return (isc::util::unittests::run_all()); } diff --git a/src/lib/dhcp/tests/Makefile.am b/src/lib/dhcp/tests/Makefile.am index 8bcc1af637..bd60db0060 100644 --- a/src/lib/dhcp/tests/Makefile.am +++ b/src/lib/dhcp/tests/Makefile.am @@ -94,6 +94,7 @@ libdhcp___unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la libdhcp___unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la libdhcp___unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la libdhcp___unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la +libdhcp___unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la libdhcp___unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la libdhcp___unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libdhcp___unittests_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS) diff --git a/src/lib/dhcp/tests/option6_pdexclude_unittest.cc b/src/lib/dhcp/tests/option6_pdexclude_unittest.cc index b9c49f747a..6e81aed3f5 100644 --- a/src/lib/dhcp/tests/option6_pdexclude_unittest.cc +++ b/src/lib/dhcp/tests/option6_pdexclude_unittest.cc @@ -76,7 +76,6 @@ TEST(Option6PDExcludeTest, pack) { ASSERT_EQ(expected_vec.size(), buf.getLength()); // Check that the generated wire format is correct. - const uint8_t* data = buf.getData(); const std::vector<uint8_t>& vec = buf.getVector(); ASSERT_TRUE(std::equal(vec.cbegin(), vec.cend(), expected_vec.cbegin())); } diff --git a/src/lib/dhcp/tests/run_unittests.cc b/src/lib/dhcp/tests/run_unittests.cc index e1c0801f51..c6d03a200d 100644 --- a/src/lib/dhcp/tests/run_unittests.cc +++ b/src/lib/dhcp/tests/run_unittests.cc @@ -6,16 +6,14 @@ #include <config.h> -#include <log/logger_support.h> - #include <gtest/gtest.h> +#include <util/unittests/run_all.h> +#include <log/logger_support.h> + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - - int result = RUN_ALL_TESTS(); - - return (result); + return (isc::util::unittests::run_all()); } diff --git a/src/lib/dhcp_ddns/tests/Makefile.am b/src/lib/dhcp_ddns/tests/Makefile.am index 68ae6baabe..abf16b9bfd 100644 --- a/src/lib/dhcp_ddns/tests/Makefile.am +++ b/src/lib/dhcp_ddns/tests/Makefile.am @@ -39,6 +39,7 @@ libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la +libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libdhcp_ddns_unittests_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS) diff --git a/src/lib/dhcp_ddns/tests/run_unittests.cc b/src/lib/dhcp_ddns/tests/run_unittests.cc index e1c0801f51..c6d03a200d 100644 --- a/src/lib/dhcp_ddns/tests/run_unittests.cc +++ b/src/lib/dhcp_ddns/tests/run_unittests.cc @@ -6,16 +6,14 @@ #include <config.h> -#include <log/logger_support.h> - #include <gtest/gtest.h> +#include <util/unittests/run_all.h> +#include <log/logger_support.h> + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - - int result = RUN_ALL_TESTS(); - - return (result); + return (isc::util::unittests::run_all()); } diff --git a/src/lib/dhcpsrv/tests/Makefile.am b/src/lib/dhcpsrv/tests/Makefile.am index 20c670159f..eb2cd2630f 100644 --- a/src/lib/dhcpsrv/tests/Makefile.am +++ b/src/lib/dhcpsrv/tests/Makefile.am @@ -187,6 +187,7 @@ libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.l libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la +libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libdhcpsrv_unittests_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS) diff --git a/src/lib/dhcpsrv/tests/run_unittests.cc b/src/lib/dhcpsrv/tests/run_unittests.cc index 76b2ebf0bc..956fe8b13e 100644 --- a/src/lib/dhcpsrv/tests/run_unittests.cc +++ b/src/lib/dhcpsrv/tests/run_unittests.cc @@ -5,16 +5,15 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include <config.h> -#include <log/logger_support.h> #include <gtest/gtest.h> +#include <util/unittests/run_all.h> +#include <log/logger_support.h> + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - - int result = RUN_ALL_TESTS(); - - return (result); + return (isc::util::unittests::run_all()); } diff --git a/src/lib/dns/message.h b/src/lib/dns/message.h index be5d0afa54..d5c57950d0 100644 --- a/src/lib/dns/message.h +++ b/src/lib/dns/message.h @@ -153,8 +153,8 @@ class Message { public: /// Constants to specify the operation mode of the \c Message. enum Mode { - PARSE = 0, ///< Parse mode (handling an incoming message) - RENDER = 1 ///< Render mode (building an outgoing message) + PARSE = 0, // Parse mode (handling an incoming message) + RENDER = 1 // Render mode (building an outgoing message) }; /// \brief Constants for flag bit fields of a DNS message header. @@ -200,13 +200,13 @@ public: /// between the complexity and advantage, but hopefully the cast notation /// is sufficiently ugly to prevent proliferation of the usage. enum HeaderFlag { - HEADERFLAG_QR = 0x8000, ///< Query (if cleared) or response (if set) - HEADERFLAG_AA = 0x0400, ///< Authoritative answer - HEADERFLAG_TC = 0x0200, ///< Truncation - HEADERFLAG_RD = 0x0100, ///< Recursion desired - HEADERFLAG_RA = 0x0080, ///< Recursion available - HEADERFLAG_AD = 0x0020, ///< Authentic %data (RFC4035) - HEADERFLAG_CD = 0x0010 ///< DNSSEC checking disabled (RFC4035) + HEADERFLAG_QR = 0x8000, // Query (if cleared) or response (if set) + HEADERFLAG_AA = 0x0400, // Authoritative answer + HEADERFLAG_TC = 0x0200, // Truncation + HEADERFLAG_RD = 0x0100, // Recursion desired + HEADERFLAG_RA = 0x0080, // Recursion available + HEADERFLAG_AD = 0x0020, // Authentic %data (RFC4035) + HEADERFLAG_CD = 0x0010 // DNSSEC checking disabled (RFC4035) }; /// \brief Constants to specify sections of a DNS message. @@ -240,10 +240,10 @@ public: /// <b>Future Extension:</b> We'll probably also define constants for /// the section names used in dynamic updates in future versions. enum Section { - SECTION_QUESTION = 0, ///< %Question section - SECTION_ANSWER = 1, ///< Answer section - SECTION_AUTHORITY = 2, ///< Authority section - SECTION_ADDITIONAL = 3 ///< Additional section + SECTION_QUESTION = 0, // Question section + SECTION_ANSWER = 1, // Answer section + SECTION_AUTHORITY = 2, // Authority section + SECTION_ADDITIONAL = 3 // Additional section }; /// @@ -594,8 +594,8 @@ public: /// These are values of a bitmask type. Bitwise operations can be /// performed on these values to express compound options. enum ParseOptions { - PARSE_DEFAULT = 0, ///< The default options - PRESERVE_ORDER = 1 ///< Preserve RR order and don't combine them + PARSE_DEFAULT = 0, // The default options + PRESERVE_ORDER = 1 // Preserve RR order and don't combine them }; /// \brief Parse the header section of the \c Message. diff --git a/src/lib/dns/name.h b/src/lib/dns/name.h index 1a64f194ff..37723e88f7 100644 --- a/src/lib/dns/name.h +++ b/src/lib/dns/name.h @@ -296,9 +296,9 @@ public: /// In addition, if resource allocation for the new name fails, a /// corresponding standard exception will be thrown. /// - /// \param buffer A buffer storing the wire format %data. + /// \param buff A buffer storing the wire format %data. /// \param downcase Whether to convert upper case alphabets to lower case. - explicit Name(isc::util::InputBuffer& buffer, bool downcase = false); + explicit Name(isc::util::InputBuffer& buff, bool downcase = false); /// /// We use the default copy constructor intentionally. //@} @@ -420,8 +420,8 @@ public: /// <code>buffer.getCapacity() - buffer.getLength() >= Name::MAX_WIRE</code> /// then this method should not throw an exception. /// - /// \param buffer An output buffer to store the wire %data. - void toWire(isc::util::OutputBuffer& buffer) const; + /// \param buff An output buffer to store the wire %data. + void toWire(isc::util::OutputBuffer& buff) const; //@} /// diff --git a/src/lib/dns/question.h b/src/lib/dns/question.h index efd6c3f167..088ca9fdfc 100644 --- a/src/lib/dns/question.h +++ b/src/lib/dns/question.h @@ -106,8 +106,8 @@ public: /// It may throw an exception if the construction of these component /// classes fails. /// - /// \param buffer A buffer storing the wire format data. - Question(isc::util::InputBuffer& buffer); + /// \param buff A buffer storing the wire format data. + Question(isc::util::InputBuffer& buff); /// \brief Constructor from fixed parameters of the \c Question. /// diff --git a/src/lib/dns/rdata.h b/src/lib/dns/rdata.h index af294f0670..47d7c77923 100644 --- a/src/lib/dns/rdata.h +++ b/src/lib/dns/rdata.h @@ -163,8 +163,8 @@ public: /// conversion is specific to each derived concrete class and /// should be explicitly defined in the derived class. /// - /// \param buffer An output buffer to store the wire data. - virtual void toWire(isc::util::OutputBuffer& buffer) const = 0; + /// \param buff An output buffer to store the wire data. + virtual void toWire(isc::util::OutputBuffer& buff) const = 0; /// \brief Render the \c Rdata in the wire format into a /// \c MessageRenderer object. @@ -282,10 +282,10 @@ public: /// contain \c rdata_len bytes of unread data, an exception of /// class \c isc::OutOfRange will be thrown. /// - /// \param buffer A reference to an \c InputBuffer object storing the + /// \param buff A reference to an \c InputBuffer object storing the /// \c Rdata to parse. /// \param rdata_len The length in buffer of the \c Rdata. In bytes. - Generic(isc::util::InputBuffer& buffer, size_t rdata_len); + Generic(isc::util::InputBuffer& buff, size_t rdata_len); /// \brief Constructor from master lexer. /// @@ -337,8 +337,8 @@ public: /// necessary memory space fails, a corresponding standard exception will /// be thrown. /// - /// \param buffer An output buffer to store the wire data. - virtual void toWire(isc::util::OutputBuffer& buffer) const; + /// \param buff An output buffer to store the wire data. + virtual void toWire(isc::util::OutputBuffer& buff) const; /// \brief Render the \c generic::Generic in the wire format into a /// \c MessageRenderer object. @@ -465,13 +465,13 @@ RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass, /// /// \param rrtype An \c RRType object specifying the type/class pair. /// \param rrclass An \c RRClass object specifying the type/class pair. -/// \param buffer A reference to an \c InputBuffer object storing the +/// \param buff A reference to an \c InputBuffer object storing the /// \c Rdata to parse. /// \param len The length in buffer of the \c Rdata. In bytes. /// \return An \c RdataPtr object pointing to the created \c Rdata /// object. RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass, - isc::util::InputBuffer& buffer, size_t len); + isc::util::InputBuffer& buff, size_t len); /// \brief Create RDATA of a given pair of RR type and class, copying /// of another RDATA of same kind. diff --git a/src/lib/dns/rrparamregistry.h b/src/lib/dns/rrparamregistry.h index 01d9059fc2..3ac7615495 100644 --- a/src/lib/dns/rrparamregistry.h +++ b/src/lib/dns/rrparamregistry.h @@ -90,11 +90,11 @@ public: /// of specific class corresponding to the specific derived class of /// \c AbstractRdataFactory. /// - /// \param buffer A reference to an \c InputBuffer object storing the + /// \param buff A reference to an \c InputBuffer object storing the /// \c Rdata to parse. /// \param rdata_len The length in buffer of the \c Rdata. In bytes. /// \return An \c RdataPtr object pointing to the created \c Rdata object. - virtual RdataPtr create(isc::util::InputBuffer& buffer, + virtual RdataPtr create(isc::util::InputBuffer& buff, size_t rdata_len) const = 0; /// \brief Create RDATA from another \c Rdata object of the same type. @@ -483,13 +483,13 @@ public: /// /// \param rrtype An \c RRType object specifying the type/class pair. /// \param rrclass An \c RRClass object specifying the type/class pair. - /// \param buffer A reference to an \c InputBuffer object storing the + /// \param buff A reference to an \c InputBuffer object storing the /// \c Rdata to parse. /// \param len The length in buffer of the \c Rdata. In bytes. /// \return An \c rdata::RdataPtr object pointing to the created \c Rdata /// object. rdata::RdataPtr createRdata(const RRType& rrtype, const RRClass& rrclass, - isc::util::InputBuffer& buffer, size_t len); + isc::util::InputBuffer& buff, size_t len); /// \brief Create RDATA of a given pair of RR type and class, copying /// of another RDATA of same kind. /// diff --git a/src/lib/dns/rrttl.h b/src/lib/dns/rrttl.h index 8f6b03ebd5..fb723c1a43 100644 --- a/src/lib/dns/rrttl.h +++ b/src/lib/dns/rrttl.h @@ -89,8 +89,8 @@ public: /// If the given data does not large enough to contain a 16-bit integer, /// an exception of class \c IncompleteRRTTL will be thrown. /// - /// \param buffer A buffer storing the wire format data. - explicit RRTTL(isc::util::InputBuffer& buffer); + /// \param buff A buffer storing the wire format data. + explicit RRTTL(isc::util::InputBuffer& buff); /// A separate factory of RRTTL from text. /// @@ -157,8 +157,8 @@ public: /// If resource allocation in rendering process fails, a corresponding /// standard exception will be thrown. /// - /// \param buffer An output buffer to store the wire data. - void toWire(isc::util::OutputBuffer& buffer) const; + /// \param buff An output buffer to store the wire data. + void toWire(isc::util::OutputBuffer& buff) const; //@} /// diff --git a/src/lib/dns/tsigkey.cc b/src/lib/dns/tsigkey.cc index 92a12bd146..b7f76945bc 100644 --- a/src/lib/dns/tsigkey.cc +++ b/src/lib/dns/tsigkey.cc @@ -26,35 +26,6 @@ using namespace isc::cryptolink; namespace isc { namespace dns { -namespace { - HashAlgorithm - convertAlgorithmName(const isc::dns::Name& name) { - if (name == TSIGKey::HMACMD5_NAME()) { - return (isc::cryptolink::MD5); - } - if (name == TSIGKey::HMACMD5_SHORT_NAME()) { - return (isc::cryptolink::MD5); - } - if (name == TSIGKey::HMACSHA1_NAME()) { - return (isc::cryptolink::SHA1); - } - if (name == TSIGKey::HMACSHA256_NAME()) { - return (isc::cryptolink::SHA256); - } - if (name == TSIGKey::HMACSHA224_NAME()) { - return (isc::cryptolink::SHA224); - } - if (name == TSIGKey::HMACSHA384_NAME()) { - return (isc::cryptolink::SHA384); - } - if (name == TSIGKey::HMACSHA512_NAME()) { - return (isc::cryptolink::SHA512); - } - - return (isc::cryptolink::UNKNOWN_HASH); - } -} - struct TSIGKey::TSIGKeyImpl { TSIGKeyImpl(const Name& key_name, const Name& algorithm_name, @@ -92,6 +63,35 @@ TSIGKey::TSIGKeyImpl { const vector<uint8_t> secret_; }; +namespace { + HashAlgorithm + convertAlgorithmName(const isc::dns::Name& name) { + if (name == TSIGKey::HMACMD5_NAME()) { + return (isc::cryptolink::MD5); + } + if (name == TSIGKey::HMACMD5_SHORT_NAME()) { + return (isc::cryptolink::MD5); + } + if (name == TSIGKey::HMACSHA1_NAME()) { + return (isc::cryptolink::SHA1); + } + if (name == TSIGKey::HMACSHA224_NAME()) { + return (isc::cryptolink::SHA224); + } + if (name == TSIGKey::HMACSHA256_NAME()) { + return (isc::cryptolink::SHA256); + } + if (name == TSIGKey::HMACSHA384_NAME()) { + return (isc::cryptolink::SHA384); + } + if (name == TSIGKey::HMACSHA512_NAME()) { + return (isc::cryptolink::SHA512); + } + + return (isc::cryptolink::UNKNOWN_HASH); + } +} + TSIGKey::TSIGKey(const Name& key_name, const Name& algorithm_name, const void* secret, size_t secret_len, size_t digestbits /*= 0*/) : impl_(0) { @@ -248,54 +248,6 @@ TSIGKey::toText() const { } } -const -Name& TSIGKey::HMACMD5_NAME() { - static Name alg_name("hmac-md5.sig-alg.reg.int"); - return (alg_name); -} - -const -Name& TSIGKey::HMACMD5_SHORT_NAME() { - static Name alg_name("hmac-md5"); - return (alg_name); -} - -const -Name& TSIGKey::HMACSHA1_NAME() { - static Name alg_name("hmac-sha1"); - return (alg_name); -} - -const -Name& TSIGKey::HMACSHA256_NAME() { - static Name alg_name("hmac-sha256"); - return (alg_name); -} - -const -Name& TSIGKey::HMACSHA224_NAME() { - static Name alg_name("hmac-sha224"); - return (alg_name); -} - -const -Name& TSIGKey::HMACSHA384_NAME() { - static Name alg_name("hmac-sha384"); - return (alg_name); -} - -const -Name& TSIGKey::HMACSHA512_NAME() { - static Name alg_name("hmac-sha512"); - return (alg_name); -} - -const -Name& TSIGKey::GSSTSIG_NAME() { - static Name alg_name("gss-tsig"); - return (alg_name); -} - struct TSIGKeyRing::TSIGKeyRingImpl { typedef map<Name, TSIGKey> TSIGKeyMap; typedef pair<Name, TSIGKey> NameAndKey; @@ -315,9 +267,7 @@ TSIGKeyRing::size() const { TSIGKeyRing::Result TSIGKeyRing::add(const TSIGKey& key) { - if (impl_->keys.insert( - TSIGKeyRingImpl::NameAndKey(key.getKeyName(), key)).second - == true) { + if (impl_->keys.insert(TSIGKeyRingImpl::NameAndKey(key.getKeyName(), key)).second) { return (SUCCESS); } else { return (EXIST); @@ -350,5 +300,53 @@ TSIGKeyRing::find(const Name& key_name, const Name& algorithm_name) const { return (FindResult(SUCCESS, &((*found).second))); } +const +Name& TSIGKey::HMACMD5_NAME() { + static Name alg_name("hmac-md5.sig-alg.reg.int"); + return (alg_name); +} + +const +Name& TSIGKey::HMACMD5_SHORT_NAME() { + static Name alg_name("hmac-md5"); + return (alg_name); +} + +const +Name& TSIGKey::HMACSHA1_NAME() { + static Name alg_name("hmac-sha1"); + return (alg_name); +} + +const +Name& TSIGKey::HMACSHA224_NAME() { + static Name alg_name("hmac-sha224"); + return (alg_name); +} + +const +Name& TSIGKey::HMACSHA256_NAME() { + static Name alg_name("hmac-sha256"); + return (alg_name); +} + +const +Name& TSIGKey::HMACSHA384_NAME() { + static Name alg_name("hmac-sha384"); + return (alg_name); +} + +const +Name& TSIGKey::HMACSHA512_NAME() { + static Name alg_name("hmac-sha512"); + return (alg_name); +} + +const +Name& TSIGKey::GSSTSIG_NAME() { + static Name alg_name("gss-tsig"); + return (alg_name); +} + } // namespace dns } // namespace isc diff --git a/src/lib/dns/tsigkey.h b/src/lib/dns/tsigkey.h index 93810741af..6d6e7a3218 100644 --- a/src/lib/dns/tsigkey.h +++ b/src/lib/dns/tsigkey.h @@ -14,7 +14,7 @@ namespace dns { class Name; -/// \brief TSIG key. +/// @brief TSIG key. /// /// This class holds a TSIG key along with some related attributes as /// defined in RFC2845. @@ -38,7 +38,7 @@ class Name; /// In the TSIG protocol, hash algorithms are represented in the form of /// domain name. /// Our interfaces provide direct translation of this concept; for example, -/// the constructor from parameters take a \c Name object to specify the +/// the constructor from parameters take a @class Name object to specify the /// algorithm. /// On one hand, this may be counter intuitive. /// An API user would rather specify "hmac-md5" instead of @@ -56,25 +56,25 @@ class Name; class TSIGKey { public: /// - /// \name Constructors, Assignment Operator and Destructor. + /// @brief Constructors, Assignment Operator and Destructor. /// //@{ - /// \brief Constructor from key parameters + /// @brief Constructor from key parameters. /// - /// \c algorithm_name should generally be a known algorithm to this + /// The algorithm_name should generally be a known algorithm to this /// implementation, which are defined via the /// <code>static const</code> member functions. /// /// Other names are still accepted as long as the secret is empty - /// (\c secret is null and \c secret_len is 0), however; in some cases + /// (secret is null and secret_len is 0), however; in some cases /// we might want to treat just the pair of key name and algorithm name /// opaquely, e.g., when generating a response TSIG with a BADKEY error /// because the algorithm is unknown as specified in Section 3.2 of /// RFC2845 (in which case the algorithm name would be copied from the /// request to the response, and for that purpose it would be convenient - /// if a \c TSIGKey object can hold a name for an "unknown" algorithm). + /// if a TSIGKey object can hold a name for an "unknown" algorithm). /// - /// \note RFC2845 does not specify which algorithm name should be used + /// @note RFC2845 does not specify which algorithm name should be used /// in such a BADKEY response. The behavior of using the same algorithm /// is derived from the BIND 9 implementation. /// @@ -84,13 +84,13 @@ public: /// accidental creation of such a dangerous key, e.g., due to misspelling /// in a configuration file). /// If the given algorithm name is unknown and non empty secret is - /// specified, an exception of type \c InvalidParameter will be thrown. + /// specified, an exception of type InvalidParameter will be thrown. /// - /// \c secret and \c secret_len must be consistent in that the latter + /// secret and secret_len must be consistent in that the latter /// is 0 if and only if the former is null; - /// otherwise an exception of type \c InvalidParameter will be thrown. + /// otherwise an exception of type InvalidParameter will be thrown. /// - /// \c digestbits is the truncated length in bits or 0 which means no + /// digestbits is the truncated length in bits or 0 which means no /// truncation and is the default. Constraints for non-zero value /// are in RFC 4635 section 3.1: minimum 80 or the half of the /// full (i.e., not truncated) length, integral number of octets @@ -99,19 +99,19 @@ public: /// This constructor internally involves resource allocation, and if /// it fails, a corresponding standard exception will be thrown. /// - /// \param key_name The name of the key as a domain name. - /// \param algorithm_name The hash algorithm used for this key in the + /// @param key_name The name of the key as a domain name. + /// @param algorithm_name The hash algorithm used for this key in the /// form of domain name. For example, it can be - /// \c TSIGKey::HMACSHA256_NAME() for HMAC-SHA256. - /// \param secret Point to a binary sequence of the shared secret to be + /// TSIGKey::HMACSHA256_NAME() for HMAC-SHA256. + /// @param secret Point to a binary sequence of the shared secret to be /// used for this key, or null if the secret is empty. - /// \param secret_len The size of the binary %data (\c secret) in bytes. - /// \param digestbits The number of bits to include in the digest - /// (0 means to include all) + /// @param secret_len The size of the binary %data (secret) in bytes. + /// @param digestbits The number of bits to include in the digest + /// (0 means to include all). TSIGKey(const Name& key_name, const Name& algorithm_name, const void* secret, size_t secret_len, size_t digestbits = 0); - /// \brief Constructor from an input string + /// @brief Constructor from an input string /// /// The string must be of the form: /// name:secret[:algorithm][:digestbits] @@ -129,20 +129,20 @@ public: /// use this constructor to create keys with a ':' character in /// their name. /// - /// \exception InvalidParameter exception if the input string is + /// @throw InvalidParameter exception if the input string is /// invalid. /// - /// \param str The string to make a TSIGKey from + /// @param str The string to make a TSIGKey from explicit TSIGKey(const std::string& str); - /// \brief The copy constructor. + /// @brief The copy constructor. /// /// It internally allocates a resource, and if it fails a corresponding /// standard exception will be thrown. /// This constructor never throws an exception otherwise. TSIGKey(const TSIGKey& source); - /// \brief Assignment operator. + /// @brief Assignment operator. /// /// It internally allocates a resource, and if it fails a corresponding /// standard exception will be thrown. @@ -153,70 +153,69 @@ public: /// intact. TSIGKey& operator=(const TSIGKey& source); - /// The destructor. + /// @brief The destructor. virtual ~TSIGKey(); //@} /// - /// \name Getter Methods + /// @brief Getter Methods /// /// These methods never throw an exception. //@{ - /// Return the key name. + /// @brief Return the key name. const Name& getKeyName() const; - /// Return the algorithm name. + /// @brief Return the algorithm name. const Name& getAlgorithmName() const; - /// Return the hash algorithm name in the form of cryptolink::HashAlgorithm + /// @brief Return the hash algorithm name in the form of cryptolink::HashAlgorithm isc::cryptolink::HashAlgorithm getAlgorithm() const; - /// Return the minimum truncated length. + /// @brief Return the minimum truncated length. size_t getDigestbits() const; - /// Return the length of the TSIG secret in bytes. + /// @brief Return the length of the TSIG secret in bytes. size_t getSecretLength() const; - /// Return the value of the TSIG secret. + /// @brief Return the value of the TSIG secret. /// /// If it returns a non null pointer, the memory region beginning at the /// address returned by this method is valid up to the bytes specified - /// by the return value of \c getSecretLength(). + /// by the return value of getSecretLength(). /// - /// The memory region is only valid while the corresponding \c TSIGKey - /// object is valid. The caller must hold the \c TSIGKey object while + /// The memory region is only valid while the corresponding TSIGKey + /// object is valid. The caller must hold the TSIGKey object while /// it needs to refer to the region or it must make a local copy of the /// region. const void* getSecret() const; //@} - /// \brief Converts the TSIGKey to a string value + /// @brief Converts the TSIGKey to a string value /// /// The resulting string will be of the form - /// name:secret:algorithm[:digestbits] + /// name:secret:algorithm[:digestbits]. /// Where "name" is a domain name for the key, "secret" is a /// base64 representation of the key secret, and "algorithm" is /// an algorithm identifier as specified in RFC 4635. /// When not zero, digestbits is appended. /// - /// \return The string representation of the given TSIGKey. + /// @return The string representation of the given TSIGKey. std::string toText() const; - /// - /// \name Well known algorithm names as defined in RFC2845 and RFC4635. + /// @brief Well known algorithm names as defined in RFC2845 and RFC4635. /// /// Note: we begin with the "mandatory" algorithms defined in RFC4635 /// as a minimal initial set. /// We'll add others as we see the need for them. //@{ - static const Name& HMACMD5_NAME(); ///< HMAC-MD5 (RFC2845) + static const Name& HMACMD5_NAME(); // HMAC-MD5 (RFC2845) static const Name& HMACMD5_SHORT_NAME(); - static const Name& HMACSHA1_NAME(); ///< HMAC-SHA1 (RFC4635) - static const Name& HMACSHA256_NAME(); ///< HMAC-SHA256 (RFC4635) - static const Name& HMACSHA224_NAME(); ///< HMAC-SHA256 (RFC4635) - static const Name& HMACSHA384_NAME(); ///< HMAC-SHA256 (RFC4635) - static const Name& HMACSHA512_NAME(); ///< HMAC-SHA256 (RFC4635) - static const Name& GSSTSIG_NAME(); ///< GSS-TSIG (RFC3645) + static const Name& HMACSHA1_NAME(); // HMAC-SHA1 (RFC4635) + static const Name& HMACSHA256_NAME(); // HMAC-SHA256 (RFC4635) + static const Name& HMACSHA224_NAME(); // HMAC-SHA256 (RFC4635) + static const Name& HMACSHA384_NAME(); // HMAC-SHA256 (RFC4635) + static const Name& HMACSHA512_NAME(); // HMAC-SHA256 (RFC4635) + static const Name& GSSTSIG_NAME(); // GSS-TSIG (RFC3645) //@} private: @@ -224,9 +223,9 @@ private: boost::shared_ptr<TSIGKeyImpl> impl_; }; -/// \brief A simple repository of a set of \c TSIGKey objects. +/// @brief A simple repository of a set of TSIGKey objects. /// -/// This is a "key ring" to maintain TSIG keys (\c TSIGKey objects) and +/// This is a "key ring" to maintain TSIG keys (TSIGKey objects) and /// provides trivial operations such as add, remove, and find. /// /// The keys are identified by their key names. @@ -245,18 +244,18 @@ private: /// we may have to revisit the design. class TSIGKeyRing { public: - /// Result codes of various public methods of \c TSIGKeyRing + /// Result codes of various public methods of TSIGKeyRing enum Result { - SUCCESS = 0, ///< The operation is successful. - EXIST = 1, ///< A key is already stored in \c TSIGKeyRing. - NOTFOUND = 2 ///< The specified key is not found in \c TSIGKeyRing. + SUCCESS = 0, // The operation is successful. + EXIST = 1, // A key is already stored in TSIGKeyRing. + NOTFOUND = 2 // The specified key is not found in TSIGKeyRing. }; - /// \brief A helper structure to represent the search result of + /// @brief A helper structure to represent the search result of /// <code>TSIGKeyRing::find()</code>. /// /// This is a straightforward pair of the result code and a pointer - /// to the found key to represent the result of \c find(). + /// to the found key to represent the result of find(). /// We use this in order to avoid overloading the return value for both /// the result code ("success" or "not found") and the found object, /// i.e., avoid using null to mean "not found", etc. @@ -265,7 +264,7 @@ public: /// convenience we allow the applications to refer to the members /// directly. /// - /// See the description of \c find() for the semantics of the member + /// See the description of find() for the semantics of the member /// variables. struct FindResult { FindResult(Result param_code, const TSIGKey* param_key) : @@ -276,10 +275,9 @@ public: }; /// - /// \name Constructors and Destructor. + /// @brief Constructors and Destructor. /// - /// \b Note: - /// The copy constructor and the assignment operator are + /// @note The copy constructor and the assignment operator are /// intentionally defined as private, making this class non copyable. /// There is no technical reason why this class cannot be copied, /// but since the key ring can potentially have a large number of keys, @@ -293,21 +291,21 @@ private: TSIGKeyRing(const TSIGKeyRing& source); TSIGKeyRing& operator=(const TSIGKeyRing& source); public: - /// \brief The default constructor. + /// @brief The default constructor. /// /// This constructor never throws an exception. TSIGKeyRing(); - /// The destructor. + /// @brief The destructor. ~TSIGKeyRing(); //@} - /// Return the number of keys stored in the \c TSIGKeyRing. + /// @brief Return the number of keys stored in the TSIGKeyRing. /// /// This method never throws an exception. unsigned int size() const; - /// Add a \c TSIGKey to the \c TSIGKeyRing. + /// @brief Add a TSIGKey to the TSIGKeyRing. /// /// This method will create a local copy of the given key, so the caller /// does not have to keep owning it. @@ -316,65 +314,64 @@ public: /// exception will be thrown. /// This method never throws an exception otherwise. /// - /// \param key A \c TSIGKey to be added. - /// \return \c SUCCESS If the key is successfully added to the key ring. - /// \return \c EXIST The key ring already stores a key whose name is - /// identical to that of \c key. + /// @param key A TSIGKey to be added. + /// @return SUCCESS if the key is successfully added to the key ring or + /// EXIST if the key ring already stores a key whose name is identical to + /// that of key. Result add(const TSIGKey& key); - /// Remove a \c TSIGKey for the given name from the \c TSIGKeyRing. + /// Remove a TSIGKey for the given name from the TSIGKeyRing. /// /// This method never throws an exception. /// - /// \param key_name The name of the key to be removed. - /// \return \c SUCCESS If the key is successfully removed from the key - /// ring. - /// \return \c NOTFOUND The key ring does not store the key that matches - /// \c key_name. + /// @param key_name The name of the key to be removed. + /// @return SUCCESS if the key is successfully removed from the key + /// ring or NOTFOUND if the key ring does not store the key that matches + /// key_name. Result remove(const Name& key_name); - /// Find a \c TSIGKey for the given name in the \c TSIGKeyRing. + /// Find a TSIGKey for the given name in the TSIGKeyRing. /// - /// It searches the internal storage for a \c TSIGKey whose name is - /// \c key_name. - /// It returns the result in the form of a \c FindResult + /// It searches the internal storage for a TSIGKey whose name is + /// key_name. + /// It returns the result in the form of a FindResult /// object as follows: - /// - \c code: \c SUCCESS if a key is found; otherwise \c NOTFOUND. - /// - \c key: A pointer to the found \c TSIGKey object if one is found; + /// - code: SUCCESS if a key is found; otherwise NOTFOUND. + /// - key: A pointer to the found TSIGKey object if one is found; /// otherwise null. /// - /// The pointer returned in the \c FindResult object is only valid until + /// The pointer returned in the FindResult object is only valid until /// the corresponding key is removed from the key ring. /// The caller must ensure that the key is held in the key ring while /// it needs to refer to it, or it must make a local copy of the key. /// /// This method never throws an exception. /// - /// \param key_name The name of the key to be found. - /// \return A \c FindResult object enclosing the search result (see above). + /// @param key_name The name of the key to be found. + /// @return A FindResult object enclosing the search result (see above). FindResult find(const Name& key_name) const; - /// Find a \c TSIGKey for the given name in the \c TSIGKeyRing. + /// Find a TSIGKey for the given name in the TSIGKeyRing. /// - /// It searches the internal storage for a \c TSIGKey whose name is - /// \c key_name and that uses the hash algorithm identified by - /// \c algorithm_name. - /// It returns the result in the form of a \c FindResult + /// It searches the internal storage for a TSIGKey whose name is + /// key_name and that uses the hash algorithm identified by + /// algorithm_name. + /// It returns the result in the form of a FindResult /// object as follows: - /// - \c code: \c SUCCESS if a key is found; otherwise \c NOTFOUND. - /// - \c key: A pointer to the found \c TSIGKey object if one is found; + /// - code: SUCCESS if a key is found; otherwise NOTFOUND. + /// - key: A pointer to the found TSIGKey object if one is found; /// otherwise null. /// - /// The pointer returned in the \c FindResult object is only valid until + /// The pointer returned in the FindResult object is only valid until /// the corresponding key is removed from the key ring. /// The caller must ensure that the key is held in the key ring while /// it needs to refer to it, or it must make a local copy of the key. /// /// This method never throws an exception. /// - /// \param key_name The name of the key to be found. - /// \param algorithm_name The name of the algorithm of the found key. - /// \return A \c FindResult object enclosing the search result (see above). + /// @param key_name The name of the key to be found. + /// @param algorithm_name The name of the algorithm of the found key. + /// @return A FindResult object enclosing the search result (see above). FindResult find(const Name& key_name, const Name& algorithm_name) const; private: diff --git a/src/lib/eval/tests/Makefile.am b/src/lib/eval/tests/Makefile.am index 13ba09715b..b053b54726 100644 --- a/src/lib/eval/tests/Makefile.am +++ b/src/lib/eval/tests/Makefile.am @@ -37,6 +37,7 @@ libeval_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la libeval_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la libeval_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la libeval_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la +libeval_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la libeval_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la libeval_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libeval_unittests_LDADD += $(CRYPTO_LIBS) $(LOG4CPLUS_LIBS) diff --git a/src/lib/eval/tests/run_unittests.cc b/src/lib/eval/tests/run_unittests.cc index 08f04d1ba9..561038b997 100644 --- a/src/lib/eval/tests/run_unittests.cc +++ b/src/lib/eval/tests/run_unittests.cc @@ -6,16 +6,14 @@ #include <config.h> -#include <log/logger_support.h> - #include <gtest/gtest.h> +#include <util/unittests/run_all.h> +#include <log/logger_support.h> + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - - int result = RUN_ALL_TESTS(); - - return (result); + return (isc::util::unittests::run_all()); } diff --git a/src/lib/exceptions/exceptions.h b/src/lib/exceptions/exceptions.h index 0f89159988..0cd982a573 100644 --- a/src/lib/exceptions/exceptions.h +++ b/src/lib/exceptions/exceptions.h @@ -258,7 +258,3 @@ public: } #endif // EXCEPTIONS_H - -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/hooks/tests/run_unittests.cc b/src/lib/hooks/tests/run_unittests.cc index cd6fc2bf31..cf3f2040f2 100644 --- a/src/lib/hooks/tests/run_unittests.cc +++ b/src/lib/hooks/tests/run_unittests.cc @@ -6,11 +6,11 @@ #include <config.h> -#include <log/logger_support.h> -#include <util/unittests/run_all.h> - #include <gtest/gtest.h> +#include <util/unittests/run_all.h> +#include <log/logger_support.h> + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); diff --git a/src/lib/http/tests/Makefile.am b/src/lib/http/tests/Makefile.am index 5b2b2a0e74..c8005e25a9 100644 --- a/src/lib/http/tests/Makefile.am +++ b/src/lib/http/tests/Makefile.am @@ -67,6 +67,7 @@ libhttp_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la libhttp_unittests_LDADD += $(top_builddir)/src/lib/asiolink/testutils/libasiolinktest.la libhttp_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la libhttp_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la +libhttp_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la libhttp_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la libhttp_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libhttp_unittests_LDADD += $(LOG4CPLUS_LIBS) diff --git a/src/lib/http/tests/run_unittests.cc b/src/lib/http/tests/run_unittests.cc index 17255dcc22..63da3739f8 100644 --- a/src/lib/http/tests/run_unittests.cc +++ b/src/lib/http/tests/run_unittests.cc @@ -6,16 +6,14 @@ #include <config.h> -#include <log/logger_support.h> -#include <http/http_log.h> #include <gtest/gtest.h> +#include <util/unittests/run_all.h> +#include <log/logger_support.h> + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - - int result = RUN_ALL_TESTS(); - - return (result); + return (isc::util::unittests::run_all()); } diff --git a/src/lib/log/Makefile.am b/src/lib/log/Makefile.am index 4ad294625b..78a7ffa743 100644 --- a/src/lib/log/Makefile.am +++ b/src/lib/log/Makefile.am @@ -37,8 +37,7 @@ EXTRA_DIST = logging.dox EXTRA_DIST += logimpl_messages.mes EXTRA_DIST += log_messages.mes -# Note: the ordering matters: -Wno-... must follow -Wextra (defined in -# KEA_CXXFLAGS) +# Note: the ordering matters: -Wno-... must follow -Wextra (defined in KEA_CXXFLAGS) libkea_log_la_CXXFLAGS = $(AM_CXXFLAGS) if USE_GXX libkea_log_la_CXXFLAGS += -Wno-unused-parameter -Wno-deprecated-declarations diff --git a/src/lib/log/compiler/message.cc b/src/lib/log/compiler/message.cc index 81f408742b..981f7385bb 100644 --- a/src/lib/log/compiler/message.cc +++ b/src/lib/log/compiler/message.cc @@ -33,6 +33,7 @@ using namespace std; using namespace isc::log; +using namespace isc::util; using namespace isc::util::file; /// \file log/compiler/message.cc @@ -98,7 +99,7 @@ sentinel(Path& file) { string name = file.stem(); string ext = file.extension(); string sentinel_text = name + "_" + ext.substr(1); - isc::util::str::uppercase(sentinel_text); + str::uppercase(sentinel_text); return (sentinel_text); } @@ -175,7 +176,7 @@ splitNamespace(string ns) { // ... and return the vector of namespace components split on the single // colon. - return (isc::util::str::tokens(ns, ":")); + return (str::tokens(ns, ":")); } /// \brief Write Opening Namespace(s) diff --git a/src/lib/log/message_reader.cc b/src/lib/log/message_reader.cc index 6885805031..11da719a08 100644 --- a/src/lib/log/message_reader.cc +++ b/src/lib/log/message_reader.cc @@ -18,6 +18,7 @@ #include <log/message_reader.h> #include <util/str.h> +using namespace isc::util; using namespace std; namespace { @@ -71,7 +72,7 @@ void MessageReader::processLine(const string& line, MessageReader::Mode mode) { // Get rid of leading and trailing spaces - string text = isc::util::str::trim(line); + string text(str::trim(line)); if (text.empty()) { ; // Ignore blank lines @@ -96,14 +97,14 @@ MessageReader::parseDirective(const std::string& text) { // Break into tokens - vector<string> tokens = isc::util::str::tokens(text); + vector<string> tokens(str::tokens(text)); // Uppercase directive and branch on valid ones - isc::util::str::uppercase(tokens[0]); - if (tokens[0] == string("$PREFIX")) { + str::uppercase(tokens[0]); + if (tokens[0] == "$PREFIX") { parsePrefix(tokens); - } else if (tokens[0] == string("$NAMESPACE")) { + } else if (tokens[0] == "$NAMESPACE") { parseNamespace(tokens); } else { @@ -227,7 +228,7 @@ MessageReader::parseMessage(const std::string& text, MessageReader::Mode mode) { } // Strip off the introducer and any leading space after that. - string message_line = isc::util::str::trim(text.substr(1)); + string message_line = str::trim(text.substr(1)); // Look for the first delimiter. size_t first_delim = message_line.find_first_of(delimiters); @@ -249,7 +250,7 @@ MessageReader::parseMessage(const std::string& text, MessageReader::Mode mode) { LOG_INVALID_MESSAGE_ID, ident, lineno_); } } - isc::util::str::uppercase(ident); + str::uppercase(ident); // Locate the start of the message text size_t first_text = message_line.find_first_not_of(delimiters, first_delim); diff --git a/src/lib/mysql/tests/Makefile.am b/src/lib/mysql/tests/Makefile.am index 2c0053c4c8..8946e5f5dc 100644 --- a/src/lib/mysql/tests/Makefile.am +++ b/src/lib/mysql/tests/Makefile.am @@ -35,6 +35,7 @@ libmysql_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la libmysql_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la libmysql_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la libmysql_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la +libmysql_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la libmysql_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la libmysql_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libmysql_unittests_LDADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(GTEST_LDADD) diff --git a/src/lib/mysql/tests/run_unittests.cc b/src/lib/mysql/tests/run_unittests.cc index 4e83d4bd6c..1ccf6d1503 100644 --- a/src/lib/mysql/tests/run_unittests.cc +++ b/src/lib/mysql/tests/run_unittests.cc @@ -6,15 +6,14 @@ #include <config.h> -#include <log/logger_support.h> #include <gtest/gtest.h> +#include <util/unittests/run_all.h> +#include <log/logger_support.h> + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - - int result = RUN_ALL_TESTS(); - - return (result); + return (isc::util::unittests::run_all()); } diff --git a/src/lib/pgsql/tests/Makefile.am b/src/lib/pgsql/tests/Makefile.am index be8b932e4e..52b906de8b 100644 --- a/src/lib/pgsql/tests/Makefile.am +++ b/src/lib/pgsql/tests/Makefile.am @@ -33,6 +33,7 @@ libpgsql_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la libpgsql_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la libpgsql_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la libpgsql_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la +libpgsql_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la libpgsql_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la libpgsql_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libpgsql_unittests_LDADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(GTEST_LDADD) diff --git a/src/lib/pgsql/tests/run_unittests.cc b/src/lib/pgsql/tests/run_unittests.cc index 4e83d4bd6c..1ccf6d1503 100644 --- a/src/lib/pgsql/tests/run_unittests.cc +++ b/src/lib/pgsql/tests/run_unittests.cc @@ -6,15 +6,14 @@ #include <config.h> -#include <log/logger_support.h> #include <gtest/gtest.h> +#include <util/unittests/run_all.h> +#include <log/logger_support.h> + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - - int result = RUN_ALL_TESTS(); - - return (result); + return (isc::util::unittests::run_all()); } diff --git a/src/lib/process/cfgrpt/tests/Makefile.am b/src/lib/process/cfgrpt/tests/Makefile.am index 74bdc4377f..f201da92bc 100644 --- a/src/lib/process/cfgrpt/tests/Makefile.am +++ b/src/lib/process/cfgrpt/tests/Makefile.am @@ -20,7 +20,12 @@ run_unittests_SOURCES = config_report_unittests.cc run_unittests.cc run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) run_unittests_LDADD = $(top_builddir)/src/lib/process/cfgrpt/libcfgrpt.la -run_unittests_LDADD += $(GTEST_LDADD) +run_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la +run_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la +run_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la +run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la +run_unittests_LDADD += $(LOG4CPLUS_LIBS) +run_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD) endif diff --git a/src/lib/process/cfgrpt/tests/run_unittests.cc b/src/lib/process/cfgrpt/tests/run_unittests.cc index feb0d8e6b7..c4e1d42bc9 100644 --- a/src/lib/process/cfgrpt/tests/run_unittests.cc +++ b/src/lib/process/cfgrpt/tests/run_unittests.cc @@ -8,11 +8,12 @@ #include <gtest/gtest.h> +#include <util/unittests/run_all.h> +#include <log/logger_support.h> + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); - - int result = RUN_ALL_TESTS(); - - return (result); + isc::log::initLogger(); + return (isc::util::unittests::run_all()); } diff --git a/src/lib/process/tests/run_unittests.cc b/src/lib/process/tests/run_unittests.cc index a7c1f68dce..5937bfd518 100644 --- a/src/lib/process/tests/run_unittests.cc +++ b/src/lib/process/tests/run_unittests.cc @@ -7,17 +7,19 @@ #include <config.h> #include <log/logger_support.h> -#include <process/d_log.h> + #include <gtest/gtest.h> int main(int argc, char* argv[]) { + ::testing::InitGoogleTest(&argc, argv); + + // See the documentation of the KEA_* environment variables in + // src/lib/log/README for info on how to tweak logging isc::log::initLogger(); - // Override --localstatedir value for PID files setenv("KEA_PIDFILE_DIR", TEST_DATA_BUILDDIR, 1); - int result = RUN_ALL_TESTS(); return (result); diff --git a/src/lib/stats/tests/Makefile.am b/src/lib/stats/tests/Makefile.am index 138a657989..e041a3c7e1 100644 --- a/src/lib/stats/tests/Makefile.am +++ b/src/lib/stats/tests/Makefile.am @@ -28,6 +28,7 @@ libstats_unittests_LDADD = $(top_builddir)/src/lib/stats/libkea-stats.la libstats_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la libstats_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la libstats_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la +libstats_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la libstats_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la libstats_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libstats_unittests_LDADD += $(LOG4CPLUS_LIBS) $(GTEST_LDADD) $(BOOST_LIBS) diff --git a/src/lib/stats/tests/run_unittests.cc b/src/lib/stats/tests/run_unittests.cc index 9d621ae1fa..561038b997 100644 --- a/src/lib/stats/tests/run_unittests.cc +++ b/src/lib/stats/tests/run_unittests.cc @@ -8,11 +8,12 @@ #include <gtest/gtest.h> +#include <util/unittests/run_all.h> +#include <log/logger_support.h> + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); - - int result = RUN_ALL_TESTS(); - - return (result); + isc::log::initLogger(); + return (isc::util::unittests::run_all()); } diff --git a/src/lib/tcp/tests/Makefile.am b/src/lib/tcp/tests/Makefile.am index fd06ef4f21..492c6272c7 100644 --- a/src/lib/tcp/tests/Makefile.am +++ b/src/lib/tcp/tests/Makefile.am @@ -46,8 +46,7 @@ run_unittests_LDADD += $(GTEST_LDADD) run_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS) -# Note: the ordering matters: -Wno-... must follow -Wextra (defined in -# KEA_CXXFLAGS) +# Note: the ordering matters: -Wno-... must follow -Wextra (defined in KEA_CXXFLAGS) run_unittests_CXXFLAGS = $(AM_CXXFLAGS) if USE_GXX run_unittests_CXXFLAGS += -Wno-unused-parameter -Wno-unused-private-field diff --git a/src/lib/tcp/tests/run_unittests.cc b/src/lib/tcp/tests/run_unittests.cc index 55589a6632..64645f6774 100644 --- a/src/lib/tcp/tests/run_unittests.cc +++ b/src/lib/tcp/tests/run_unittests.cc @@ -5,16 +5,15 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include <config.h> -#include <log/logger_support.h> #include <gtest/gtest.h> +#include <util/unittests/run_all.h> +#include <log/logger_support.h> + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); isc::log::initLogger(); - - int result = RUN_ALL_TESTS(); - - return (result); + return (isc::util::unittests::run_all()); } diff --git a/src/lib/util/io/fd_share.cc b/src/lib/util/io/fd_share.cc index 6edffd301e..7ab265953a 100644 --- a/src/lib/util/io/fd_share.cc +++ b/src/lib/util/io/fd_share.cc @@ -161,6 +161,6 @@ send_fd(const int sock, const int fd) { return (ret >= 0 ? 0 : FD_SYSTEM_ERROR); } -} // End for namespace io -} // End for namespace util -} // End for namespace isc +} // namespace io +} // namespace util +} // namespace isc diff --git a/src/lib/util/io/fd_share.h b/src/lib/util/io/fd_share.h index 36d0d5fbc3..600606f820 100644 --- a/src/lib/util/io/fd_share.h +++ b/src/lib/util/io/fd_share.h @@ -4,8 +4,8 @@ // 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/. -#ifndef FD_SHARE_H_ -#define FD_SHARE_H_ +#ifndef FD_SHARE_H +#define FD_SHARE_H /** * \file fd_share.h @@ -50,12 +50,8 @@ int recv_fd(const int sock); */ int send_fd(const int sock, const int fd); -} // End for namespace io -} // End for namespace util -} // End for namespace isc +} // namespace io +} // namespace util +} // namespace isc -#endif - -// Local Variables: -// mode: c++ -// End: +#endif // FD_SHARE_H diff --git a/src/lib/util/io/sockaddr_util.h b/src/lib/util/io/sockaddr_util.h index 1cb31f2028..767bb0db16 100644 --- a/src/lib/util/io/sockaddr_util.h +++ b/src/lib/util/io/sockaddr_util.h @@ -70,7 +70,3 @@ convertSockAddr(struct sockaddr* sa) { } #endif // SOCKADDR_UTIL_H - -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/util/io/socketsession.h b/src/lib/util/io/socketsession.h index 52e33de64d..6c0fac74bd 100644 --- a/src/lib/util/io/socketsession.h +++ b/src/lib/util/io/socketsession.h @@ -489,7 +489,3 @@ private: } #endif // SOCKETSESSION_H - -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/util/memory_segment.h b/src/lib/util/memory_segment.h index c9ae97f9de..4edae4a8e4 100644 --- a/src/lib/util/memory_segment.h +++ b/src/lib/util/memory_segment.h @@ -327,7 +327,3 @@ protected: } // namespace isc #endif // MEMORY_SEGMENT_H - -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/util/memory_segment_local.h b/src/lib/util/memory_segment_local.h index 2c0ee53db6..0a037295a3 100644 --- a/src/lib/util/memory_segment_local.h +++ b/src/lib/util/memory_segment_local.h @@ -94,7 +94,3 @@ private: } // namespace isc #endif // MEMORY_SEGMENT_LOCAL_H - -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/util/python/gen_wiredata.py.in b/src/lib/util/python/gen_wiredata.py.in index f1b51f3552..c446841101 100644 --- a/src/lib/util/python/gen_wiredata.py.in +++ b/src/lib/util/python/gen_wiredata.py.in @@ -841,49 +841,6 @@ class SSHFP(RR): self.fingerprint)) f.write('%02x %02x %s\n' % (self.algorithm, self.fingerprint_type, self.fingerprint)) -class MINFO(RR): - '''Implements rendering MINFO RDATA in the test data format. - - Configurable parameters are as follows (see the description of the - same name of attribute for the default value): - - rmailbox (string): The rmailbox field. - - emailbox (string): The emailbox field. - These strings must be interpreted as a valid domain name. - ''' - rmailbox = 'rmailbox.example.com' - emailbox = 'emailbox.example.com' - def dump(self, f): - rmailbox_wire = encode_name(self.rmailbox) - emailbox_wire = encode_name(self.emailbox) - if self.rdlen is None: - self.rdlen = (len(rmailbox_wire) + len(emailbox_wire)) / 2 - else: - self.rdlen = int(self.rdlen) - self.dump_header(f, self.rdlen) - f.write('# RMAILBOX=%s EMAILBOX=%s\n' % (self.rmailbox, self.emailbox)) - f.write('%s %s\n' % (rmailbox_wire, emailbox_wire)) - -class AFSDB(RR): - '''Implements rendering AFSDB RDATA in the test data format. - - Configurable parameters are as follows (see the description of the - same name of attribute for the default value): - - subtype (16 bit int): The subtype field. - - server (string): The server field. - The string must be interpreted as a valid domain name. - ''' - subtype = 1 - server = 'afsdb.example.com' - def dump(self, f): - server_wire = encode_name(self.server) - if self.rdlen is None: - self.rdlen = 2 + len(server_wire) / 2 - else: - self.rdlen = int(self.rdlen) - self.dump_header(f, self.rdlen) - f.write('# SUBTYPE=%d SERVER=%s\n' % (self.subtype, self.server)) - f.write('%04x %s\n' % (self.subtype, server_wire)) - class CAA(RR): '''Implements rendering CAA RDATA in the test data format. @@ -1382,6 +1339,49 @@ class TSIG(RR): f.write('%04x%s\n' % (other_len, ' ' + other_data if len(other_data) > 0 else '')) +class MINFO(RR): + '''Implements rendering MINFO RDATA in the test data format. + + Configurable parameters are as follows (see the description of the + same name of attribute for the default value): + - rmailbox (string): The rmailbox field. + - emailbox (string): The emailbox field. + These strings must be interpreted as a valid domain name. + ''' + rmailbox = 'rmailbox.example.com' + emailbox = 'emailbox.example.com' + def dump(self, f): + rmailbox_wire = encode_name(self.rmailbox) + emailbox_wire = encode_name(self.emailbox) + if self.rdlen is None: + self.rdlen = (len(rmailbox_wire) + len(emailbox_wire)) / 2 + else: + self.rdlen = int(self.rdlen) + self.dump_header(f, self.rdlen) + f.write('# RMAILBOX=%s EMAILBOX=%s\n' % (self.rmailbox, self.emailbox)) + f.write('%s %s\n' % (rmailbox_wire, emailbox_wire)) + +class AFSDB(RR): + '''Implements rendering AFSDB RDATA in the test data format. + + Configurable parameters are as follows (see the description of the + same name of attribute for the default value): + - subtype (16 bit int): The subtype field. + - server (string): The server field. + The string must be interpreted as a valid domain name. + ''' + subtype = 1 + server = 'afsdb.example.com' + def dump(self, f): + server_wire = encode_name(self.server) + if self.rdlen is None: + self.rdlen = 2 + len(server_wire) / 2 + else: + self.rdlen = int(self.rdlen) + self.dump_header(f, self.rdlen) + f.write('# SUBTYPE=%d SERVER=%s\n' % (self.subtype, self.server)) + f.write('%04x %s\n' % (self.subtype, server_wire)) + # Build section-class mapping config_param = { 'name' : (Name, {}), 'header' : (DNSHeader, header_xtables), diff --git a/src/lib/util/tests/buffer_unittest.cc b/src/lib/util/tests/buffer_unittest.cc index 1c985713b1..66c43e8f21 100644 --- a/src/lib/util/tests/buffer_unittest.cc +++ b/src/lib/util/tests/buffer_unittest.cc @@ -42,110 +42,218 @@ protected: const uint8_t BufferTest::testdata[5] = {1, 2, 3, 4, 5}; +TEST_F(BufferTest, outputBufferClear) { + obuffer.writeData(testdata, sizeof(testdata)); + obuffer.clear(); + ASSERT_EQ(0, obuffer.getLength()); + ASSERT_FALSE(obuffer.getData()); +} + +TEST_F(BufferTest, outputBufferCopy) { + ASSERT_NO_THROW({ + obuffer.writeData(testdata, sizeof(testdata)); + + OutputBuffer copy(obuffer); + ASSERT_EQ(sizeof(testdata), copy.getLength()); + ASSERT_NE(obuffer.getData(), copy.getData()); + for (size_t i = 0; i < sizeof(testdata); ++i) { + ASSERT_EQ(testdata[i], copy[i]); + if (i + 1 < sizeof(testdata)) { + obuffer.writeUint16At(0, i); + } + ASSERT_EQ(testdata[i], copy[i]); + } + obuffer.clear(); + ASSERT_EQ(sizeof(testdata), copy.getLength()); + }); +} + +TEST_F(BufferTest, outputEmptyBufferCopy) { + ASSERT_NO_THROW({ + OutputBuffer copy(obuffer); + ASSERT_EQ(0, copy.getLength()); + ASSERT_FALSE(copy.getData()); + }); +} + +TEST_F(BufferTest, outputBufferAssign) { + ASSERT_NO_THROW({ + OutputBuffer another(0); + another.clear(); + obuffer.writeData(testdata, sizeof(testdata)); + + another = obuffer; + ASSERT_EQ(sizeof(testdata), another.getLength()); + ASSERT_NE(obuffer.getData(), another.getData()); + for (size_t i = 0; i < sizeof(testdata); ++i) { + ASSERT_EQ(testdata[i], another[i]); + if (i + 1 < sizeof(testdata)) { + obuffer.writeUint16At(0, i); + } + ASSERT_EQ(testdata[i], another[i]); + } + obuffer.clear(); + ASSERT_EQ(sizeof(testdata), another.getLength()); + }); +} + +TEST_F(BufferTest, outputEmptyBufferAssign) { + OutputBuffer copy(0); + ASSERT_NO_THROW(copy = obuffer;); + ASSERT_EQ(0, copy.getLength()); + ASSERT_EQ(0, copy.getData()); +} + +// Check assign to self doesn't break stuff +TEST_F(BufferTest, outputBufferAssignSelf) { + ASSERT_NO_THROW(obuffer = obuffer); +} + +TEST_F(BufferTest, inputBufferException) { + ASSERT_THROW(ibuffer.setPosition(6), isc::OutOfRange); + + ibuffer.setPosition(sizeof(testdata)); + ASSERT_THROW(ibuffer.peekUint8(), isc::OutOfRange); + ASSERT_THROW(ibuffer.readUint8(), isc::OutOfRange); + + ibuffer.setPosition(sizeof(testdata) - 1); + ASSERT_THROW(ibuffer.peekUint16(), isc::OutOfRange); + ASSERT_THROW(ibuffer.readUint16(), isc::OutOfRange); + + ibuffer.setPosition(sizeof(testdata) - 3); + ASSERT_THROW(ibuffer.peekUint32(), isc::OutOfRange); + ASSERT_THROW(ibuffer.readUint32(), isc::OutOfRange); + + ibuffer.setPosition(sizeof(testdata) - 4); + ASSERT_THROW(ibuffer.peekData(vdata, sizeof(vdata)), isc::OutOfRange); + ASSERT_THROW(ibuffer.readData(vdata, sizeof(vdata)), isc::OutOfRange); + ASSERT_THROW(ibuffer.peekVector(datav, sizeof(vdata)), isc::OutOfRange); + ASSERT_THROW(ibuffer.readVector(datav, sizeof(vdata)), isc::OutOfRange); +} + +TEST_F(BufferTest, outputBufferExtend) { + ASSERT_EQ(0, obuffer.getCapacity()); + ASSERT_EQ(0, obuffer.getLength()); + obuffer.writeUint8(10); + ASSERT_LT(0, obuffer.getCapacity()); + ASSERT_EQ(1, obuffer.getLength()); +} + +TEST_F(BufferTest, outputBufferSkip) { + obuffer.skip(4); + ASSERT_EQ(4, obuffer.getLength()); + + obuffer.skip(2); + ASSERT_EQ(6, obuffer.getLength()); +} + +TEST_F(BufferTest, outputBufferTrim) { + obuffer.writeData(testdata, sizeof(testdata)); + ASSERT_EQ(5, obuffer.getLength()); + + obuffer.trim(1); + ASSERT_EQ(4, obuffer.getLength()); + + obuffer.trim(2); + ASSERT_EQ(2, obuffer.getLength()); + + ASSERT_THROW(obuffer.trim(3), OutOfRange); +} + TEST_F(BufferTest, inputBufferRead) { - EXPECT_EQ(5, ibuffer.getLength()); - EXPECT_EQ(1, ibuffer.peekUint8()); - EXPECT_EQ(0, ibuffer.getPosition()); - EXPECT_EQ(1, ibuffer.readUint8()); - EXPECT_EQ(1, ibuffer.getPosition()); + ASSERT_EQ(5, ibuffer.getLength()); + ASSERT_EQ(1, ibuffer.peekUint8()); + ASSERT_EQ(0, ibuffer.getPosition()); + ASSERT_EQ(1, ibuffer.readUint8()); + ASSERT_EQ(1, ibuffer.getPosition()); data16 = ibuffer.peekUint16(); - EXPECT_EQ(1, ibuffer.getPosition()); - EXPECT_EQ(data16, ibuffer.readUint16()); - EXPECT_EQ((2 << 8) | 3, data16); - EXPECT_EQ(3, ibuffer.getPosition()); + ASSERT_EQ(1, ibuffer.getPosition()); + ASSERT_EQ(data16, ibuffer.readUint16()); + ASSERT_EQ((2 << 8) | 3, data16); + ASSERT_EQ(3, ibuffer.getPosition()); ibuffer.setPosition(1); - EXPECT_EQ(1, ibuffer.getPosition()); + ASSERT_EQ(1, ibuffer.getPosition()); data32 = ibuffer.peekUint32(); - EXPECT_EQ(1, ibuffer.getPosition()); - EXPECT_EQ(data32, ibuffer.readUint32()); - EXPECT_EQ((2 << 24) | (3 << 16) | (4 << 8) | 5, data32); + ASSERT_EQ(1, ibuffer.getPosition()); + ASSERT_EQ(data32, ibuffer.readUint32()); + ASSERT_EQ((2 << 24) | (3 << 16) | (4 << 8) | 5, data32); ibuffer.setPosition(0); memset(vdata, 0, sizeof(vdata)); ibuffer.peekData(vdata, sizeof(vdata)); - EXPECT_EQ(0, memcmp(vdata, testdata, sizeof(testdata))); - EXPECT_EQ(0, ibuffer.getPosition()); + ASSERT_EQ(0, memcmp(vdata, testdata, sizeof(testdata))); + ASSERT_EQ(0, ibuffer.getPosition()); memset(vdata, 0, sizeof(vdata)); ibuffer.readData(vdata, sizeof(vdata)); - EXPECT_EQ(0, memcmp(vdata, testdata, sizeof(testdata))); - EXPECT_EQ(sizeof(vdata), ibuffer.getPosition()); + ASSERT_EQ(0, memcmp(vdata, testdata, sizeof(testdata))); + ASSERT_EQ(sizeof(vdata), ibuffer.getPosition()); ibuffer.setPosition(0); datav.clear(); ibuffer.peekVector(datav, sizeof(vdata)); ASSERT_EQ(sizeof(vdata), datav.size()); - EXPECT_EQ(0, memcmp(&vdata[0], testdata, sizeof(testdata))); - EXPECT_EQ(0, ibuffer.getPosition()); + ASSERT_EQ(0, memcmp(&vdata[0], testdata, sizeof(testdata))); + ASSERT_EQ(0, ibuffer.getPosition()); datav.clear(); ibuffer.readVector(datav, sizeof(vdata)); ASSERT_EQ(sizeof(vdata), datav.size()); - EXPECT_EQ(0, memcmp(&vdata[0], testdata, sizeof(testdata))); - EXPECT_EQ(sizeof(vdata), ibuffer.getPosition()); + ASSERT_EQ(0, memcmp(&vdata[0], testdata, sizeof(testdata))); + ASSERT_EQ(sizeof(vdata), ibuffer.getPosition()); } -TEST_F(BufferTest, inputBufferException) { - EXPECT_THROW(ibuffer.setPosition(6), isc::OutOfRange); - - ibuffer.setPosition(sizeof(testdata)); - EXPECT_THROW(ibuffer.peekUint8(), isc::OutOfRange); - EXPECT_THROW(ibuffer.readUint8(), isc::OutOfRange); - - ibuffer.setPosition(sizeof(testdata) - 1); - EXPECT_THROW(ibuffer.peekUint16(), isc::OutOfRange); - EXPECT_THROW(ibuffer.readUint16(), isc::OutOfRange); - - ibuffer.setPosition(sizeof(testdata) - 3); - EXPECT_THROW(ibuffer.peekUint32(), isc::OutOfRange); - EXPECT_THROW(ibuffer.readUint32(), isc::OutOfRange); - - ibuffer.setPosition(sizeof(testdata) - 4); - EXPECT_THROW(ibuffer.peekData(vdata, sizeof(vdata)), isc::OutOfRange); - EXPECT_THROW(ibuffer.readData(vdata, sizeof(vdata)), isc::OutOfRange); - EXPECT_THROW(ibuffer.peekVector(datav, sizeof(vdata)), isc::OutOfRange); - EXPECT_THROW(ibuffer.readVector(datav, sizeof(vdata)), isc::OutOfRange); +TEST_F(BufferTest, outputBufferReadAt) { + obuffer.writeData(testdata, sizeof(testdata)); + for (size_t i = 0; i < sizeof(testdata); ++i) { + ASSERT_EQ(testdata[i], obuffer[i]); + } + ASSERT_THROW(obuffer[sizeof(testdata)], isc::OutOfRange); } -TEST_F(BufferTest, outputBufferExtend) { - EXPECT_EQ(0, obuffer.getCapacity()); - EXPECT_EQ(0, obuffer.getLength()); - obuffer.writeUint8(10); - EXPECT_LT(0, obuffer.getCapacity()); - EXPECT_EQ(1, obuffer.getLength()); +TEST_F(BufferTest, inputBufferReadVectorChunks) { + std::vector<uint8_t> vec; + + // check that vector can read the whole buffer + ibuffer.readVector(vec, 3); + ASSERT_EQ(3, vec.size()); + ASSERT_EQ(0, memcmp(&vec[0], testdata, 3)); + ASSERT_NO_THROW(ibuffer.readVector(vec, 2)); + ASSERT_EQ(2, vec.size()); + ASSERT_EQ(0, memcmp(&vec[0], &testdata[3], 2)); } TEST_F(BufferTest, outputBufferWrite) { obuffer.writeUint8(1); expected_size += sizeof(uint8_t); - EXPECT_EQ(expected_size, obuffer.getLength()); + ASSERT_EQ(expected_size, obuffer.getLength()); const uint8_t* cp = obuffer.getData(); - EXPECT_EQ(1, *cp); + ASSERT_EQ(1, *cp); obuffer.writeUint16(data16); expected_size += sizeof(data16); cp = obuffer.getData(); - EXPECT_EQ(expected_size, obuffer.getLength()); - EXPECT_EQ(2, *(cp + 1)); - EXPECT_EQ(3, *(cp + 2)); + ASSERT_EQ(expected_size, obuffer.getLength()); + ASSERT_EQ(2, *(cp + 1)); + ASSERT_EQ(3, *(cp + 2)); obuffer.writeUint32(data32); expected_size += sizeof(data32); cp = obuffer.getData(); - EXPECT_EQ(expected_size, obuffer.getLength()); - EXPECT_EQ(4, *(cp + 3)); - EXPECT_EQ(5, *(cp + 4)); - EXPECT_EQ(6, *(cp + 5)); - EXPECT_EQ(7, *(cp + 6)); + ASSERT_EQ(expected_size, obuffer.getLength()); + ASSERT_EQ(4, *(cp + 3)); + ASSERT_EQ(5, *(cp + 4)); + ASSERT_EQ(6, *(cp + 5)); + ASSERT_EQ(7, *(cp + 6)); obuffer.writeData(testdata, sizeof(testdata)); expected_size += sizeof(testdata); - EXPECT_EQ(expected_size, obuffer.getLength()); + ASSERT_EQ(expected_size, obuffer.getLength()); cp = obuffer.getData(); - EXPECT_EQ(0, memcmp(cp + 7, testdata, sizeof(testdata))); + ASSERT_EQ(0, memcmp(cp + 7, testdata, sizeof(testdata))); datav = obuffer.getVector(); ASSERT_EQ(expected_size, datav.size()); std::vector<uint8_t> expected = { 1, 2, 3, 4, 5, 6, 7 }; expected.insert(expected.end(), testdata, testdata + sizeof(testdata)); ASSERT_EQ(expected_size, expected.size()); - EXPECT_EQ(0, memcmp(&expected[0], &datav[0], expected_size)); + ASSERT_EQ(0, memcmp(&expected[0], &datav[0], expected_size)); } TEST_F(BufferTest, outputBufferWriteAt) { @@ -154,138 +262,29 @@ TEST_F(BufferTest, outputBufferWriteAt) { // overwrite 2nd byte obuffer.writeUint8At(4, 1); - EXPECT_EQ(expected_size, obuffer.getLength()); // length shouldn't change + ASSERT_EQ(expected_size, obuffer.getLength()); // length shouldn't change const uint8_t* cp = obuffer.getData(); - EXPECT_EQ(4, *(cp + 1)); + ASSERT_EQ(4, *(cp + 1)); // overwrite 2nd and 3rd bytes obuffer.writeUint16At(data16, 1); - EXPECT_EQ(expected_size, obuffer.getLength()); // length shouldn't change + ASSERT_EQ(expected_size, obuffer.getLength()); // length shouldn't change cp = obuffer.getData(); - EXPECT_EQ(2, *(cp + 1)); - EXPECT_EQ(3, *(cp + 2)); + ASSERT_EQ(2, *(cp + 1)); + ASSERT_EQ(3, *(cp + 2)); // overwrite 3rd and 4th bytes obuffer.writeUint16At(data16, 2); - EXPECT_EQ(expected_size, obuffer.getLength()); + ASSERT_EQ(expected_size, obuffer.getLength()); cp = obuffer.getData(); - EXPECT_EQ(2, *(cp + 2)); - EXPECT_EQ(3, *(cp + 3)); - - EXPECT_THROW(obuffer.writeUint8At(data16, 5), isc::OutOfRange); - EXPECT_THROW(obuffer.writeUint8At(data16, 4), isc::OutOfRange); - EXPECT_THROW(obuffer.writeUint16At(data16, 3), isc::OutOfRange); - EXPECT_THROW(obuffer.writeUint16At(data16, 4), isc::OutOfRange); - EXPECT_THROW(obuffer.writeUint16At(data16, 5), isc::OutOfRange); -} - -TEST_F(BufferTest, outputBufferSkip) { - obuffer.skip(4); - EXPECT_EQ(4, obuffer.getLength()); - - obuffer.skip(2); - EXPECT_EQ(6, obuffer.getLength()); -} - -TEST_F(BufferTest, outputBufferTrim) { - obuffer.writeData(testdata, sizeof(testdata)); - EXPECT_EQ(5, obuffer.getLength()); - - obuffer.trim(1); - EXPECT_EQ(4, obuffer.getLength()); - - obuffer.trim(2); - EXPECT_EQ(2, obuffer.getLength()); - - EXPECT_THROW(obuffer.trim(3), OutOfRange); -} - -TEST_F(BufferTest, outputBufferReadAt) { - obuffer.writeData(testdata, sizeof(testdata)); - for (size_t i = 0; i < sizeof(testdata); ++i) { - EXPECT_EQ(testdata[i], obuffer[i]); - } - EXPECT_THROW(obuffer[sizeof(testdata)], isc::OutOfRange); -} - -TEST_F(BufferTest, outputBufferClear) { - obuffer.writeData(testdata, sizeof(testdata)); - const uint8_t* cp = obuffer.getData(); - obuffer.clear(); - EXPECT_EQ(0, obuffer.getLength()); - EXPECT_FALSE(obuffer.getData()); -} - -TEST_F(BufferTest, outputBufferCopy) { - EXPECT_NO_THROW({ - obuffer.writeData(testdata, sizeof(testdata)); - - OutputBuffer copy(obuffer); - ASSERT_EQ(sizeof(testdata), copy.getLength()); - ASSERT_NE(obuffer.getData(), copy.getData()); - for (size_t i = 0; i < sizeof(testdata); ++i) { - EXPECT_EQ(testdata[i], copy[i]); - if (i + 1 < sizeof(testdata)) { - obuffer.writeUint16At(0, i); - } - EXPECT_EQ(testdata[i], copy[i]); - } - obuffer.clear(); - ASSERT_EQ(sizeof(testdata), copy.getLength()); - }); -} - -TEST_F(BufferTest, outputEmptyBufferCopy) { - EXPECT_NO_THROW({ - OutputBuffer copy(obuffer); - ASSERT_EQ(0, copy.getLength()); - EXPECT_FALSE(copy.getData()); - }); -} - -TEST_F(BufferTest, outputBufferAssign) { - EXPECT_NO_THROW({ - OutputBuffer another(0); - another.clear(); - obuffer.writeData(testdata, sizeof(testdata)); - - another = obuffer; - ASSERT_EQ(sizeof(testdata), another.getLength()); - ASSERT_NE(obuffer.getData(), another.getData()); - for (size_t i = 0; i < sizeof(testdata); ++i) { - EXPECT_EQ(testdata[i], another[i]); - if (i + 1 < sizeof(testdata)) { - obuffer.writeUint16At(0, i); - } - EXPECT_EQ(testdata[i], another[i]); - } - obuffer.clear(); - ASSERT_EQ(sizeof(testdata), another.getLength()); - }); -} - -TEST_F(BufferTest, outputEmptyBufferAssign) { - OutputBuffer copy(0); - EXPECT_NO_THROW(copy = obuffer;); - EXPECT_EQ(0, copy.getLength()); - EXPECT_EQ(0, copy.getData()); -} - -// Check assign to self doesn't break stuff -TEST_F(BufferTest, outputBufferAssignSelf) { - EXPECT_NO_THROW(obuffer = obuffer); -} - -TEST_F(BufferTest, inputBufferReadVectorChunks) { - std::vector<uint8_t> vec; - - // check that vector can read the whole buffer - ibuffer.readVector(vec, 3); - EXPECT_EQ(3, vec.size()); - EXPECT_EQ(0, memcmp(&vec[0], testdata, 3)); - EXPECT_NO_THROW(ibuffer.readVector(vec, 2)); - ASSERT_EQ(2, vec.size()); - EXPECT_EQ(0, memcmp(&vec[0], &testdata[3], 2)); + ASSERT_EQ(2, *(cp + 2)); + ASSERT_EQ(3, *(cp + 3)); + + ASSERT_THROW(obuffer.writeUint8At(data16, 5), isc::OutOfRange); + ASSERT_THROW(obuffer.writeUint8At(data16, 4), isc::OutOfRange); + ASSERT_THROW(obuffer.writeUint16At(data16, 3), isc::OutOfRange); + ASSERT_THROW(obuffer.writeUint16At(data16, 4), isc::OutOfRange); + ASSERT_THROW(obuffer.writeUint16At(data16, 5), isc::OutOfRange); } // Tests whether uint64 can be written properly. @@ -298,15 +297,15 @@ TEST_F(BufferTest, writeUint64) { obuffer.writeUint64(val1); ASSERT_EQ(sizeof(uint64_t), obuffer.getLength()); const uint8_t* cp = obuffer.getData(); - EXPECT_TRUE(cp); - EXPECT_FALSE(memcmp(exp_val1, obuffer.getData(), sizeof(uint64_t))); + ASSERT_TRUE(cp); + ASSERT_FALSE(memcmp(exp_val1, obuffer.getData(), sizeof(uint64_t))); - EXPECT_NO_THROW(obuffer.clear()); + ASSERT_NO_THROW(obuffer.clear()); obuffer.writeUint64(val2); ASSERT_EQ(sizeof(uint64_t), obuffer.getLength()); cp = obuffer.getData(); - EXPECT_TRUE(cp); - EXPECT_FALSE(memcmp(exp_val2, obuffer.getData(), sizeof(uint64_t))); + ASSERT_TRUE(cp); + ASSERT_FALSE(memcmp(exp_val2, obuffer.getData(), sizeof(uint64_t))); } } diff --git a/src/lib/util/tests/memory_segment_common_unittest.h b/src/lib/util/tests/memory_segment_common_unittest.h index 435ff12cd2..c650878d10 100644 --- a/src/lib/util/tests/memory_segment_common_unittest.h +++ b/src/lib/util/tests/memory_segment_common_unittest.h @@ -22,7 +22,3 @@ void checkSegmentNamedAddress(MemorySegment& segment, bool out_of_segment_ok); } } } - -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/util/unittests/interprocess_util.h b/src/lib/util/unittests/interprocess_util.h index 7012f7b270..4e9183a001 100644 --- a/src/lib/util/unittests/interprocess_util.h +++ b/src/lib/util/unittests/interprocess_util.h @@ -18,6 +18,3 @@ unsigned char parentReadState(int fd); } } -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/util/unittests/mock_socketsession.h b/src/lib/util/unittests/mock_socketsession.h index 808cddb399..2fc2bb2d3b 100644 --- a/src/lib/util/unittests/mock_socketsession.h +++ b/src/lib/util/unittests/mock_socketsession.h @@ -146,6 +146,3 @@ private: } // end of isc #endif // UTIL_UNITTESTS_MOCKSOCKETSESSION_H -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/util/unittests/newhook.h b/src/lib/util/unittests/newhook.h index 1fc3eba113..3e818e6289 100644 --- a/src/lib/util/unittests/newhook.h +++ b/src/lib/util/unittests/newhook.h @@ -68,7 +68,3 @@ extern size_t throw_size_on_new; } #endif // UTIL_UNITTESTS_NEWHOOK_H - -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/util/unittests/resource.h b/src/lib/util/unittests/resource.h index dfa44eecdf..328544168b 100644 --- a/src/lib/util/unittests/resource.h +++ b/src/lib/util/unittests/resource.h @@ -25,7 +25,3 @@ void dontCreateCoreDumps(); } // end of namespace isc #endif // UTIL_UNITTESTS_RESOURCE_H - -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/util/unittests/testdata.h b/src/lib/util/unittests/testdata.h index ee7c1c5753..e16b5fc8ff 100644 --- a/src/lib/util/unittests/testdata.h +++ b/src/lib/util/unittests/testdata.h @@ -40,7 +40,3 @@ void openTestData(const char* const datafile, std::ifstream& ifs); } #endif // UTIL_UNITTESTS_TESTDATA_H - -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/util/unittests/textdata.h b/src/lib/util/unittests/textdata.h index ae132cd10f..fada98e3de 100644 --- a/src/lib/util/unittests/textdata.h +++ b/src/lib/util/unittests/textdata.h @@ -89,7 +89,3 @@ matchTextData(const std::string& expected_text, } #endif // UTIL_UNITTESTS_TEXTDATA_H - -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/util/unittests/wiredata.h b/src/lib/util/unittests/wiredata.h index fee555e991..8c4d5ef025 100644 --- a/src/lib/util/unittests/wiredata.h +++ b/src/lib/util/unittests/wiredata.h @@ -31,7 +31,3 @@ void matchWireData(const void* expected_data, std::size_t expected_len, } #endif // UTIL_UNITTESTS_WIREDATA_H - -// Local Variables: -// mode: c++ -// End: diff --git a/src/lib/yang/tests/run_unittests.cc b/src/lib/yang/tests/run_unittests.cc index 24870d1f9a..a689ad06d2 100644 --- a/src/lib/yang/tests/run_unittests.cc +++ b/src/lib/yang/tests/run_unittests.cc @@ -8,14 +8,12 @@ #include <gtest/gtest.h> -#include <log/logger_support.h> #include <util/unittests/run_all.h> +#include <log/logger_support.h> int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); - isc::log::initLogger(); - return (isc::util::unittests::run_all()); } |