BIND 10 trac878, updated. 70d50df5bc495661463ff19885b9a4112270bafa [trac990] gtest tests added for Addr6.
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Jun 30 00:08:14 UTC 2011
The branch, trac878 has been updated
via 70d50df5bc495661463ff19885b9a4112270bafa (commit)
from d3ef96824420d7f089b28e6521790191e39949bf (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 70d50df5bc495661463ff19885b9a4112270bafa
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Thu Jun 30 02:05:31 2011 +0200
[trac990] gtest tests added for Addr6.
-----------------------------------------------------------------------
Summary of changes:
src/bin/dhcp6/tests/Makefile.am | 41 ++++++++++
src/bin/dhcp6/tests/addr6_unittest.cc | 88 ++++++++++++++++++++++
src/{lib/cc => bin/dhcp6}/tests/run_unittests.cc | 8 +-
3 files changed, 134 insertions(+), 3 deletions(-)
create mode 100644 src/bin/dhcp6/tests/addr6_unittest.cc
copy src/{lib/cc => bin/dhcp6}/tests/run_unittests.cc (92%)
-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/tests/Makefile.am b/src/bin/dhcp6/tests/Makefile.am
index a35284f..48f71d4 100644
--- a/src/bin/dhcp6/tests/Makefile.am
+++ b/src/bin/dhcp6/tests/Makefile.am
@@ -20,3 +20,44 @@ check-local:
BIND10_MSGQ_SOCKET_FILE=$(abs_top_builddir)/msgq_socket \
$(PYCOVERAGE_RUN) $(abs_srcdir)/$$pytest || exit ; \
done
+
+
+AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
+AM_CPPFLAGS += -I$(top_builddir)/src/bin # for generated spec_config.h header
+AM_CPPFLAGS += -I$(top_srcdir)/src/bin
+AM_CPPFLAGS += -I$(top_builddir)/src/lib/cc
+AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(abs_top_srcdir)/src/lib/testutils/testdata\"
+AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/testutils/testdata\"
+AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
+
+AM_CXXFLAGS = $(B10_CXXFLAGS)
+
+if USE_STATIC_LINK
+AM_LDFLAGS = -static
+endif
+
+TESTS =
+if HAVE_GTEST
+
+TESTS += run_unittests
+
+run_unittests_SOURCES = ../addr6.h ../addr6.cc
+run_unittests_SOURCES += ../pkt6.h ../pkt6.cc
+run_unittests_SOURCES += ../iface_mgr.h ../iface_mgr.cc
+run_unittests_SOURCES += ../dhcp6_srv.h ../dhcp6_srv.cc
+run_unittests_SOURCES += addr6_unittest.cc
+run_unittests_SOURCES += run_unittests.cc
+
+run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
+run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
+run_unittests_LDADD = $(GTEST_LDADD)
+run_unittests_LDADD += $(SQLITE_LIBS)
+run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
+run_unittests_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
+run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
+run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
+run_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
+endif
+
+noinst_PROGRAMS = $(TESTS)
diff --git a/src/bin/dhcp6/tests/addr6_unittest.cc b/src/bin/dhcp6/tests/addr6_unittest.cc
new file mode 100644
index 0000000..3d4960d
--- /dev/null
+++ b/src/bin/dhcp6/tests/addr6_unittest.cc
@@ -0,0 +1,88 @@
+// 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 <config.h>
+#include <iostream>
+#include <sstream>
+
+#include <arpa/inet.h>
+#include <gtest/gtest.h>
+
+
+#include "dhcp6/addr6.h"
+
+using namespace std;
+using namespace isc;
+
+class Addr6Test : public ::testing::Test {
+public:
+ Addr6Test() {
+ }
+};
+
+
+TEST_F(Addr6Test, constructor) {
+
+ char buf[16];
+
+ string addr1("2001:db8:1::abcd");
+ inet_pton(AF_INET6, addr1.c_str(), buf);
+
+ Addr6 test1(addr1.c_str(), true);
+
+ EXPECT_EQ(test1.getPlain(), addr1);
+ EXPECT_EQ(memcmp(test1.get(),buf, 16), 0);
+
+ Addr6 test2(buf, false);
+
+ EXPECT_EQ(test2.getPlain(), addr1);
+ EXPECT_EQ(memcmp(test2.get(),buf, 16), 0);
+}
+
+TEST_F(Addr6Test, mcast_linklocal) {
+
+ Addr6 mcast("ff00:2001:db8:1::abcd", true);
+ Addr6 global("2001:db8:1::dead:beef", true);
+ Addr6 local("fe80::face:b00c", true);
+
+ EXPECT_EQ(mcast.multicast(), true);
+ EXPECT_EQ(mcast.linkLocal(), false);
+
+ EXPECT_EQ(global.multicast(), false);
+ EXPECT_EQ(global.linkLocal(), false);
+
+ EXPECT_EQ(local.multicast(), false);
+ EXPECT_EQ(local.linkLocal(), true);
+}
+
+TEST_F(Addr6Test, equal) {
+
+ Addr6 one("2001:db8:1::abcd");
+ Addr6 two("2001:db8:1::abcd");
+ Addr6 three("2001:db8:1::4321");
+
+ EXPECT_EQ( (one==two), true);
+ EXPECT_EQ( (one==three), false);
+}
+
+TEST_F(Addr6Test, stream) {
+
+ string plain("2001:db8:1::abcd");
+ Addr6 addr(plain.c_str(), true);
+
+ stringstream tmp;
+ tmp << addr;
+
+ EXPECT_EQ( tmp.str(), plain);
+}
diff --git a/src/bin/dhcp6/tests/run_unittests.cc b/src/bin/dhcp6/tests/run_unittests.cc
new file mode 100644
index 0000000..360fb71
--- /dev/null
+++ b/src/bin/dhcp6/tests/run_unittests.cc
@@ -0,0 +1,28 @@
+// Copyright (C) 2009 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 <stdio.h>
+#include <gtest/gtest.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;
+}
More information about the bind10-changes
mailing list