mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 14:05:33 +00:00
[master] Merge branch 'trac1387'
This commit is contained in:
@@ -912,6 +912,7 @@ AC_CONFIG_FILES([Makefile
|
||||
src/lib/datasrc/tests/Makefile
|
||||
src/lib/datasrc/tests/testdata/Makefile
|
||||
src/lib/xfr/Makefile
|
||||
src/lib/xfr/tests/Makefile
|
||||
src/lib/log/Makefile
|
||||
src/lib/log/compiler/Makefile
|
||||
src/lib/log/tests/Makefile
|
||||
|
@@ -1,3 +1,5 @@
|
||||
SUBDIRS = . tests
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
|
||||
AM_CPPFLAGS += $(BOOST_INCLUDES)
|
||||
|
25
src/lib/xfr/tests/Makefile.am
Normal file
25
src/lib/xfr/tests/Makefile.am
Normal file
@@ -0,0 +1,25 @@
|
||||
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
|
||||
AM_CPPFLAGS += $(BOOST_INCLUDES)
|
||||
AM_CXXFLAGS = $(B10_CXXFLAGS)
|
||||
|
||||
if USE_STATIC_LINK
|
||||
AM_LDFLAGS = -static
|
||||
endif
|
||||
|
||||
CLEANFILES = *.gcno *.gcda
|
||||
|
||||
TESTS =
|
||||
if HAVE_GTEST
|
||||
TESTS += run_unittests
|
||||
run_unittests_SOURCES = run_unittests.cc client_test.cc
|
||||
|
||||
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
|
||||
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
|
||||
|
||||
run_unittests_LDADD = $(GTEST_LDADD)
|
||||
run_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
|
||||
run_unittests_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
|
||||
run_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
|
||||
endif
|
||||
|
||||
noinst_PROGRAMS = $(TESTS)
|
37
src/lib/xfr/tests/client_test.cc
Normal file
37
src/lib/xfr/tests/client_test.cc
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <sys/un.h>
|
||||
#include <string>
|
||||
|
||||
#include <xfr/xfrout_client.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace isc::xfr;
|
||||
|
||||
namespace {
|
||||
|
||||
TEST(ClientTest, connetFile) {
|
||||
// File path is too long
|
||||
struct sockaddr_un s; // can't be const; some compiler complains
|
||||
EXPECT_THROW(XfroutClient(string(sizeof(s.sun_path), 'x')).connect(),
|
||||
XfroutError);
|
||||
|
||||
// File doesn't exist (we assume the file "no_such_file" doesn't exist)
|
||||
EXPECT_THROW(XfroutClient("no_such_file").connect(), XfroutError);
|
||||
}
|
||||
|
||||
}
|
24
src/lib/xfr/tests/run_unittests.cc
Normal file
24
src/lib/xfr/tests/run_unittests.cc
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <log/logger_support.h>
|
||||
#include <util/unittests/run_all.h>
|
||||
|
||||
int
|
||||
main(int argc, char* argv[]) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
isc::log::initLogger();
|
||||
return (isc::util::unittests::run_all());
|
||||
}
|
@@ -52,10 +52,11 @@ XfroutClient::~XfroutClient() {
|
||||
|
||||
void
|
||||
XfroutClient::connect() {
|
||||
asio::error_code err;
|
||||
impl_->socket_.connect(stream_protocol::endpoint(impl_->file_path_), err);
|
||||
if (err) {
|
||||
isc_throw(XfroutError, "socket connect failed: " << err.message());
|
||||
try {
|
||||
impl_->socket_.connect(stream_protocol::endpoint(impl_->file_path_));
|
||||
} catch (const asio::system_error& err) {
|
||||
isc_throw(XfroutError, "socket connect failed for " <<
|
||||
impl_->file_path_ << ": " << err.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user