You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by rl...@apache.org on 2016/05/18 02:50:23 UTC

[10/51] [abbrv] [partial] incubator-hawq git commit: HAWQ-735. Import thrift-0.9.3 into depends/thirdparty/thrift folder

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/c_glib/test/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/c_glib/test/CMakeLists.txt b/depends/thirdparty/thrift/lib/c_glib/test/CMakeLists.txt
new file mode 100644
index 0000000..31e6c6b
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/c_glib/test/CMakeLists.txt
@@ -0,0 +1,170 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+#Make sure gen-cpp and gen-c_glib files can be included
+include_directories("${CMAKE_CURRENT_BINARY_DIR}")
+
+set(TEST_PREFIX "c_glib")
+
+include_directories(${Boost_INCLUDE_DIRS})
+
+# Create the thrift C test library
+set(testgenc_SOURCES
+    gen-c_glib/t_test_debug_proto_test_types.c
+    gen-c_glib/t_test_empty_service.c
+    gen-c_glib/t_test_inherited.c
+    gen-c_glib/t_test_optional_required_test_types.c
+    gen-c_glib/t_test_reverse_order_service.c
+    gen-c_glib/t_test_second_service.c
+    gen-c_glib/t_test_service_for_exception_with_a_map.c
+    gen-c_glib/t_test_srv.c
+    gen-c_glib/t_test_thrift_test.c
+    gen-c_glib/t_test_thrift_test_types.c
+    gen-c_glib/t_test_debug_proto_test_types.h
+    gen-c_glib/t_test_empty_service.h
+    gen-c_glib/t_test_inherited.h
+    gen-c_glib/t_test_optional_required_test_types.h
+    gen-c_glib/t_test_reverse_order_service.h
+    gen-c_glib/t_test_second_service.h
+    gen-c_glib/t_test_service_for_exception_with_a_map.h
+    gen-c_glib/t_test_srv.h
+    gen-c_glib/t_test_thrift_test.h
+    gen-c_glib/t_test_thrift_test_types.h
+)
+
+add_library(testgenc STATIC ${testgenc_SOURCES})
+target_link_libraries(testgenc thrift_c_glib)
+
+
+add_executable(testapplicationexception testapplicationexception.c)
+target_link_libraries(testapplicationexception thrift_c_glib)
+add_test(NAME testapplicationexception COMMAND testapplicationexception)
+
+add_executable(testtransportsocket testtransportsocket.c)
+target_link_libraries(testtransportsocket thrift_c_glib)
+add_test(NAME testtransportsocket COMMAND testtransportsocket)
+
+add_executable(testbinaryprotocol testbinaryprotocol.c)
+target_link_libraries(testbinaryprotocol thrift_c_glib)
+add_test(NAME testbinaryprotocol COMMAND testbinaryprotocol)
+
+add_executable(testbufferedtransport testbufferedtransport.c)
+target_link_libraries(testbufferedtransport thrift_c_glib)
+add_test(NAME testbufferedtransport COMMAND testbufferedtransport)
+
+add_executable(testframedtransport testframedtransport.c)
+target_link_libraries(testframedtransport thrift_c_glib)
+add_test(NAME testframedtransport COMMAND testframedtransport)
+
+add_executable(testmemorybuffer testmemorybuffer.c)
+target_link_libraries(testmemorybuffer thrift_c_glib)
+add_test(NAME testmemorybuffer COMMAND testmemorybuffer)
+
+add_executable(testsimpleserver testsimpleserver.c)
+target_link_libraries(testsimpleserver thrift_c_glib)
+add_test(NAME testsimpleserver COMMAND testsimpleserver)
+
+add_executable(testdebugproto testdebugproto.c)
+target_link_libraries(testdebugproto testgenc)
+add_test(NAME testdebugproto COMMAND testdebugproto)
+
+add_executable(testoptionalrequired testoptionalrequired.c)
+target_link_libraries(testoptionalrequired testgenc)
+add_test(NAME testoptionalrequired COMMAND testoptionalrequired)
+
+add_executable(testthrifttest testthrifttest.c)
+target_link_libraries(testthrifttest testgenc)
+add_test(NAME testthrifttest COMMAND testthrifttest)
+
+
+if(BUILD_CPP)
+
+    include_directories("${PROJECT_SOURCE_DIR}/lib/cpp/src")
+
+    # Create the thrift C++ test library
+    set(testgenc_cpp_SOURCES
+        gen-cpp/ThriftTest.cpp
+        gen-cpp/ThriftTest_constants.cpp
+        gen-cpp/ThriftTest_types.cpp
+        gen-cpp/ThriftTest.h
+        gen-cpp/ThriftTest_constants.h
+        gen-cpp/ThriftTest_types.h
+    )
+
+    add_library(testgenc_cpp STATIC ${testgenc_cpp_SOURCES})
+    target_link_libraries(testgenc_cpp thrift)
+
+    #HACK: testthrifttestclient.cpp includes ThriftTest.h without gen-*/ prefixes
+    # so we include it here
+    include_directories("${CMAKE_CURRENT_BINARY_DIR}/gen-cpp" "${CMAKE_CURRENT_BINARY_DIR}/gen-c_glib")
+
+    add_executable(testthrifttestclient testthrifttestclient.cpp)
+    target_link_libraries(testthrifttestclient testgenc testgenc_cpp)
+    add_test(NAME testthrifttestclient COMMAND testthrifttestclient)
+
+endif(BUILD_CPP)
+
+#
+# Common thrift code generation rules
+#
+
+add_custom_command(OUTPUT
+    gen-c_glib/t_test_debug_proto_test_types.c
+    gen-c_glib/t_test_debug_proto_test_types.h
+    gen-c_glib/t_test_empty_service.c
+    gen-c_glib/t_test_empty_service.h
+    gen-c_glib/t_test_inherited.c
+    gen-c_glib/t_test_inherited.h
+    gen-c_glib/t_test_reverse_order_service.c
+    gen-c_glib/t_test_reverse_order_service.h
+    gen-c_glib/t_test_service_for_exception_with_a_map.c
+    gen-c_glib/t_test_service_for_exception_with_a_map.h
+    gen-c_glib/t_test_srv.c
+    gen-c_glib/t_test_srv.h
+    COMMAND thrift-compiler --gen c_glib ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift
+)
+
+add_custom_command(OUTPUT
+    gen-c_glib/t_test_optional_required_test_types.c
+    gen-c_glib/t_test_optional_required_test_types.h
+    COMMAND thrift-compiler --gen c_glib ${PROJECT_SOURCE_DIR}/test/OptionalRequiredTest.thrift
+)
+
+add_custom_command(OUTPUT
+    gen-c_glib/t_test_second_service.c
+    gen-c_glib/t_test_thrift_test.c
+    gen-c_glib/t_test_thrift_test_types.c
+    gen-c_glib/t_test_second_service.h
+    gen-c_glib/t_test_thrift_test.h
+    gen-c_glib/t_test_thrift_test_types.h
+    COMMAND thrift-compiler --gen c_glib ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
+)
+
+add_custom_command(OUTPUT
+    gen-cpp/ThriftTest.cpp
+    gen-cpp/ThriftTest_constants.cpp
+    gen-cpp/ThriftTest_types.cpp
+    gen-cpp/ThriftTest.h
+    gen-cpp/ThriftTest_constants.h
+    gen-cpp/ThriftTest_types.h
+    COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
+)
+
+# TODO: Add memory checks using ctest_memcheck or similar

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/c_glib/test/ContainerTest.thrift
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/c_glib/test/ContainerTest.thrift b/depends/thirdparty/thrift/lib/c_glib/test/ContainerTest.thrift
new file mode 100644
index 0000000..a92a9a5
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/c_glib/test/ContainerTest.thrift
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace c_glib TTest
+
+typedef list<string> StringList
+typedef list<StringList> ListStringList
+
+struct ContainersWithDefaultValues {
+  1: list<string> StringList = [ "Apache", "Thrift" ];
+}
+
+service ContainerService {
+  void receiveStringList(1: list<string> stringList);
+  list<string> returnStringList();
+
+  list<list<string>> returnListStringList();
+  ListStringList returnTypedefdListStringList();
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/c_glib/test/Makefile.am
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/c_glib/test/Makefile.am b/depends/thirdparty/thrift/lib/c_glib/test/Makefile.am
new file mode 100755
index 0000000..7319743
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/c_glib/test/Makefile.am
@@ -0,0 +1,282 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+AUTOMAKE_OPTIONS = subdir-objects serial-tests
+
+SUBDIRS =
+
+BUILT_SOURCES = \
+        gen-c_glib/t_test_container_test_types.c \
+        gen-c_glib/t_test_container_test_types.h \
+        gen-c_glib/t_test_debug_proto_test_types.h \
+        gen-c_glib/t_test_empty_service.h \
+        gen-c_glib/t_test_inherited.h \
+        gen-c_glib/t_test_optional_required_test_types.h \
+        gen-c_glib/t_test_reverse_order_service.h \
+        gen-c_glib/t_test_second_service.h \
+        gen-c_glib/t_test_service_for_exception_with_a_map.h \
+        gen-c_glib/t_test_container_service.c \
+        gen-c_glib/t_test_container_service.h \
+        gen-c_glib/t_test_srv.h \
+        gen-c_glib/t_test_thrift_test.h \
+        gen-c_glib/t_test_thrift_test_types.h
+
+AM_CPPFLAGS = -I../src
+AM_CFLAGS = -g -Wall -Wextra -pedantic $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) \
+	@GCOV_CFLAGS@
+AM_CXXFLAGS = $(AM_CFLAGS)
+AM_LDFLAGS = $(GLIB_LIBS) $(GOBJECT_LIBS) @GCOV_LDFLAGS@
+
+check_PROGRAMS = \
+  testapplicationexception \
+  testcontainertest \
+  testtransportsocket \
+  testbinaryprotocol \
+  testbufferedtransport \
+  testframedtransport \
+  testmemorybuffer \
+  teststruct \
+  testsimpleserver \
+  testdebugproto \
+  testoptionalrequired \
+  testthrifttest
+
+if WITH_CPP
+  BUILT_SOURCES += gen-cpp/ThriftTest_types.cpp
+  check_PROGRAMS += testthrifttestclient
+endif
+
+testapplicationexception_SOURCES = testapplicationexception.c
+testapplicationexception_LDADD = \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/libthrift_c_glib_la-thrift_application_exception.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/protocol/libthrift_c_glib_la-thrift_protocol.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/libthrift_c_glib_la-thrift_struct.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_transport.o
+
+testcontainertest_SOURCES = testcontainertest.c
+testcontainertest_LDADD = \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/libthrift_c_glib_la-thrift_struct.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/protocol/libthrift_c_glib_la-thrift_protocol.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_transport.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_transport_factory.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/processor/libthrift_c_glib_la-thrift_processor.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/protocol/libthrift_c_glib_la-thrift_protocol_factory.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/protocol/libthrift_c_glib_la-thrift_binary_protocol.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/protocol/libthrift_c_glib_la-thrift_binary_protocol_factory.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_socket.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_server_transport.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_server_socket.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/server/libthrift_c_glib_la-thrift_server.o \
+	  libtestgenc.la
+
+testtransportsocket_SOURCES = testtransportsocket.c
+testtransportsocket_LDADD = \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_transport.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_buffered_transport.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_server_transport.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_server_socket.o
+
+testbinaryprotocol_SOURCES = testbinaryprotocol.c
+testbinaryprotocol_LDADD = \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/protocol/libthrift_c_glib_la-thrift_protocol.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_transport.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_socket.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_server_transport.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_server_socket.o
+
+testbufferedtransport_SOURCES = testbufferedtransport.c
+testbufferedtransport_LDADD = \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_transport.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_socket.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_server_transport.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_server_socket.o
+
+testframedtransport_SOURCES = testframedtransport.c
+testframedtransport_LDADD = \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_transport.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_socket.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_server_transport.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_server_socket.o
+
+testmemorybuffer_SOURCES = testmemorybuffer.c
+testmemorybuffer_LDADD = \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_transport.o
+
+teststruct_SOURCES = teststruct.c
+teststruct_LDADD = \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/protocol/libthrift_c_glib_la-thrift_protocol.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_transport.o
+
+testsimpleserver_SOURCES = testsimpleserver.c
+testsimpleserver_LDADD = \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/protocol/libthrift_c_glib_la-thrift_protocol.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_transport.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_transport_factory.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/processor/libthrift_c_glib_la-thrift_processor.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/protocol/libthrift_c_glib_la-thrift_protocol_factory.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/protocol/libthrift_c_glib_la-thrift_binary_protocol.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/protocol/libthrift_c_glib_la-thrift_binary_protocol_factory.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_socket.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_server_transport.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_server_socket.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/server/libthrift_c_glib_la-thrift_server.o
+
+testdebugproto_SOURCES = testdebugproto.c
+testdebugproto_LDADD = libtestgenc.la
+
+testoptionalrequired_SOURCES = testoptionalrequired.c
+testoptionalrequired_LDADD = \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/protocol/libthrift_c_glib_la-thrift_protocol.o \
+    $(top_builddir)/lib/c_glib/src/thrift/c_glib/transport/libthrift_c_glib_la-thrift_transport.o \
+    libtestgenc.la
+
+testthrifttest_SOURCES = testthrifttest.c
+testthrifttest_LDADD = libtestgenc.la
+
+testthrifttestclient_SOURCES = testthrifttestclient.cpp
+testthrifttestclient_CPPFLAGS = -I../../cpp/src $(BOOST_CPPFLAGS) -I./gen-cpp -I../src -I./gen-c_glib $(GLIB_CFLAGS)
+testthrifttestclient_LDADD = ../../cpp/.libs/libthrift.la ../libthrift_c_glib.la libtestgenc.la libtestgencpp.la
+testthrifttestclient_LDFLAGS = -L../.libs -L../../cpp/.libs $(GLIB_LIBS) $(GOBJECT_LIBS)
+
+check_LTLIBRARIES = libtestgenc.la
+
+if WITH_CPP
+  check_LTLIBRARIES += libtestgencpp.la
+endif
+
+nodist_libtestgenc_la_SOURCES = \
+        gen-c_glib/t_test_container_test_types.c \
+        gen-c_glib/t_test_debug_proto_test_types.c \
+        gen-c_glib/t_test_empty_service.c \
+        gen-c_glib/t_test_inherited.c \
+        gen-c_glib/t_test_optional_required_test_types.c \
+        gen-c_glib/t_test_reverse_order_service.c \
+        gen-c_glib/t_test_second_service.c \
+        gen-c_glib/t_test_service_for_exception_with_a_map.c \
+        gen-c_glib/t_test_srv.c \
+        gen-c_glib/t_test_container_service.c \
+        gen-c_glib/t_test_thrift_test.c \
+        gen-c_glib/t_test_thrift_test_types.c \
+        gen-c_glib/t_test_container_test_types.h \
+        gen-c_glib/t_test_debug_proto_test_types.h \
+        gen-c_glib/t_test_empty_service.h \
+        gen-c_glib/t_test_inherited.h \
+        gen-c_glib/t_test_optional_required_test_types.h \
+        gen-c_glib/t_test_reverse_order_service.h \
+        gen-c_glib/t_test_second_service.h \
+        gen-c_glib/t_test_service_for_exception_with_a_map.h \
+        gen-c_glib/t_test_srv.h \
+        gen-c_glib/t_test_container_service.h \
+        gen-c_glib/t_test_thrift_test.h \
+        gen-c_glib/t_test_thrift_test_types.h
+libtestgenc_la_LIBADD = $(top_builddir)/lib/c_glib/libthrift_c_glib.la
+libtestgenc_la_CPPFLAGS = $(AM_CPPFLAGS) -Wno-unused-function
+
+nodist_libtestgencpp_la_SOURCES = \
+        gen-cpp/ThriftTest.cpp \
+        gen-cpp/ThriftTest_constants.cpp \
+        gen-cpp/ThriftTest_types.cpp \
+        gen-cpp/ThriftTest.h \
+        gen-cpp/ThriftTest_constants.h \
+        gen-cpp/ThriftTest_types.h
+libtestgencpp_la_CPPFLAGS = -I../../cpp/src $(BOOST_CPPFLAGS) -I./gen-cpp
+
+THRIFT = $(top_builddir)/compiler/cpp/thrift
+
+gen-c_glib/t_test_container_test_types.c gen-c_glib/t_test_container_test_types.h gen-c_glib/t_test_container_service.c gen-c_glib/t_test_container_service.h: ContainerTest.thrift
+	$(THRIFT) --gen c_glib $<
+
+gen-c_glib/t_test_debug_proto_test_types.c gen-c_glib/t_test_debug_proto_test_types.h gen-c_glib/t_test_empty_service.c gen-c_glib/t_test_empty_service.h gen-c_glib/t_test_inherited.c gen-c_glib/t_test_inherited.h gen-c_glib/t_test_reverse_order_service.c gen-c_glib/t_test_reverse_order_service.h gen-c_glib/t_test_service_for_exception_with_a_map.c gen-c_glib/t_test_service_for_exception_with_a_map.h gen-c_glib/t_test_srv.c gen-c_glib/t_test_srv.h: ../../../test/DebugProtoTest.thrift
+	$(THRIFT) --gen c_glib $<
+
+gen-c_glib/t_test_optional_required_test_types.c gen-c_glib/t_test_optional_required_test_types.h: ../../../test/OptionalRequiredTest.thrift
+	$(THRIFT) --gen c_glib $<
+
+gen-c_glib/t_test_second_service.c gen-c_glib/t_test_thrift_test.c gen-c_glib/t_test_thrift_test_types.c gen-c_glib/t_test_second_service.h gen-c_glib/t_test_thrift_test.h gen-c_glib/t_test_thrift_test_types.h: ../../../test/ThriftTest.thrift
+	$(THRIFT) --gen c_glib $<
+
+gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_constants.cpp gen-cpp/ThriftTest_types.cpp: ../../../test/ThriftTest.thrift
+	$(THRIFT) --gen cpp $<
+
+TESTS = \
+  $(check_PROGRAMS) \
+  $(check_SCRIPTS)
+
+# globally added to all instances of valgrind calls
+# VALGRIND_OPTS = --suppressions=glib.suppress
+VALGRIND_OPTS =
+
+# globally added to all memcheck calls
+VALGRIND_MEM_OPTS = --tool=memcheck \
+                    --num-callers=10 \
+                    ${myextravalgrindmemopts}
+
+# globally added to all leakcheck calls
+VALGRIND_LEAK_OPTS = --tool=memcheck \
+                     --num-callers=10 \
+                     --leak-check=full \
+                     --leak-resolution=high \
+                     ${myextravalgrindleakopts}
+
+memcheck: $(check_PROGRAMS)
+	@for x in $(check_PROGRAMS);                                     \
+	  do                                                             \
+	    $(MAKE) memcheck-$$x;                                        \
+	  done
+
+leakcheck: $(check_PROGRAMS)
+	@for x in $(check_PROGRAMS);                                     \
+	  do                                                             \
+	    $(MAKE) leakcheck-$$x;                                       \
+	done
+
+memcheck-%: %
+	@echo "*****************************************";               \
+	echo "MEMCHECK: $<";                                             \
+	echo "ARGS: ${VALGRIND_OPTS} ${VALGRIND_MEM_OPTS} ${$<_VALGRIND_MEM_OPTS}";                                                                      \
+	$(LIBTOOL) --mode=execute                                        \
+	  valgrind                                                       \
+	    ${VALGRIND_OPTS}                                             \
+	    ${VALGRIND_MEM_OPTS}                                         \
+	    ${$<_VALGRIND_MEM_OPTS} ./$<
+
+leakcheck-%: %
+	@echo "*****************************************";              \
+	echo "LEAKCHECK: $<";                                           \
+	echo "ARGS: ${VALGRIND_OPTS} ${VALGRIND_LEAK_OPTS} ${$<_VALGRIND_LEAK_OPTS}";                                                                   \
+	G_SLICE=always-malloc $(LIBTOOL) --mode=execute                 \
+	  valgrind                                                      \
+	    ${VALGRIND_OPTS}                                            \
+	    ${VALGRIND_LEAK_OPTS}                                       \
+	    ${$<_VALGRIND_LEAK_OPTS}  ./$<
+
+clean-local:
+	$(RM) gen-c_glib/* gen-cpp/*
+
+CLEANFILES =                            \
+    *.bb                                \
+    *.bbg                               \
+    *.da                                \
+    *.gcno                              \
+    *.gcda                              \
+    *.gcov
+
+EXTRA_DIST = \
+             CMakeLists.txt \
+             ContainerTest.thrift
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/c_glib/test/glib.suppress
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/c_glib/test/glib.suppress b/depends/thirdparty/thrift/lib/c_glib/test/glib.suppress
new file mode 100644
index 0000000..0e0e9fe
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/c_glib/test/glib.suppress
@@ -0,0 +1,64 @@
+{
+   g_type_init_1
+   Memcheck:Leak
+   fun:malloc
+   ...
+   fun:g_type_init_with_debug_flags
+}
+
+{
+   g_type_init_2
+   Memcheck:Leak
+   fun:calloc
+   ...
+   fun:g_type_init_with_debug_flags
+}
+
+{
+   g_type_init_3
+   Memcheck:Leak
+   fun:realloc
+   ...
+   fun:g_type_init_with_debug_flags
+}
+
+{
+   g_type_register_static_1
+   Memcheck:Leak
+   fun:realloc
+   ...
+   fun:g_type_register_static
+}
+
+{
+   g_type_register_statuc_2
+   Memcheck:Leak
+   fun:malloc
+   fun:realloc
+   fun:g_realloc
+   ...
+   fun:g_type_register_static
+}
+
+{
+   type_class_init_Wm1
+   Memcheck:Leak
+   fun:calloc
+   fun:g_malloc0
+   fun:type_class_init_Wm
+   fun:g_type_class_ref
+   ...
+   fun:g_object_newv
+}
+
+{
+   type_class_init_Wm2
+   Memcheck:Leak
+   fun:calloc
+   fun:g_malloc0
+   fun:type_class_init_Wm
+   fun:g_type_class_ref
+   ...
+   fun:type_class_init_Wm
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/c_glib/test/testapplicationexception.c
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/c_glib/test/testapplicationexception.c b/depends/thirdparty/thrift/lib/c_glib/test/testapplicationexception.c
new file mode 100644
index 0000000..89e39e2
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/c_glib/test/testapplicationexception.c
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <glib.h>
+#include <string.h>
+
+#include <thrift/c_glib/thrift_application_exception.h>
+
+static void
+test_create_and_destroy (void)
+{
+  GObject *object = NULL;
+
+  /* A ThriftApplicationException can be created... */
+  object = g_object_new (THRIFT_TYPE_APPLICATION_EXCEPTION, NULL);
+
+  g_assert (object != NULL);
+  g_assert (THRIFT_IS_APPLICATION_EXCEPTION (object));
+
+  /* ...and destroyed */
+  g_object_unref (object);
+}
+
+static void
+test_initialize (void)
+{
+  ThriftApplicationException *xception = NULL;
+  gint32 type = THRIFT_APPLICATION_EXCEPTION_ERROR_INTERNAL_ERROR;
+  gchar *message = "Exception message";
+  gint32 retrieved_type = 0;
+  gchar *retrieved_message = NULL;
+
+  /* A ThriftApplicationException has "type" and "message" properties that can
+     be initialized at object creation */
+  xception =
+    g_object_new (THRIFT_TYPE_APPLICATION_EXCEPTION,
+                  "type",    type,
+                  "message", message,
+                  NULL);
+
+  g_assert (xception != NULL);
+
+  /* A ThriftApplicationException's properties can be retrieved */
+  g_object_get (xception,
+                "type",    &retrieved_type,
+                "message", &retrieved_message,
+                NULL);
+
+  g_assert (retrieved_type == type);
+  g_assert (retrieved_message != NULL);
+  g_assert_cmpstr (retrieved_message, ==, message);
+
+  g_free (retrieved_message);
+  g_object_unref (xception);
+}
+
+static void
+test_properties_test (void)
+{
+  ThriftApplicationException *xception = NULL;
+  gint32 retrieved_type;
+
+  xception = g_object_new (THRIFT_TYPE_APPLICATION_EXCEPTION, NULL);
+
+#define TEST_TYPE_VALUE(_type)                                  \
+  retrieved_type = -1;                                          \
+  g_object_set (xception, "type", _type, NULL);                 \
+  g_object_get (xception, "type", &retrieved_type, NULL);       \
+  g_assert_cmpint (retrieved_type, ==, _type);
+
+  /* The "type" property can be set to any valid Thrift exception type */
+  TEST_TYPE_VALUE (THRIFT_APPLICATION_EXCEPTION_ERROR_UNKNOWN);
+  TEST_TYPE_VALUE (THRIFT_APPLICATION_EXCEPTION_ERROR_UNKNOWN_METHOD);
+  TEST_TYPE_VALUE (THRIFT_APPLICATION_EXCEPTION_ERROR_INVALID_MESSAGE_TYPE);
+  TEST_TYPE_VALUE (THRIFT_APPLICATION_EXCEPTION_ERROR_WRONG_METHOD_NAME);
+  TEST_TYPE_VALUE (THRIFT_APPLICATION_EXCEPTION_ERROR_BAD_SEQUENCE_ID);
+  TEST_TYPE_VALUE (THRIFT_APPLICATION_EXCEPTION_ERROR_MISSING_RESULT);
+  TEST_TYPE_VALUE (THRIFT_APPLICATION_EXCEPTION_ERROR_INTERNAL_ERROR);
+  TEST_TYPE_VALUE (THRIFT_APPLICATION_EXCEPTION_ERROR_PROTOCOL_ERROR);
+  TEST_TYPE_VALUE (THRIFT_APPLICATION_EXCEPTION_ERROR_INVALID_TRANSFORM);
+  TEST_TYPE_VALUE (THRIFT_APPLICATION_EXCEPTION_ERROR_INVALID_PROTOCOL);
+  TEST_TYPE_VALUE (THRIFT_APPLICATION_EXCEPTION_ERROR_UNSUPPORTED_CLIENT_TYPE);
+
+/* "g_test_expect_message" is required for the property range tests below but is
+   not present in GLib before version 2.34 */
+#if (GLIB_CHECK_VERSION (2, 34, 0))
+  g_object_set (xception,
+                "type", THRIFT_APPLICATION_EXCEPTION_ERROR_UNKNOWN,
+                NULL);
+
+  /* The "type" property cannot be set to a value too low (less than zero) */
+  g_test_expect_message ("GLib-GObject",
+                         G_LOG_LEVEL_WARNING,
+                         "value*out of range*type*");
+  g_object_set (xception, "type", -1, NULL);
+  g_test_assert_expected_messages ();
+
+  g_object_get (xception, "type", &retrieved_type, NULL);
+  g_assert_cmpint (retrieved_type, !=, -1);
+  g_assert_cmpint (retrieved_type,
+                   ==,
+                   THRIFT_APPLICATION_EXCEPTION_ERROR_UNKNOWN);
+
+  /* The "type" property cannot be set to a value too high (greater than the
+     highest defined exception-type value) */
+  g_test_expect_message ("GLib-GObject",
+                         G_LOG_LEVEL_WARNING,
+                         "value*out of range*type*");
+  g_object_set (xception, "type", THRIFT_APPLICATION_EXCEPTION_ERROR_N, NULL);
+  g_test_assert_expected_messages ();
+
+  g_object_get (xception, "type", &retrieved_type, NULL);
+  g_assert_cmpint (retrieved_type, !=, THRIFT_APPLICATION_EXCEPTION_ERROR_N);
+  g_assert_cmpint (retrieved_type,
+                   ==,
+                   THRIFT_APPLICATION_EXCEPTION_ERROR_UNKNOWN);
+#endif
+
+  g_object_unref (xception);
+}
+
+static void
+test_properties_message (void)
+{
+  ThriftApplicationException *xception = NULL;
+  gchar *message = "Exception message";
+  gchar *retrieved_message;
+
+  xception = g_object_new (THRIFT_TYPE_APPLICATION_EXCEPTION, NULL);
+
+  /* The "message" property can be set to NULL */
+  g_object_set (xception, "message", NULL, NULL);
+  g_object_get (xception, "message", &retrieved_message, NULL);
+  g_assert (retrieved_message == NULL);
+
+  /* The "message" property can be set to a valid string */
+  g_object_set (xception, "message", message, NULL);
+  g_object_get (xception, "message", &retrieved_message, NULL);
+  g_assert_cmpint (strcmp (retrieved_message, message), ==, 0);
+
+  g_free (retrieved_message);
+  g_object_unref (xception);
+}
+
+int
+main (int argc, char **argv)
+{
+#if (!GLIB_CHECK_VERSION (2, 36, 0))
+  g_type_init ();
+#endif
+
+  g_test_init (&argc, &argv, NULL);
+
+  g_test_add_func ("/testapplicationexception/CreateAndDestroy",
+    test_create_and_destroy);
+  g_test_add_func ("/testapplicationexception/Initialize",
+    test_initialize);
+  g_test_add_func ("/testapplicationexception/Properties/test",
+    test_properties_test);
+  g_test_add_func ("/testapplicationexception/Properties/message",
+    test_properties_message);
+
+  return g_test_run ();
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/c_glib/test/testbinaryprotocol.c
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/c_glib/test/testbinaryprotocol.c b/depends/thirdparty/thrift/lib/c_glib/test/testbinaryprotocol.c
new file mode 100755
index 0000000..cd65501
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/c_glib/test/testbinaryprotocol.c
@@ -0,0 +1,688 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* Disable string-function optimizations when glibc is used, as these produce
+   compiler warnings about string length when a string function is used inside
+   a call to assert () */
+#if !defined(__APPLE__) && !defined(__FreeBSD__) && \
+    !defined(__OpenBSD__) && !defined(__NetBSD__)
+#include <features.h>
+#endif
+
+#ifdef __GLIBC__
+#define __NO_STRING_INLINES 1
+#endif
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+#include <netdb.h>
+#include <string.h>
+#include <sys/wait.h>
+
+#include <thrift/c_glib/protocol/thrift_protocol.h>
+#include <thrift/c_glib/transport/thrift_socket.h>
+#include <thrift/c_glib/transport/thrift_server_socket.h>
+
+#define TEST_BOOL TRUE
+#define TEST_BYTE 123
+#define TEST_I16 12345
+#define TEST_I32 1234567890
+#define TEST_I64 123456789012345
+#define TEST_DOUBLE 1234567890.123
+#define TEST_STRING "this is a test string 1234567890!@#$%^&*()"
+#define TEST_PORT 51199
+
+static int transport_read_count = 0;
+static int transport_read_error = 0;
+static int transport_read_error_at = -1;
+gint32
+my_thrift_transport_read (ThriftTransport *transport, gpointer buf,
+                          guint32 len, GError **error)
+{
+  if (transport_read_count != transport_read_error_at
+      && transport_read_error == 0)
+  {
+    transport_read_count++;
+    return thrift_transport_read (transport, buf, len, error);
+  }
+  return -1;
+}
+
+static int transport_write_count = 0;
+static int transport_write_error = 0;
+static int transport_write_error_at = -1;
+gboolean
+my_thrift_transport_write (ThriftTransport *transport, const gpointer buf,
+                           const guint32 len, GError **error)
+{
+  if (transport_write_count != transport_write_error_at
+      && transport_write_error == 0)
+  {
+    transport_write_count++;
+    return thrift_transport_write (transport, buf, len, error);
+  }
+  return FALSE;
+}
+
+#define thrift_transport_read my_thrift_transport_read
+#define thrift_transport_write my_thrift_transport_write
+#include "../src/thrift/c_glib/protocol/thrift_binary_protocol.c"
+#undef thrift_transport_read
+#undef thrift_transport_write
+
+static void thrift_server_primitives (const int port);
+static void thrift_server_complex_types (const int port);
+
+static void
+test_create_and_destroy(void)
+{
+  GObject *object = NULL;
+
+  /* create an object and then destroy it */
+  object = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, NULL);
+  assert (object != NULL);
+  g_object_unref (object);
+}
+
+static void
+test_initialize(void)
+{
+  ThriftSocket *tsocket = NULL;
+  ThriftBinaryProtocol *protocol = NULL;
+  ThriftSocket *temp = NULL;
+
+  /* create a ThriftTransport */
+  tsocket = g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost",
+                          "port", 51188, NULL);
+  assert (tsocket != NULL);
+  /* create a ThriftBinaryProtocol using the Transport */
+  protocol = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, "transport",
+                           tsocket, NULL);
+  assert (protocol != NULL);
+  /* fetch the properties */
+  g_object_get (G_OBJECT(protocol), "transport", &temp, NULL);
+  g_object_unref (temp);
+
+  /* clean up memory */
+  g_object_unref (protocol);
+  g_object_unref (tsocket);
+}
+
+static void
+test_read_and_write_primitives(void)
+{
+  int status;
+  pid_t pid;
+  ThriftSocket *tsocket = NULL;
+  ThriftTransport *transport = NULL;
+  ThriftBinaryProtocol *tb = NULL;
+  ThriftProtocol *protocol = NULL;
+  gpointer binary = (gpointer *) TEST_STRING;
+  guint32 len = strlen (TEST_STRING);
+  int port = TEST_PORT;
+
+  /* fork a server from the client */
+  pid = fork ();
+  assert (pid >= 0);
+
+  if (pid == 0)
+  {
+    /* child listens */
+    thrift_server_primitives (port);
+    exit (0);
+  } else {
+    /* parent.  wait a bit for the socket to be created. */
+    sleep (1);
+
+    /* create a ThriftSocket */
+    tsocket = g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost",
+                            "port", port, NULL);
+    transport = THRIFT_TRANSPORT (tsocket);
+    thrift_transport_open (transport, NULL);
+    assert (thrift_transport_is_open (transport));
+
+    /* create a ThriftBinaryTransport */
+    tb = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, "transport",
+                       tsocket, NULL);
+    protocol = THRIFT_PROTOCOL (tb);
+    assert (protocol != NULL);
+
+    /* write a bunch of primitives */
+    assert (thrift_binary_protocol_write_bool (protocol, TEST_BOOL, NULL) > 0);
+    assert (thrift_binary_protocol_write_byte (protocol, TEST_BYTE, NULL) > 0);
+    assert (thrift_binary_protocol_write_i16 (protocol, TEST_I16, NULL) > 0);
+    assert (thrift_binary_protocol_write_i32 (protocol, TEST_I32, NULL) > 0);
+    assert (thrift_binary_protocol_write_i64 (protocol, TEST_I64, NULL) > 0);
+    assert (thrift_binary_protocol_write_double (protocol, 
+                                                 TEST_DOUBLE, NULL) > 0);
+    assert (thrift_binary_protocol_write_string (protocol,
+                                                 TEST_STRING, NULL) > 0);
+    assert (thrift_binary_protocol_write_binary (protocol, binary, 
+                                                 len, NULL) > 0);
+    assert (thrift_binary_protocol_write_binary (protocol, NULL, 0, NULL) > 0);
+    assert (thrift_binary_protocol_write_binary (protocol, binary,
+                                                 len, NULL) > 0);
+
+    /* test write errors */
+    transport_write_error = 1;
+    assert (thrift_binary_protocol_write_byte (protocol, TEST_BYTE, 
+                                               NULL) == -1);
+    assert (thrift_binary_protocol_write_i16 (protocol, TEST_I16, NULL) == -1);
+    assert (thrift_binary_protocol_write_i32 (protocol, TEST_I32, NULL) == -1);
+    assert (thrift_binary_protocol_write_i64 (protocol, TEST_I64, NULL) == -1);
+    assert (thrift_binary_protocol_write_double (protocol, TEST_DOUBLE,
+                                                 NULL) == -1);
+    assert (thrift_binary_protocol_write_binary (protocol, binary, len,
+                                                 NULL) == -1);
+    transport_write_error = 0;
+
+    /* test binary partial failure */
+    transport_write_count = 0;
+    transport_write_error_at = 1;
+    assert (thrift_binary_protocol_write_binary (protocol, binary,
+                                                 len, NULL) == -1);
+    transport_write_error_at = -1;
+
+    /* clean up */
+    thrift_transport_close (transport, NULL);
+    g_object_unref (tsocket);
+    g_object_unref (protocol);
+    assert (wait (&status) == pid);
+    assert (status == 0);
+  }
+}
+
+static void
+test_read_and_write_complex_types (void)
+{
+  int status;
+  pid_t pid;
+  ThriftSocket *tsocket = NULL;
+  ThriftTransport *transport = NULL;
+  ThriftBinaryProtocol *tb = NULL;
+  ThriftProtocol *protocol = NULL;
+  int port = TEST_PORT;
+
+  /* fork a server from the client */
+  pid = fork ();
+  assert (pid >= 0);
+
+  if (pid == 0)
+  {
+    /* child listens */
+    thrift_server_complex_types (port);
+    exit (0);
+  } else {
+    /* parent.  wait a bit for the socket to be created. */
+    sleep (1);
+
+    /* create a ThriftSocket */
+    tsocket = g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost",
+                            "port", port, NULL);
+    transport = THRIFT_TRANSPORT (tsocket);
+    thrift_transport_open (transport, NULL);
+    assert (thrift_transport_is_open (transport));
+
+    /* create a ThriftBinaryTransport */
+    tb = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, "transport",
+                       tsocket, NULL);
+    protocol = THRIFT_PROTOCOL (tb);
+    assert (protocol != NULL);
+
+    /* test structures */
+    assert (thrift_binary_protocol_write_struct_begin (protocol, 
+                                                       NULL, NULL) == 0);
+    assert (thrift_binary_protocol_write_struct_end (protocol, NULL) == 0);
+
+    assert (thrift_binary_protocol_write_field_begin (protocol, "test", T_VOID,
+                                                      1, NULL) > 0);
+    assert (thrift_binary_protocol_write_field_end (protocol, NULL) == 0);
+
+    /* test write error */
+    transport_write_error = 1;
+    assert (thrift_binary_protocol_write_field_begin (protocol, "test", T_VOID, 
+                                                      1, NULL) == -1);
+    transport_write_error = 0;
+
+    /* test 2nd write error */
+    transport_write_count = 0;
+    transport_write_error_at = 1;
+    assert (thrift_binary_protocol_write_field_begin (protocol, "test", T_VOID,
+                                                      1, NULL) == -1);
+    transport_write_error_at = -1;
+
+    /* test 2nd read failure on a field */
+    thrift_binary_protocol_write_byte (protocol, T_VOID, NULL);
+
+    /* test write_field_stop */
+    assert (thrift_binary_protocol_write_field_stop (protocol, NULL) > 0);
+
+    /* write a map */
+    assert (thrift_binary_protocol_write_map_begin (protocol, T_VOID, T_VOID,
+                                                    1, NULL) > 0);
+    assert (thrift_binary_protocol_write_map_end (protocol, NULL) == 0);
+
+    /* test 2nd read failure on a map */
+    thrift_binary_protocol_write_byte (protocol, T_VOID, NULL);
+
+    /* test 3rd read failure on a map */
+    thrift_binary_protocol_write_byte (protocol, T_VOID, NULL);
+    thrift_binary_protocol_write_byte (protocol, T_VOID, NULL);
+
+    /* test 1st write failure on a map */
+    transport_write_error = 1;
+    assert (thrift_binary_protocol_write_map_begin (protocol, T_VOID, T_VOID,
+                                                    1, NULL) == -1);
+    transport_write_error = 0;
+
+    /* test 2nd write failure on a map */
+    transport_write_count = 0;
+    transport_write_error_at = 1;
+    assert (thrift_binary_protocol_write_map_begin (protocol, T_VOID, T_VOID,
+                                                    1, NULL) == -1);
+    transport_write_error_at = -1;
+
+    /* test 3rd write failure on a map */
+    transport_write_count = 0;
+    transport_write_error_at = 2;
+    assert (thrift_binary_protocol_write_map_begin (protocol, T_VOID, T_VOID,
+                                                    1, NULL) == -1);
+    transport_write_error_at = -1;
+
+    /* test negative map size */
+    thrift_binary_protocol_write_byte (protocol, T_VOID, NULL);
+    thrift_binary_protocol_write_byte (protocol, T_VOID, NULL);
+    thrift_binary_protocol_write_i32 (protocol, -10, NULL);
+
+    /* test list operations */
+    assert (thrift_binary_protocol_write_list_begin (protocol, T_VOID,
+                                                     1, NULL) > 0);
+    assert (thrift_binary_protocol_write_list_end (protocol, NULL) == 0);
+
+    /* test 2nd read failure on a list */
+    thrift_binary_protocol_write_byte (protocol, T_VOID, NULL);
+
+    /* test negative list size */
+    thrift_binary_protocol_write_byte (protocol, T_VOID, NULL);
+    thrift_binary_protocol_write_i32 (protocol, -10, NULL);
+
+    /* test first write error on a list */
+    transport_write_error = 1;
+    assert (thrift_binary_protocol_write_list_begin (protocol, T_VOID,
+                                                     1, NULL) == -1);
+    transport_write_error = 0;
+
+    /* test 2nd write error on a list */
+    transport_write_count = 0;
+    transport_write_error_at = 1;
+    assert (thrift_binary_protocol_write_list_begin (protocol, T_VOID,
+                                                     1, NULL) == -1);
+    transport_write_error_at = -1;
+
+    /* test set operation s*/
+    assert (thrift_binary_protocol_write_set_begin (protocol, T_VOID,
+                                                    1, NULL) > 0);
+    assert (thrift_binary_protocol_write_set_end (protocol, NULL) == 0);
+
+    /* invalid version */
+    assert (thrift_binary_protocol_write_i32 (protocol, -1, NULL) > 0);
+
+    /* sz > 0 for a message */
+    assert (thrift_binary_protocol_write_i32 (protocol, 1, NULL) > 0);
+
+    /* send a valid message */
+    thrift_binary_protocol_write_i32 (protocol, 0x80010000, NULL);
+    thrift_binary_protocol_write_string (protocol, "test", NULL);
+    thrift_binary_protocol_write_i32 (protocol, 1, NULL);
+
+    /* broken 2nd read */
+    thrift_binary_protocol_write_i32 (protocol, 0x80010000, NULL);
+
+    /* send a broken 3rd read */
+    thrift_binary_protocol_write_i32 (protocol, 0x80010000, NULL);
+    thrift_binary_protocol_write_string (protocol, "test", NULL);
+
+    /* send a valid message */
+    assert (thrift_binary_protocol_write_message_begin (protocol, "test",
+                                                        T_CALL, 1, NULL) > 0);
+
+    assert (thrift_binary_protocol_write_message_end (protocol, NULL) == 0);
+
+    /* send broken writes */
+    transport_write_error = 1;
+    assert (thrift_binary_protocol_write_message_begin (protocol, "test",
+                                                        T_CALL, 1, NULL) == -1);
+    transport_write_error = 0;
+
+    transport_write_count = 0;
+    transport_write_error_at = 2;
+    assert (thrift_binary_protocol_write_message_begin (protocol, "test",
+                                                        T_CALL, 1, NULL) == -1);
+    transport_write_error_at = -1;
+
+    transport_write_count = 0;
+    transport_write_error_at = 3;
+    assert (thrift_binary_protocol_write_message_begin (protocol, "test",
+                                                        T_CALL, 1, NULL) == -1);
+    transport_write_error_at = -1;
+
+    /* clean up */
+    thrift_transport_close (transport, NULL);
+    g_object_unref (tsocket);
+    g_object_unref (protocol);
+    assert (wait (&status) == pid);
+    assert (status == 0);
+  }
+}
+
+
+static void
+thrift_server_primitives (const int port)
+{
+  ThriftServerTransport *transport = NULL;
+  ThriftTransport *client = NULL;
+  ThriftBinaryProtocol *tbp = NULL;
+  ThriftProtocol *protocol = NULL;
+  gboolean value_boolean = FALSE;
+  gint8 value_byte = 0;
+  gint16 value_16 = 0;
+  gint32 value_32 = 0;
+  gint64 value_64 = 0;
+  gdouble value_double = 0;
+  gchar *string = NULL;
+  gpointer binary = NULL;
+  guint32 len = 0;
+  void *comparator = (void *) TEST_STRING;
+
+  ThriftServerSocket *tsocket = g_object_new (THRIFT_TYPE_SERVER_SOCKET,
+                                              "port", port, NULL);
+  transport = THRIFT_SERVER_TRANSPORT (tsocket);
+  thrift_server_transport_listen (transport, NULL);
+  client = thrift_server_transport_accept (transport, NULL);
+  assert (client != NULL);
+
+  tbp = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, "transport",
+                      client, NULL);
+  protocol = THRIFT_PROTOCOL (tbp);
+
+  assert (thrift_binary_protocol_read_bool (protocol,
+                                            &value_boolean, NULL) > 0);
+  assert (thrift_binary_protocol_read_byte (protocol, &value_byte, NULL) > 0);
+  assert (thrift_binary_protocol_read_i16 (protocol, &value_16, NULL) > 0);
+  assert (thrift_binary_protocol_read_i32 (protocol, &value_32, NULL) > 0);
+  assert (thrift_binary_protocol_read_i64 (protocol, &value_64, NULL) > 0);
+  assert (thrift_binary_protocol_read_double (protocol,
+                                              &value_double, NULL) > 0);
+  assert (thrift_binary_protocol_read_string (protocol, &string, NULL) > 0);
+  assert (thrift_binary_protocol_read_binary (protocol, &binary,
+                                              &len, NULL) > 0);
+
+  assert (value_boolean == TEST_BOOL);
+  assert (value_byte = TEST_BYTE);
+  assert (value_16 = TEST_I16);
+  assert (value_32 = TEST_I32);
+  assert (value_64 = TEST_I64);
+  assert (value_double = TEST_DOUBLE);
+  assert (strcmp (TEST_STRING, string) == 0);
+  assert (memcmp (comparator, binary, len) == 0);
+
+  g_free (string);
+  g_free (binary);
+
+  thrift_binary_protocol_read_binary (protocol, &binary, &len, NULL);
+  g_free (binary);
+
+  transport_read_count = 0;
+  transport_read_error_at = 0;
+  assert (thrift_binary_protocol_read_binary (protocol, &binary,
+                                              &len, NULL) == -1);
+  transport_read_error_at = -1;
+
+  transport_read_count = 0;
+  transport_read_error_at = 1;
+  assert (thrift_binary_protocol_read_binary (protocol, &binary,
+                                              &len, NULL) == -1);
+  transport_read_error_at = -1;
+
+  transport_read_error = 1;
+  assert (thrift_binary_protocol_read_bool (protocol,
+                                            &value_boolean, NULL) == -1);
+  assert (thrift_binary_protocol_read_byte (protocol,
+                                            &value_byte, NULL) == -1);
+  assert (thrift_binary_protocol_read_i16 (protocol,
+                                           &value_16, NULL) == -1);
+  assert (thrift_binary_protocol_read_i32 (protocol, &value_32, NULL) == -1);
+  assert (thrift_binary_protocol_read_i64 (protocol, &value_64, NULL) == -1);
+  assert (thrift_binary_protocol_read_double (protocol,
+                                              &value_double, NULL) == -1);
+  transport_read_error = 0;
+
+  /* test partial write failure */
+  thrift_protocol_read_i32 (protocol, &value_32, NULL);
+
+  thrift_transport_read_end (client, NULL);
+  thrift_transport_close (client, NULL);
+
+  g_object_unref (tbp);
+  g_object_unref (client);
+  g_object_unref (tsocket);
+}
+
+static void
+thrift_server_complex_types (const int port)
+{
+  ThriftServerTransport *transport = NULL;
+  ThriftTransport *client = NULL;
+  ThriftBinaryProtocol *tbp = NULL;
+  ThriftProtocol *protocol = NULL;
+  gchar *struct_name = NULL;
+  gchar *field_name = NULL;
+  gchar *message_name = NULL;
+  ThriftType element_type, key_type, value_type, field_type;
+  ThriftMessageType message_type;
+  gint8 value = 0;
+  gint16 field_id = 0;
+  guint32 size = 0;
+  gint32 seqid = 0;
+  gint32 version = 0;
+
+  ThriftServerSocket *tsocket = g_object_new (THRIFT_TYPE_SERVER_SOCKET,
+                                              "port", port, NULL);
+  transport = THRIFT_SERVER_TRANSPORT (tsocket);
+  thrift_server_transport_listen (transport, NULL);
+  client = thrift_server_transport_accept (transport, NULL);
+  assert (client != NULL);
+
+  tbp = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, "transport",
+                      client, NULL);
+  protocol = THRIFT_PROTOCOL (tbp);
+
+  thrift_binary_protocol_read_struct_begin (protocol, &struct_name, NULL);
+  thrift_binary_protocol_read_struct_end (protocol, NULL);
+
+  thrift_binary_protocol_read_field_begin (protocol, &field_name, &field_type,
+                                           &field_id, NULL);
+  thrift_binary_protocol_read_field_end (protocol, NULL);
+
+  /* test first read error on a field */
+  transport_read_error = 1;
+  assert (thrift_binary_protocol_read_field_begin (protocol,
+                                                   &field_name, &field_type,
+                                                   &field_id, NULL) == -1);
+  transport_read_error = 0;
+
+  /* test 2nd write failure */
+  thrift_binary_protocol_read_byte (protocol, &value, NULL);
+
+  /* test 2nd read failure on a field */
+  transport_read_count = 0;
+  transport_read_error_at = 1;
+  assert (thrift_binary_protocol_read_field_begin (protocol,
+                                                   &field_name, &field_type,
+                                                   &field_id, NULL) == -1);
+  transport_read_error_at = -1;
+
+  /* test field stop */
+  thrift_binary_protocol_read_field_begin (protocol, &field_name, &field_type,
+                                           &field_id, NULL);
+
+  thrift_binary_protocol_read_map_begin (protocol, &key_type, &value_type,
+                                         &size, NULL);
+  thrift_binary_protocol_read_map_end (protocol, NULL);
+
+  /* test read failure on a map */
+  transport_read_count = 0;
+  transport_read_error_at = 0;
+  assert (thrift_binary_protocol_read_map_begin (protocol,
+                                                 &key_type, &value_type,
+                                                 &size, NULL) == -1);
+  transport_read_error_at = -1;
+
+  /* test 2nd read failure on a map */
+  transport_read_count = 0;
+  transport_read_error_at = 1;
+  assert (thrift_binary_protocol_read_map_begin (protocol,
+                                                 &key_type, &value_type,
+                                                 &size, NULL) == -1);
+  transport_read_error_at = -1;
+
+  /* test 3rd read failure on a map */
+  transport_read_count = 0;
+  transport_read_error_at = 2;
+  assert (thrift_binary_protocol_read_map_begin (protocol,
+                                                 &key_type, &value_type,
+                                                 &size, NULL) == -1);
+  transport_read_error_at = -1;
+
+  /* test 2nd write failure */
+  thrift_binary_protocol_read_byte (protocol, &value, NULL);
+
+  /* test 3rd write failure */
+  thrift_binary_protocol_read_byte (protocol, &value, NULL);
+  thrift_binary_protocol_read_byte (protocol, &value, NULL);
+
+  /* test negative map size */
+  assert (thrift_binary_protocol_read_map_begin (protocol,
+                                                 &key_type, &value_type,
+                                                 &size, NULL) == -1);
+
+  /* test list operations */
+  thrift_binary_protocol_read_list_begin (protocol, &element_type, &size, NULL);
+  thrift_binary_protocol_read_list_end (protocol, NULL);
+
+  /* test read failure */
+  transport_read_error = 1;
+  assert (thrift_binary_protocol_read_list_begin (protocol, &element_type,
+                                                  &size, NULL) == -1);
+  transport_read_error = 0;
+
+  /* test 2nd read failure */
+  transport_read_count = 0;
+  transport_read_error_at = 1;
+  thrift_binary_protocol_read_list_begin (protocol, &element_type, &size, NULL);
+  transport_read_error_at = -1;
+
+  /* test negative list size failure */
+  thrift_binary_protocol_read_list_begin (protocol, &element_type, &size, NULL);
+
+  /* test 2nd write failure */
+  thrift_binary_protocol_read_byte (protocol, &value, NULL);
+
+  /* test set operations */
+  thrift_binary_protocol_read_set_begin (protocol, &element_type, &size, NULL);
+  thrift_binary_protocol_read_set_end (protocol, NULL);
+
+  /* broken read */
+  transport_read_error = 1;
+  assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
+                                                     &message_type, &seqid,
+                                                     NULL) == -1);
+  transport_read_error = 0;
+
+  /* invalid protocol version */
+  assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
+                                                     &message_type, &seqid,
+                                                     NULL) == -1);
+
+  /* sz > 0 */
+  assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
+                                                     &message_type, &seqid,
+                                                     NULL) > 0);
+
+  /* read a valid message */
+  assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
+                                                     &message_type, &seqid,
+                                                     NULL) > 0);
+  g_free (message_name);
+
+  /* broken 2nd read on a message */
+  transport_read_count = 0;
+  transport_read_error_at = 1;
+  assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
+                                                     &message_type, &seqid,
+                                                     NULL) == -1);
+  transport_read_error_at = -1;
+
+  /* broken 3rd read on a message */
+  transport_read_count = 0;
+  transport_read_error_at = 3; /* read_string does two reads */
+  assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
+                                                     &message_type, &seqid,
+                                                     NULL) == -1);
+  g_free (message_name);
+  transport_read_error_at = -1;
+
+  /* read a valid message */
+  assert (thrift_binary_protocol_read_message_begin (protocol, &message_name,
+                                                     &message_type, &seqid, 
+                                                     NULL) > 0);
+  g_free (message_name);
+
+  assert (thrift_binary_protocol_read_message_end (protocol, NULL) == 0);
+
+  /* handle 2nd write failure on a message */
+  thrift_binary_protocol_read_i32 (protocol, &version, NULL);
+
+  /* handle 2nd write failure on a message */
+  thrift_binary_protocol_read_i32 (protocol, &version, NULL);
+  thrift_binary_protocol_read_string (protocol, &message_name, NULL);
+
+  g_object_unref (client);
+  /* TODO: investigate g_object_unref (tbp); */
+  g_object_unref (tsocket);
+}
+
+int
+main(int argc, char *argv[])
+{
+#if (!GLIB_CHECK_VERSION (2, 36, 0))
+  g_type_init();
+#endif
+
+  g_test_init (&argc, &argv, NULL);
+
+  g_test_add_func ("/testbinaryprotocol/CreateAndDestroy", test_create_and_destroy);
+  g_test_add_func ("/testbinaryprotocol/Initialize", test_initialize);
+  g_test_add_func ("/testbinaryprotocol/ReadAndWritePrimitives", test_read_and_write_primitives);
+  g_test_add_func ("/testbinaryprotocol/ReadAndWriteComplexTypes", test_read_and_write_complex_types);
+
+  return g_test_run ();
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/c_glib/test/testbufferedtransport.c
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/c_glib/test/testbufferedtransport.c b/depends/thirdparty/thrift/lib/c_glib/test/testbufferedtransport.c
new file mode 100755
index 0000000..3203a66
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/c_glib/test/testbufferedtransport.c
@@ -0,0 +1,287 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <assert.h>
+#include <netdb.h>
+#include <signal.h>
+#include <sys/wait.h>
+
+#include <thrift/c_glib/transport/thrift_transport.h>
+#include <thrift/c_glib/transport/thrift_socket.h>
+#include <thrift/c_glib/transport/thrift_server_transport.h>
+#include <thrift/c_glib/transport/thrift_server_socket.h>
+
+#define TEST_DATA { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' }
+
+#include "../src/thrift/c_glib/transport/thrift_buffered_transport.c"
+
+static void thrift_server (const int port);
+
+/* test object creation and destruction */
+static void
+test_create_and_destroy(void)
+{
+  ThriftTransport *transport = NULL;
+  guint r_buf_size = 0;
+  guint w_buf_size = 0;
+
+  GObject *object = NULL;
+  object = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT, NULL);
+  assert (object != NULL);
+  g_object_get (G_OBJECT (object), "transport", &transport,
+                "r_buf_size", &r_buf_size,
+                "w_buf_size", &w_buf_size, NULL);
+  g_object_unref (object);
+}
+
+static void
+test_open_and_close(void)
+{
+  ThriftSocket *tsocket = NULL;
+  ThriftTransport *transport = NULL;
+  GError *err = NULL;
+
+  /* create a ThriftSocket */
+  tsocket = g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost",
+                          "port", 51188, NULL); 
+
+  /* create a BufferedTransport wrapper of the Socket */
+  transport = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT,
+                            "transport", THRIFT_TRANSPORT (tsocket), NULL);
+
+  /* this shouldn't work */
+  assert (thrift_buffered_transport_open (transport, NULL) == FALSE);
+  assert (thrift_buffered_transport_is_open (transport) == TRUE);
+  assert (thrift_buffered_transport_close (transport, NULL) == TRUE);
+  g_object_unref (transport);
+  g_object_unref (tsocket);
+
+  /* try and underlying socket failure */
+  tsocket = g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost.broken",
+                          NULL);
+
+  /* create a BufferedTransport wrapper of the Socket */
+  transport = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT,
+                            "transport", THRIFT_TRANSPORT (tsocket), NULL);
+
+  assert (thrift_buffered_transport_open (transport, &err) == FALSE);
+  g_object_unref (transport);
+  g_object_unref (tsocket);
+  g_error_free (err);
+  err = NULL;
+}
+
+static void
+test_read_and_write(void)
+{
+  int status;
+  pid_t pid;
+  ThriftSocket *tsocket = NULL;
+  ThriftTransport *transport = NULL;
+  int port = 51199;
+  guchar buf[10] = TEST_DATA; /* a buffer */
+
+  pid = fork ();
+  assert ( pid >= 0 );
+
+  if ( pid == 0 )
+  {
+    /* child listens */
+    thrift_server (port);
+    exit (0);
+  } else {
+    /* parent connects, wait a bit for the socket to be created */
+    sleep (1);
+
+    tsocket = g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost",
+                            "port", port, NULL);
+    transport = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT,
+                              "transport", THRIFT_TRANSPORT (tsocket),
+                              "w_buf_size", 4, NULL);
+
+    assert (thrift_buffered_transport_open (transport, NULL) == TRUE);
+    assert (thrift_buffered_transport_is_open (transport));
+
+    /* write 10 bytes */
+    thrift_buffered_transport_write (transport, buf, 10, NULL);
+
+    /* write 1 byte at a time */
+    thrift_buffered_transport_write (transport, buf, 1, NULL);
+    thrift_buffered_transport_write (transport, buf, 1, NULL);
+    thrift_buffered_transport_write (transport, buf, 1, NULL);
+
+    /* overflow the buffer */
+    thrift_buffered_transport_write (transport, buf, 2, NULL);
+    thrift_buffered_transport_write (transport, buf, 1, NULL);
+    thrift_buffered_transport_flush (transport, NULL);
+
+    /* write 1 byte and flush */
+    thrift_buffered_transport_write (transport, buf, 1, NULL);
+    thrift_buffered_transport_flush (transport, NULL);
+
+    /* write and overflow buffer with 2 system calls */
+    thrift_buffered_transport_write (transport, buf, 1, NULL);
+    thrift_buffered_transport_write (transport, buf, 3, NULL);
+
+    /* write 10 bytes */
+    thrift_buffered_transport_write (transport, buf, 10, NULL);
+
+    thrift_buffered_transport_write_end (transport, NULL);
+    thrift_buffered_transport_flush (transport, NULL);
+    thrift_buffered_transport_close (transport, NULL);
+
+    g_object_unref (transport);
+    g_object_unref (tsocket);
+
+    assert ( wait (&status) == pid );
+    assert ( status == 0 );
+  }
+}
+
+static void
+thrift_server (const int port)
+{
+  int bytes = 0;
+  ThriftServerTransport *transport = NULL;
+  ThriftTransport *client = NULL;
+  guchar buf[10]; /* a buffer */
+  guchar match[10] = TEST_DATA;
+
+  ThriftServerSocket *tsocket = g_object_new (THRIFT_TYPE_SERVER_SOCKET,
+                                              "port", port, NULL);
+
+  transport = THRIFT_SERVER_TRANSPORT (tsocket);
+  thrift_server_transport_listen (transport, NULL);
+
+  /* wrap the client in a BufferedTransport */
+  client = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT, "transport",
+                         thrift_server_transport_accept (transport, NULL),
+                         "r_buf_size", 5, NULL);
+  assert (client != NULL);
+
+  /* read 10 bytes */
+  bytes = thrift_buffered_transport_read (client, buf, 10, NULL);
+  assert (bytes == 10); /* make sure we've read 10 bytes */
+  assert ( memcmp (buf, match, 10) == 0 ); /* make sure what we got matches */
+
+  /* read 1 byte */
+  bytes = thrift_buffered_transport_read (client, buf, 1, NULL);
+
+  bytes = thrift_buffered_transport_read (client, buf, 6, NULL);
+  bytes = thrift_buffered_transport_read (client, buf, 2, NULL);
+  bytes = thrift_buffered_transport_read (client, buf, 1, NULL);
+
+  thrift_buffered_transport_read_end (client, NULL);
+  thrift_buffered_transport_close (client, NULL);
+  g_object_unref (client);
+  g_object_unref (tsocket);
+}
+
+static void
+test_write_fail(void)
+{
+  int status;
+  pid_t pid;
+  ThriftSocket *tsocket = NULL;
+  ThriftTransport *transport = NULL;
+  int port = 51198;
+  guchar buf[10] = TEST_DATA; /* a buffer */
+
+  /* SIGPIPE when send to disconnected socket */
+  signal(SIGPIPE, SIG_IGN);
+
+  pid = fork ();
+  assert ( pid >= 0 );
+
+  if ( pid == 0 )
+  {
+    /* child listens */
+    ThriftServerTransport *transport = NULL;
+    ThriftTransport *client = NULL;
+
+    ThriftServerSocket *tsocket = g_object_new (THRIFT_TYPE_SERVER_SOCKET,
+        "port", port, NULL);
+
+    transport = THRIFT_SERVER_TRANSPORT (tsocket);
+    thrift_server_transport_listen (transport, NULL);
+
+    /* wrap the client in a BufferedTransport */
+    client = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT, "transport",
+        thrift_server_transport_accept (transport, NULL),
+        "r_buf_size", 5, NULL);
+    assert (client != NULL);
+
+    /* just close socket */
+    thrift_buffered_transport_close (client, NULL);
+    g_object_unref (client);
+    g_object_unref (tsocket);
+    exit (0);
+  } else {
+    /* parent connects, wait a bit for the socket to be created */
+    sleep (1);
+
+    tsocket = g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost",
+                            "port", port, NULL);
+    transport = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT,
+                              "transport", THRIFT_TRANSPORT (tsocket),
+                              "w_buf_size", 4, NULL);
+
+
+    assert (thrift_buffered_transport_open (transport, NULL) == TRUE);
+    assert (thrift_buffered_transport_is_open (transport));
+
+    /* recognize disconnection */
+    sleep(1);
+    assert (thrift_buffered_transport_write (transport, buf, 10, NULL) == TRUE);
+    assert (thrift_buffered_transport_write (transport, buf, 10, NULL) == FALSE);
+
+    /* write and overflow buffer */
+    assert (thrift_buffered_transport_write (transport, buf, 10, NULL) == FALSE);
+
+    /* write 1 and flush */
+    assert (thrift_buffered_transport_write (transport, buf, 1, NULL) == TRUE);
+    assert (thrift_buffered_transport_flush (transport, NULL) == FALSE);
+
+    thrift_buffered_transport_close (transport, NULL);
+
+    g_object_unref (transport);
+    g_object_unref (tsocket);
+
+    assert ( wait (&status) == pid );
+    assert ( status == 0 );
+  }
+}
+
+int
+main(int argc, char *argv[])
+{
+#if (!GLIB_CHECK_VERSION (2, 36, 0))
+  g_type_init();
+#endif
+
+  g_test_init (&argc, &argv, NULL);
+
+  g_test_add_func ("/testbufferedtransport/CreateAndDestroy", test_create_and_destroy);
+  g_test_add_func ("/testbufferedtransport/OpenAndClose", test_open_and_close);
+  g_test_add_func ("/testbufferedtransport/ReadAndWrite", test_read_and_write);
+  g_test_add_func ("/testbufferedtransport/WriteFail", test_write_fail);
+
+  return g_test_run ();
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d709f67d/depends/thirdparty/thrift/lib/c_glib/test/testcontainertest.c
----------------------------------------------------------------------
diff --git a/depends/thirdparty/thrift/lib/c_glib/test/testcontainertest.c b/depends/thirdparty/thrift/lib/c_glib/test/testcontainertest.c
new file mode 100644
index 0000000..852254b
--- /dev/null
+++ b/depends/thirdparty/thrift/lib/c_glib/test/testcontainertest.c
@@ -0,0 +1,530 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "gen-c_glib/t_test_container_test_types.h"
+#include "gen-c_glib/t_test_container_service.h"
+
+#include <thrift/c_glib/thrift.h>
+#include <thrift/c_glib/protocol/thrift_binary_protocol_factory.h>
+#include <thrift/c_glib/protocol/thrift_binary_protocol.h>
+#include <thrift/c_glib/protocol/thrift_protocol_factory.h>
+#include <thrift/c_glib/server/thrift_server.h>
+#include <thrift/c_glib/server/thrift_simple_server.h>
+#include <thrift/c_glib/transport/thrift_buffered_transport_factory.h>
+#include <thrift/c_glib/transport/thrift_buffered_transport.h>
+#include <thrift/c_glib/transport/thrift_server_socket.h>
+#include <thrift/c_glib/transport/thrift_server_transport.h>
+#include <thrift/c_glib/transport/thrift_socket.h>
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include <unistd.h>
+#include <signal.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+
+#define TEST_SERVER_HOSTNAME "localhost"
+#define TEST_SERVER_PORT     9090
+
+/* --------------------------------------------------------------------------
+   The ContainerService handler we'll use for testing */
+
+G_BEGIN_DECLS
+
+GType test_container_service_handler_get_type (void);
+
+#define TYPE_TEST_CONTAINER_SERVICE_HANDLER \
+  (test_container_service_handler_get_type ())
+
+#define TEST_CONTAINER_SERVICE_HANDLER(obj)                             \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj),                                   \
+                               TYPE_TEST_CONTAINER_SERVICE_HANDLER,     \
+                               TestContainerServiceHandler))
+#define TEST_CONTAINER_SERVICE_HANDLER_CLASS(c)                         \
+  (G_TYPE_CHECK_CLASS_CAST ((c),                                        \
+                            TYPE_TEST_CONTAINER_SERVICE_HANDLER,        \
+                            TestContainerServiceHandlerClass))
+#define IS_TEST_CONTAINER_SERVICE_HANDLER(obj)                          \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj),                                   \
+                               TYPE_TEST_CONTAINER_SERVICE_HANDLER))
+#define IS_TEST_CONTAINER_SERVICE_HANDLER_CLASS(c)                      \
+  (G_TYPE_CHECK_CLASS_TYPE ((c),                                        \
+                            TYPE_TEST_CONTAINER_SERVICE_HANDLER))
+#define TEST_CONTAINER_SERVICE_HANDLER_GET_CLASS(obj)                   \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj),                                    \
+                              TYPE_TEST_CONTAINER_SERVICE_HANDLER,      \
+                              TestContainerServiceHandlerClass))
+
+struct _TestContainerServiceHandler {
+  TTestContainerServiceHandler parent_instance;
+
+  /* private */
+  GPtrArray *string_list;
+};
+typedef struct _TestContainerServiceHandler TestContainerServiceHandler;
+
+struct _TestContainerServiceHandlerClass {
+  TTestContainerServiceHandlerClass parent_class;
+};
+typedef struct _TestContainerServiceHandlerClass
+  TestContainerServiceHandlerClass;
+
+G_END_DECLS
+
+/* -------------------------------------------------------------------------- */
+
+G_DEFINE_TYPE (TestContainerServiceHandler,
+               test_container_service_handler,
+               T_TEST_TYPE_CONTAINER_SERVICE_HANDLER)
+
+/* A helper function used to append copies of strings to a string list */
+static void append_string_to_ptr_array (gpointer element, gpointer ptr_array)
+{
+  g_ptr_array_add ((GPtrArray *)ptr_array, g_strdup ((gchar *)element));
+}
+
+/* Accept a string list from the client and append its contents to our internal
+   list */
+static gboolean
+test_container_service_handler_receive_string_list (TTestContainerServiceIf *iface,
+                                                    const GPtrArray *stringList,
+                                                    GError **error)
+{
+  TestContainerServiceHandler *self = TEST_CONTAINER_SERVICE_HANDLER (iface);
+
+  /* Append the client's strings to our own internal string list */
+  g_ptr_array_foreach ((GPtrArray *)stringList,
+                       append_string_to_ptr_array,
+                       self->string_list);
+
+  g_clear_error (error);
+  return TRUE;
+}
+
+/* Return the contents of our internal string list to the client */
+static gboolean
+test_container_service_handler_return_string_list (TTestContainerServiceIf *iface,
+                                                   GPtrArray **_return,
+                                                   GError **error)
+{
+  TestContainerServiceHandler *self = TEST_CONTAINER_SERVICE_HANDLER (iface);
+
+  /* Return (copies of) the strings contained in our list */
+  g_ptr_array_foreach (self->string_list,
+                       append_string_to_ptr_array,
+                       *_return);
+
+  g_clear_error (error);
+  return TRUE;
+}
+
+static gboolean
+test_container_service_handler_return_list_string_list (TTestContainerServiceIf *iface,
+                                                        GPtrArray **_return,
+                                                        GError **error)
+{
+  TestContainerServiceHandler *self = TEST_CONTAINER_SERVICE_HANDLER (iface);
+  GPtrArray *nested_list;
+
+  /* Return a list containing our list of strings */
+  nested_list
+    = g_ptr_array_new_with_free_func ((GDestroyNotify)g_ptr_array_unref);
+  g_ptr_array_add (nested_list, self->string_list);
+  g_ptr_array_ref (self->string_list);
+
+  g_ptr_array_add (*_return, nested_list);
+
+  g_clear_error (error);
+  return TRUE;
+}
+
+static gboolean
+test_container_service_handler_return_typedefd_list_string_list (TTestContainerServiceIf *iface,
+                                                                 TTestListStringList **_return,
+                                                                 GError **error)
+{
+  TestContainerServiceHandler *self = TEST_CONTAINER_SERVICE_HANDLER (iface);
+  TTestStringList *nested_list;
+
+  /* Return a list containing our list of strings */
+  nested_list
+    = g_ptr_array_new_with_free_func ((GDestroyNotify)g_ptr_array_unref);
+  g_ptr_array_add (nested_list, self->string_list);
+  g_ptr_array_ref (self->string_list);
+
+  g_ptr_array_add (*_return, nested_list);
+
+  g_clear_error (error);
+  return TRUE;
+}
+
+static void
+test_container_service_handler_finalize (GObject *object) {
+  TestContainerServiceHandler *self = TEST_CONTAINER_SERVICE_HANDLER (object);
+
+  /* Destroy our internal containers */
+  g_ptr_array_unref (self->string_list);
+  self->string_list = NULL;
+
+  G_OBJECT_CLASS (test_container_service_handler_parent_class)->
+    finalize (object);
+}
+
+static void
+test_container_service_handler_init (TestContainerServiceHandler *self)
+{
+  /* Create our internal containers */
+  self->string_list = g_ptr_array_new_with_free_func (g_free);
+}
+
+static void
+test_container_service_handler_class_init (TestContainerServiceHandlerClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  TTestContainerServiceHandlerClass *parent_class =
+    T_TEST_CONTAINER_SERVICE_HANDLER_CLASS (klass);
+
+  gobject_class->finalize = test_container_service_handler_finalize;
+
+  parent_class->receive_string_list =
+    test_container_service_handler_receive_string_list;
+  parent_class->return_string_list =
+    test_container_service_handler_return_string_list;
+  parent_class->return_list_string_list =
+    test_container_service_handler_return_list_string_list;
+  parent_class->return_typedefd_list_string_list =
+    test_container_service_handler_return_typedefd_list_string_list;
+}
+
+/* -------------------------------------------------------------------------- */
+
+/* Our test server, declared globally so we can access it within a signal
+   handler */
+ThriftServer *server = NULL;
+
+/* A signal handler used to detect when the child process (the test suite) has
+   exited so we know to shut down the server and terminate ourselves */
+static void
+sigchld_handler (int signal_number)
+{
+  THRIFT_UNUSED_VAR (signal_number);
+
+  /* The child process (the tests) has exited or been terminated; shut down the
+     server gracefully */
+  if (server != NULL)
+    thrift_server_stop (server);
+}
+
+/* A helper function that executes a test case against a newly constructed
+   service client */
+static void
+execute_with_service_client (void (*test_case)(TTestContainerServiceIf *,
+                                               GError **))
+{
+  ThriftSocket *socket;
+  ThriftTransport *transport;
+  ThriftProtocol *protocol;
+
+  TTestContainerServiceIf *client;
+
+  GError *error = NULL;
+
+  /* Create a client with which to access the server */
+  socket    = g_object_new (THRIFT_TYPE_SOCKET,
+                            "hostname", TEST_SERVER_HOSTNAME,
+                            "port",     TEST_SERVER_PORT,
+                            NULL);
+  transport = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT,
+                            "transport", socket,
+                            NULL);
+  protocol  = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL,
+                            "transport", transport,
+                            NULL);
+
+  thrift_transport_open (transport, &error);
+  g_assert_no_error (error);
+
+  client = g_object_new (T_TEST_TYPE_CONTAINER_SERVICE_CLIENT,
+                         "input_protocol",  protocol,
+                         "output_protocol", protocol,
+                         NULL);
+
+  /* Execute the test against this client */
+  (*test_case)(client, &error);
+  g_assert_no_error (error);
+
+  /* Clean up and exit */
+  thrift_transport_close (transport, NULL);
+
+  g_object_unref (client);
+  g_object_unref (protocol);
+  g_object_unref (transport);
+  g_object_unref (socket);
+}
+
+static void
+test_containers_with_default_values (void)
+{
+  TTestContainersWithDefaultValues *default_values;
+  GPtrArray *string_list;
+
+  /* Fetch a new ContainersWithDefaultValues struct and its StringList member */
+  default_values = g_object_new (T_TEST_TYPE_CONTAINERS_WITH_DEFAULT_VALUES,
+                                 NULL);
+  g_object_get (default_values,
+                "StringList", &string_list,
+                NULL);
+
+  /* Make sure the list has been populated with its default values */
+  g_assert_cmpint (string_list->len, ==, 2);
+  g_assert_cmpstr (((gchar **)string_list->pdata)[0], ==, "Apache");
+  g_assert_cmpstr (((gchar **)string_list->pdata)[1], ==, "Thrift");
+
+  g_ptr_array_unref (string_list);
+  g_object_unref (default_values);
+}
+
+static void
+test_container_service_string_list_inner (TTestContainerServiceIf *client,
+                                          GError **error)
+{
+  gchar *test_data[] = { "one", "two", "three" };
+
+  GPtrArray *outgoing_string_list;
+  GPtrArray *incoming_string_list;
+  guint index;
+
+  g_clear_error (error);
+
+  /* Prepare our test data (our string list to send) */
+  outgoing_string_list = g_ptr_array_new ();
+  for (index = 0; index < 3; index += 1)
+    g_ptr_array_add (outgoing_string_list, &test_data[index]);
+
+  /* Send our data to the server and make sure we get the same data back on
+     retrieve */
+  g_assert
+    (t_test_container_service_client_receive_string_list (client,
+                                                          outgoing_string_list,
+                                                          error) &&
+     *error == NULL);
+
+  incoming_string_list = g_ptr_array_new ();
+  g_assert
+    (t_test_container_service_client_return_string_list (client,
+                                                         &incoming_string_list,
+                                                         error) &&
+     *error == NULL);
+
+  /* Make sure the two lists are equivalent */
+  g_assert_cmpint (incoming_string_list->len, ==, outgoing_string_list->len);
+  for (index = 0; index < incoming_string_list->len; index += 1)
+    g_assert_cmpstr (((gchar **)incoming_string_list->pdata)[index],
+                     ==,
+                     ((gchar **)outgoing_string_list->pdata)[index]);
+
+  /* Clean up and exit */
+  g_ptr_array_unref (incoming_string_list);
+  g_ptr_array_unref (outgoing_string_list);
+}
+
+static void
+test_container_service_string_list (void)
+{
+    execute_with_service_client (test_container_service_string_list_inner);
+}
+
+static void
+test_container_service_list_string_list_inner (TTestContainerServiceIf *client,
+                                               GError **error)
+{
+  GPtrArray *incoming_list;
+  GPtrArray *nested_list;
+
+  g_clear_error (error);
+
+  /* Receive a list of string lists from the server */
+  incoming_list =
+    g_ptr_array_new_with_free_func ((GDestroyNotify)g_ptr_array_unref);
+  g_assert
+    (t_test_container_service_client_return_list_string_list (client,
+                                                              &incoming_list,
+                                                              error) &&
+     *error == NULL);
+
+  /* Make sure the list and its contents are valid */
+  g_assert_cmpint (incoming_list->len, >, 0);
+
+  nested_list = (GPtrArray *)g_ptr_array_index (incoming_list, 0);
+  g_assert (nested_list != NULL);
+  g_assert_cmpint (nested_list->len, >=, 0);
+
+  /* Clean up and exit */
+  g_ptr_array_unref (incoming_list);
+}
+
+static void
+test_container_service_list_string_list (void)
+{
+  execute_with_service_client (test_container_service_list_string_list_inner);
+}
+
+static void
+test_container_service_typedefd_list_string_list_inner (TTestContainerServiceIf *client,
+                                                        GError **error)
+{
+  TTestListStringList *incoming_list;
+  TTestStringList *nested_list;
+
+  g_clear_error (error);
+
+  /* Receive a list of string lists from the server */
+  incoming_list =
+    g_ptr_array_new_with_free_func ((GDestroyNotify)g_ptr_array_unref);
+  g_assert
+    (t_test_container_service_client_return_list_string_list (client,
+                                                              &incoming_list,
+                                                              error) &&
+     *error == NULL);
+
+  /* Make sure the list and its contents are valid */
+  g_assert_cmpint (incoming_list->len, >, 0);
+
+  nested_list = (TTestStringList *)g_ptr_array_index (incoming_list, 0);
+  g_assert (nested_list != NULL);
+  g_assert_cmpint (nested_list->len, >=, 0);
+
+  /* Clean up and exit */
+  g_ptr_array_unref (incoming_list);
+}
+
+static void
+test_container_service_typedefd_list_string_list (void)
+{
+  execute_with_service_client
+    (test_container_service_typedefd_list_string_list_inner);
+}
+
+int
+main(int argc, char *argv[])
+{
+  pid_t pid;
+  int status;
+
+#if (!GLIB_CHECK_VERSION (2, 36, 0))
+  g_type_init ();
+#endif
+
+  /* Fork to run our test suite in a child process */
+  pid = fork ();
+  g_assert_cmpint (pid, >=, 0);
+
+  if (pid == 0) {    /* The child process */
+    /* Wait a moment for the server to finish starting */
+    sleep (1);
+
+    g_test_init (&argc, &argv, NULL);
+
+    g_test_add_func
+      ("/testcontainertest/ContainerTest/Structs/ContainersWithDefaultValues",
+       test_containers_with_default_values);
+    g_test_add_func
+      ("/testcontainertest/ContainerTest/Services/ContainerService/StringList",
+       test_container_service_string_list);
+    g_test_add_func
+      ("/testcontainertest/ContainerTest/Services/ContainerService/ListStringList",
+       test_container_service_list_string_list);
+    g_test_add_func
+      ("/testcontainertest/ContainerTest/Services/ContainerService/TypedefdListStringList",
+       test_container_service_typedefd_list_string_list);
+
+    /* Run the tests and make the result available to our parent process */
+    _exit (g_test_run ());
+  }
+  else {
+    TTestContainerServiceHandler *handler;
+    TTestContainerServiceProcessor *processor;
+
+    ThriftServerTransport *server_transport;
+    ThriftTransportFactory *transport_factory;
+    ThriftProtocolFactory *protocol_factory;
+
+    struct sigaction sigchld_action;
+
+    GError *error = NULL;
+    int exit_status = 1;
+
+    /* Trap the event of the child process terminating so we know to stop the
+       server and exit */
+    memset (&sigchld_action, 0, sizeof (sigchld_action));
+    sigchld_action.sa_handler = sigchld_handler;
+    sigchld_action.sa_flags = SA_RESETHAND;
+    sigaction (SIGCHLD, &sigchld_action, NULL);
+
+    /* Create our test server */
+    handler = g_object_new (TYPE_TEST_CONTAINER_SERVICE_HANDLER,
+                            NULL);
+    processor = g_object_new (T_TEST_TYPE_CONTAINER_SERVICE_PROCESSOR,
+                              "handler", handler,
+                              NULL);
+    server_transport = g_object_new (THRIFT_TYPE_SERVER_SOCKET,
+                                     "port", TEST_SERVER_PORT,
+                                     NULL);
+    transport_factory = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT_FACTORY,
+                                      NULL);
+    protocol_factory = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL_FACTORY,
+                                     NULL);
+
+    server = g_object_new (THRIFT_TYPE_SIMPLE_SERVER,
+                           "processor",                processor,
+                           "server_transport",         server_transport,
+                           "input_transport_factory",  transport_factory,
+                           "output_transport_factory", transport_factory,
+                           "input_protocol_factory",   protocol_factory,
+                           "output_protocol_factory",  protocol_factory,
+                           NULL);
+
+    /* Start the server */
+    thrift_server_serve (server, &error);
+
+    /* Make sure the server stopped only because it was interrupted (by the
+       child process terminating) */
+    g_assert (g_error_matches (error,
+                               THRIFT_SERVER_SOCKET_ERROR,
+                               THRIFT_SERVER_SOCKET_ERROR_ACCEPT));
+
+    /* Free our resources */
+    g_object_unref (server);
+    g_object_unref (transport_factory);
+    g_object_unref (protocol_factory);
+    g_object_unref (server_transport);
+
+    g_object_unref (processor);
+    g_object_unref (handler);
+
+    /* Wait for the child process to complete and return its exit status */
+    g_assert (wait (&status) == pid);
+    if (WIFEXITED (status))
+      exit_status = WEXITSTATUS (status);
+
+    return exit_status;
+  }
+}
\ No newline at end of file