ソースを参照

ZOOKEEPER-735. cppunit test testipv6 assumes that the machine is ipv6 enabled. (mahadev)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@932049 13f79535-47bb-0310-9956-ffa450edef68
Mahadev Konar 15 年 前
コミット
af80eeedfc
4 ファイル変更32 行追加3 行削除
  1. 3 0
      CHANGES.txt
  2. 3 3
      src/c/Makefile.am
  3. 24 0
      src/c/configure.ac
  4. 2 0
      src/c/tests/TestClient.cc

+ 3 - 0
CHANGES.txt

@@ -8,6 +8,9 @@ Backward compatible changes:
 
 BUGFIXES: 
 
+  ZOOKEEPER-735. cppunit test testipv6 assumes that the machine is ipv6
+  enabled. (mahadev)
+
 IMPROVEMENTS:
   ZOOKEEPER-724. Improve junit test integration - log harness information 
   (phunt via mahadev)

+ 3 - 3
src/c/Makefile.am

@@ -3,7 +3,7 @@ include $(top_srcdir)/aminclude.am
 
 AM_CPPFLAGS = -I${srcdir}/include -I${srcdir}/tests -I${srcdir}/generated
 AM_CFLAGS = -Wall -Werror 
-CXXFLAGS = -Wall -g
+CXXFLAGS = -Wall -g $(USEIPV6)
 
 LIB_LDFLAGS = -no-undefined -version-info 2
 
@@ -83,14 +83,14 @@ SYMBOL_WRAPPERS=$(shell cat ${srcdir}/tests/wrappers.opt)
 check_PROGRAMS = zktest-st
 nodist_zktest_st_SOURCES = $(TEST_SOURCES)
 zktest_st_LDADD = libzkst.la libhashtable.la $(CPPUNIT_LIBS)
-zktest_st_CXXFLAGS = -DUSE_STATIC_LIB $(CPPUNIT_CFLAGS)
+zktest_st_CXXFLAGS = -DUSE_STATIC_LIB $(CPPUNIT_CFLAGS) $(USEIPV6)
 zktest_st_LDFLAGS = -static-libtool-libs $(SYMBOL_WRAPPERS)
 
 if WANT_SYNCAPI
   check_PROGRAMS += zktest-mt
   nodist_zktest_mt_SOURCES = $(TEST_SOURCES) tests/PthreadMocks.cc
   zktest_mt_LDADD = libzkmt.la libhashtable.la -lpthread $(CPPUNIT_LIBS)
-  zktest_mt_CXXFLAGS = -DUSE_STATIC_LIB -DTHREADED $(CPPUNIT_CFLAGS)
+  zktest_mt_CXXFLAGS = -DUSE_STATIC_LIB -DTHREADED $(CPPUNIT_CFLAGS) $(USEIPV6)
   SYMBOL_WRAPPERS_MT=$(SYMBOL_WRAPPERS) $(shell cat ${srcdir}/tests/wrappers-mt.opt)
   zktest_mt_LDFLAGS = -static-libtool-libs $(SYMBOL_WRAPPERS_MT)
 endif

+ 24 - 0
src/c/configure.ac

@@ -92,6 +92,30 @@ AC_CHECK_TYPE([nfds_t],
     [AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[poll() second argument type])],
     [#include <poll.h>])
 
+AC_MSG_CHECKING([whether to enable ipv6])
+
+AC_TRY_RUN([ /* is AF_INET6 available? */
+#include <sys/types.h>
+#include <sys/socket.h>
+main()
+{
+ if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
+   exit(1);
+ else
+   exit(0);
+}
+], AC_MSG_RESULT(yes) 
+   ipv6=yes, 
+   AC_MSG_RESULT(no) 
+   ipv6=no, 
+   AC_MSG_RESULT(no) 
+   ipv6=no)
+
+if test x"$ipv6" = xyes; then
+  USEIPV6="-DZOO_IPV6_ENABLED"
+  AC_SUBST(USEIPV6)
+fi
+
 # Checks for library functions.
 AC_CHECK_FUNCS([getcwd gethostbyname gethostname getlogin getpwuid_r gettimeofday getuid memmove memset poll socket strchr strdup strerror strtol])
 

+ 2 - 0
src/c/tests/TestClient.cc

@@ -188,7 +188,9 @@ class Zookeeper_simpleSystem : public CPPUNIT_NS::TestFixture
     CPPUNIT_TEST(testDeserializeString);
 #ifdef THREADED
     CPPUNIT_TEST(testNullData);
+#ifdef ZOO_IPV6_ENABLED
     CPPUNIT_TEST(testIPV6);
+#endif
     CPPUNIT_TEST(testPath);
     CPPUNIT_TEST(testPathValidation);
     CPPUNIT_TEST(testPing);