From f7c734bbb7b756b09eab1a8d8e9dfd6215e4e95d Mon Sep 17 00:00:00 2001 From: Marcin Siodelski Date: Tue, 6 Dec 2016 17:36:37 +0100 Subject: [PATCH] [5077] Created libkea-http library. --- configure.ac | 2 ++ src/lib/Makefile.am | 2 +- src/lib/http/.gitignore | 3 ++ src/lib/http/Makefile.am | 43 +++++++++++++++++++++++++++++ src/lib/http/http_log.cc | 19 +++++++++++++ src/lib/http/http_log.h | 23 +++++++++++++++ src/lib/http/http_messages.mes | 10 +++++++ src/lib/http/tests/.gitignore | 1 + src/lib/http/tests/Makefile.am | 37 +++++++++++++++++++++++++ src/lib/http/tests/run_unittests.cc | 19 +++++++++++++ 10 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 src/lib/http/.gitignore create mode 100644 src/lib/http/Makefile.am create mode 100644 src/lib/http/http_log.cc create mode 100644 src/lib/http/http_log.h create mode 100644 src/lib/http/http_messages.mes create mode 100644 src/lib/http/tests/.gitignore create mode 100644 src/lib/http/tests/Makefile.am create mode 100644 src/lib/http/tests/run_unittests.cc diff --git a/configure.ac b/configure.ac index 47d6c16359..8e298eb92a 100644 --- a/configure.ac +++ b/configure.ac @@ -1621,6 +1621,8 @@ AC_CONFIG_FILES([compatcheck/Makefile src/lib/hooks/tests/Makefile src/lib/hooks/tests/marker_file.h src/lib/hooks/tests/test_libraries.h + src/lib/http/Makefile + src/lib/http/tests/Makefile src/lib/log/Makefile src/lib/log/compiler/Makefile src/lib/log/interprocess/Makefile diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index dbbdb8f11b..031a3498ab 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -1,3 +1,3 @@ # The following build order must be maintained. SUBDIRS = exceptions util log cryptolink dns cc hooks asiolink testutils dhcp config \ - stats asiodns dhcp_ddns eval dhcpsrv cfgrpt process + stats asiodns dhcp_ddns eval dhcpsrv cfgrpt process http diff --git a/src/lib/http/.gitignore b/src/lib/http/.gitignore new file mode 100644 index 0000000000..4aeda87246 --- /dev/null +++ b/src/lib/http/.gitignore @@ -0,0 +1,3 @@ +/http_messages.cc +/http_messages.h +/s-messages diff --git a/src/lib/http/Makefile.am b/src/lib/http/Makefile.am new file mode 100644 index 0000000000..a0cba70b3e --- /dev/null +++ b/src/lib/http/Makefile.am @@ -0,0 +1,43 @@ +SUBDIRS = . tests + +AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib +AM_CPPFLAGS += $(BOOST_INCLUDES) +AM_CXXFLAGS = $(KEA_CXXFLAGS) + +# Define rule to build logging source files from message file +http_messages.h http_messages.cc: s-messages + +s-messages: http_messages.mes + $(top_builddir)/src/lib/log/compiler/kea-msg-compiler $(top_srcdir)/src/lib/http/http_messages.mes + touch $@ + +# Tell automake that the message files are built as part of the build process +# (so that they are built before the main library is built). +BUILT_SOURCES = http_messages.h http_messages.cc + +# Ensure that the message file is included in the distribution +EXTRA_DIST = http_messages.mes + +# Get rid of generated message files on a clean +CLEANFILES = *.gcno *.gcda http_messages.h http_messages.cc s-messages + +lib_LTLIBRARIES = libkea-http.la +libkea_http_la_SOURCES = http_log.cc http_log.h + +nodist_libkea_http_la_SOURCES = http_messages.cc http_messages.h + +libkea_http_la_CXXFLAGS = $(AM_CXXFLAGS) +libkea_http_la_CPPFLAGS = $(AM_CPPFLAGS) +libkea_http_la_LDFLAGS = $(AM_LDFLAGS) +libkea_http_la_LDFLAGS += -no-undefined -version-info 1:0:0 + +libkea_http_la_LIBADD = +libkea_http_la_LIBADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la +libkea_http_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la +libkea_http_la_LIBADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la +libkea_http_la_LIBADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) + +# Specify the headers for copying into the installation directory tree. +libkea_process_includedir = $(pkgincludedir)/http +libkea_process_include_HEADERS = \ + http_log.h diff --git a/src/lib/http/http_log.cc b/src/lib/http/http_log.cc new file mode 100644 index 0000000000..63f245b96d --- /dev/null +++ b/src/lib/http/http_log.cc @@ -0,0 +1,19 @@ +// Copyright (C) 2016 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/. + +/// Defines the logger used by the top-level component of kea-dhcp-ddns. + +#include + +namespace isc { +namespace process { + +/// @brief Defines the logger used within libkea-http library. +isc::log::Logger http_logger("http"); + +} // namespace http +} // namespace isc + diff --git a/src/lib/http/http_log.h b/src/lib/http/http_log.h new file mode 100644 index 0000000000..498c6162b9 --- /dev/null +++ b/src/lib/http/http_log.h @@ -0,0 +1,23 @@ +// Copyright (C) 2016 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/. + +#ifndef HTTP_LOG_H +#define HTTP_LOG_H + +#include +#include +#include + +namespace isc { +namespace http { + +/// Define the loggers used within libkea-http library. +extern isc::log::Logger http_logger; + +} // namespace http +} // namespace isc + +#endif // HTTP_LOG_H diff --git a/src/lib/http/http_messages.mes b/src/lib/http/http_messages.mes new file mode 100644 index 0000000000..6465f8b29e --- /dev/null +++ b/src/lib/http/http_messages.mes @@ -0,0 +1,10 @@ +# Copyright (C) 2016 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/. + +$NAMESPACE isc::http + +% HTTP_DUMMY a dummy message for libkea-htto +This is a dummy message. diff --git a/src/lib/http/tests/.gitignore b/src/lib/http/tests/.gitignore new file mode 100644 index 0000000000..7100f8eda1 --- /dev/null +++ b/src/lib/http/tests/.gitignore @@ -0,0 +1 @@ +/libhttp_unittests diff --git a/src/lib/http/tests/Makefile.am b/src/lib/http/tests/Makefile.am new file mode 100644 index 0000000000..4faa5f0af4 --- /dev/null +++ b/src/lib/http/tests/Makefile.am @@ -0,0 +1,37 @@ +SUBDIRS = . + +AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib +AM_CPPFLAGS += $(BOOST_INCLUDES) +AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/http/tests\" +AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\" + +AM_CXXFLAGS = $(KEA_CXXFLAGS) + +if USE_STATIC_LINK +AM_LDFLAGS = -static +endif + +CLEANFILES = *.gcno *.gcda + +TESTS_ENVIRONMENT = \ + $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND) + +TESTS = +if HAVE_GTEST +TESTS += libhttp_unittests + +libhttp_unittests_SOURCES = run_unittests.cc + +libhttp_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) +libhttp_unittests_CXXFLAGS = $(AM_CXXFLAGS) +libhttp_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) + +libhttp_unittests_LDADD = $(top_builddir)/src/lib/http/libkea-http.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/exceptions/libkea-exceptions.la +libhttp_unittests_LDADD += $(LOG4CPLUS_LIBS) +libhttp_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD) +endif + +noinst_PROGRAMS = $(TESTS) diff --git a/src/lib/http/tests/run_unittests.cc b/src/lib/http/tests/run_unittests.cc new file mode 100644 index 0000000000..581febb976 --- /dev/null +++ b/src/lib/http/tests/run_unittests.cc @@ -0,0 +1,19 @@ +// Copyright (C) 2016 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/. + +#include +#include +#include + +int +main(int argc, char* argv[]) { + ::testing::InitGoogleTest(&argc, argv); + isc::log::initLogger(); + + int result = RUN_ALL_TESTS(); + + return (result); +} -- 2.47.3