http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.h b/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.h deleted file mode 100644 index 981577d..0000000 --- a/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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. - */ - -#ifndef _THRIFT_SOCKET_H -#define _THRIFT_SOCKET_H - -#include <glib-object.h> - -#include <thrift/c_glib/transport/thrift_transport.h> - -G_BEGIN_DECLS - -/*! \file thrift_socket.h - * \brief Socket implementation of a Thrift transport. Subclasses the - * ThriftTransport class. - */ - -/* type macros */ -#define THRIFT_TYPE_SOCKET (thrift_socket_get_type ()) -#define THRIFT_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_SOCKET, ThriftSocket)) -#define THRIFT_IS_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_SOCKET)) -#define THRIFT_SOCKET_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_SOCKET, ThriftSocketClass)) -#define THRIFT_IS_SOCKET_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_SOCKET)) -#define THRIFT_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_SOCKET, ThriftSocketClass)) - -typedef struct _ThriftSocket ThriftSocket; - -/*! - * Thrift Socket instance. - */ -struct _ThriftSocket -{ - ThriftTransport parent; - - /* private */ - gchar *hostname; - gshort port; - int sd; - guint8 *buf; - guint32 buf_size; - guint32 buf_len; -}; - -typedef struct _ThriftSocketClass ThriftSocketClass; - -/*! - * Thrift Socket class. - */ -struct _ThriftSocketClass -{ - ThriftTransportClass parent; -}; - -/* used by THRIFT_TYPE_SOCKET */ -GType thrift_socket_get_type (void); - -G_END_DECLS - -#endif
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.c ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.c b/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.c deleted file mode 100644 index 5533437..0000000 --- a/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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 <thrift/c_glib/thrift.h> -#include <thrift/c_glib/transport/thrift_transport.h> - -/* define the GError domain string */ -#define THRIFT_TRANSPORT_ERROR_DOMAIN "thrift-transport-error-quark" - -G_DEFINE_ABSTRACT_TYPE(ThriftTransport, thrift_transport, G_TYPE_OBJECT) - -gboolean -thrift_transport_is_open (ThriftTransport *transport) -{ - return THRIFT_TRANSPORT_GET_CLASS (transport)->is_open (transport); -} - -gboolean -thrift_transport_peek (ThriftTransport *transport, GError **error) -{ - return THRIFT_TRANSPORT_GET_CLASS (transport)->peek (transport, error); -} - -gboolean -thrift_transport_open (ThriftTransport *transport, GError **error) -{ - return THRIFT_TRANSPORT_GET_CLASS (transport)->open (transport, error); -} - -gboolean -thrift_transport_close (ThriftTransport *transport, GError **error) -{ - return THRIFT_TRANSPORT_GET_CLASS (transport)->close (transport, error); -} - -gint32 -thrift_transport_read (ThriftTransport *transport, gpointer buf, - guint32 len, GError **error) -{ - return THRIFT_TRANSPORT_GET_CLASS (transport)->read (transport, buf, - len, error); -} - -gboolean -thrift_transport_read_end (ThriftTransport *transport, GError **error) -{ - return THRIFT_TRANSPORT_GET_CLASS (transport)->read_end (transport, - error); -} - -gboolean -thrift_transport_write (ThriftTransport *transport, const gpointer buf, - const guint32 len, GError **error) -{ - return THRIFT_TRANSPORT_GET_CLASS (transport)->write (transport, buf, - len, error); -} - -gboolean -thrift_transport_write_end (ThriftTransport *transport, GError **error) -{ - return THRIFT_TRANSPORT_GET_CLASS (transport)->write_end (transport, - error); -} - -gboolean -thrift_transport_flush (ThriftTransport *transport, GError **error) -{ - return THRIFT_TRANSPORT_GET_CLASS (transport)->flush (transport, error); -} - -/* by default, peek returns true if and only if the transport is open */ -static gboolean -thrift_transport_real_peek (ThriftTransport *transport, GError **error) -{ - THRIFT_UNUSED_VAR (error); - - return THRIFT_TRANSPORT_GET_CLASS (transport)->is_open (transport); -} - -/* define the GError domain for Thrift transports */ -GQuark -thrift_transport_error_quark (void) -{ - return g_quark_from_static_string (THRIFT_TRANSPORT_ERROR_DOMAIN); -} - -/* class initializer for ThriftTransport */ -static void -thrift_transport_class_init (ThriftTransportClass *cls) -{ - /* set these as virtual methods to be implemented by a subclass */ - cls->is_open = thrift_transport_is_open; - cls->open = thrift_transport_open; - cls->close = thrift_transport_close; - cls->read = thrift_transport_read; - cls->read_end = thrift_transport_read_end; - cls->write = thrift_transport_write; - cls->write_end = thrift_transport_write_end; - cls->flush = thrift_transport_flush; - - /* provide a default implementation for the peek method */ - cls->peek = thrift_transport_real_peek; -} - -static void -thrift_transport_init (ThriftTransport *transport) -{ - THRIFT_UNUSED_VAR (transport); -} http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.h b/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.h deleted file mode 100644 index 5555a5e..0000000 --- a/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * 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. - */ - -#ifndef _THRIFT_TRANSPORT_H -#define _THRIFT_TRANSPORT_H - -#include <glib-object.h> - -G_BEGIN_DECLS - -/*! \file thrift_transport.h - * \brief Abstract class for Thrift transports. - * - * An abstract class is used instead of an interface because: - * - interfaces can't seem to be used as properties. ThriftProtocol has - * a ThriftTransport as an object property. - * - if a method needs to be added that all subclasses can use, a class - * is necessary. - */ - -/* type macros */ -#define THRIFT_TYPE_TRANSPORT (thrift_transport_get_type ()) -#define THRIFT_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_TRANSPORT, ThriftTransport)) -#define THRIFT_IS_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_TRANSPORT)) -#define THRIFT_TRANSPORT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_TRANSPORT, ThriftTransportClass)) -#define THRIFT_IS_TRANSPORT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_TRANSPORT)) -#define THRIFT_TRANSPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_TRANSPORT, ThriftTransportClass)) - -typedef struct _ThriftTransport ThriftTransport; - -/*! - * Thrift Protocol object - */ -struct _ThriftTransport -{ - GObject parent; -}; - -typedef struct _ThriftTransportClass ThriftTransportClass; - -/*! - * Thrift Transport class - */ -struct _ThriftTransportClass -{ - GObjectClass parent; - - /* vtable */ - gboolean (*is_open) (ThriftTransport *transport); - gboolean (*peek) (ThriftTransport *transport, GError **error); - gboolean (*open) (ThriftTransport *transport, GError **error); - gboolean (*close) (ThriftTransport *transport, GError **error); - gint32 (*read) (ThriftTransport *transport, gpointer buf, - guint32 len, GError **error); - gboolean (*read_end) (ThriftTransport *transport, GError **error); - gboolean (*write) (ThriftTransport *transport, const gpointer buf, - const guint32 len, GError **error); - gboolean (*write_end) (ThriftTransport *transport, GError **error); - gboolean (*flush) (ThriftTransport *transport, GError **error); -}; - -/* used by THRIFT_TYPE_TRANSPORT */ -GType thrift_transport_get_type (void); - -/* virtual public methods */ - -/*! - * Checks if this transport is opened. - * \public \memberof ThriftTransportInterface - */ -gboolean thrift_transport_is_open (ThriftTransport *transport); - -/*! - * Open the transport for reading and writing. - * \public \memberof ThriftTransportInterface - */ -gboolean thrift_transport_open (ThriftTransport *transport, GError **error); - -/*! - * Tests whether there is more data to read or if the remote side is still - * open. By default this is true whenever the transport is open, but - * implementations should add logic to test for this condition where possible - * (i.e. on a socket). - * - * This is used by a server to check if it should listen for another request. - * \public \memberof ThriftTransportInterface - */ -gboolean thrift_transport_peek (ThriftTransport *transport, GError **error); - -/*! - * Close the transport. - * \public \memberof ThriftTransportInterface - */ -gboolean thrift_transport_close (ThriftTransport *transport, GError **error); - -/*! - * Read some data into the buffer buf. - * \public \memberof ThriftTransportInterface - */ -gint32 thrift_transport_read (ThriftTransport *transport, gpointer buf, - guint32 len, GError **error); - -/*! - * Called when read is completed. - * \public \memberof ThriftTransportInterface - */ -gboolean thrift_transport_read_end (ThriftTransport *transport, GError **error); - -/*! - * Writes data from a buffer to the transport. - * \public \memberof ThriftTransportInterface - */ -gboolean thrift_transport_write (ThriftTransport *transport, const gpointer buf, - const guint32 len, GError **error); - -/*! - * Called when write is completed. - * \public \memberof ThriftTransportInterface - */ -gboolean thrift_transport_write_end (ThriftTransport *transport, - GError **error); - -/*! - * Flushes any pending data to be written. Typically used with buffered - * transport mechanisms. - * \public \memberof ThriftTransportInterface - */ -gboolean thrift_transport_flush (ThriftTransport *transport, GError **error); - -/* define error/exception types */ -typedef enum -{ - THRIFT_TRANSPORT_ERROR_UNKNOWN, - THRIFT_TRANSPORT_ERROR_HOST, - THRIFT_TRANSPORT_ERROR_SOCKET, - THRIFT_TRANSPORT_ERROR_CONNECT, - THRIFT_TRANSPORT_ERROR_SEND, - THRIFT_TRANSPORT_ERROR_RECEIVE, - THRIFT_TRANSPORT_ERROR_CLOSE -} ThriftTransportError; - -/* define an error domain for GError to use */ -GQuark thrift_transport_error_quark (void); -#define THRIFT_TRANSPORT_ERROR (thrift_transport_error_quark ()) - -/* define macro for invalid socket */ -#define THRIFT_INVALID_SOCKET (-1) - -G_END_DECLS - -#endif /* _THRIFT_TRANSPORT_H */ http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport_factory.c ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport_factory.c b/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport_factory.c deleted file mode 100644 index a2025cf..0000000 --- a/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport_factory.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 <thrift/c_glib/thrift.h> -#include <thrift/c_glib/transport/thrift_transport_factory.h> - -G_DEFINE_TYPE(ThriftTransportFactory, thrift_transport_factory, G_TYPE_OBJECT) - -/* builds a transport from the base transport. */ -ThriftTransport * -thrift_transport_factory_get_transport (ThriftTransportFactory *factory, - ThriftTransport *transport) -{ - THRIFT_UNUSED_VAR (factory); - return transport; -} - -static void -thrift_transport_factory_class_init (ThriftTransportFactoryClass *cls) -{ - cls->get_transport = thrift_transport_factory_get_transport; -} - -static void -thrift_transport_factory_init (ThriftTransportFactory *factory) -{ - THRIFT_UNUSED_VAR (factory); -} http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport_factory.h ---------------------------------------------------------------------- diff --git a/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport_factory.h b/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport_factory.h deleted file mode 100644 index 0e3da30..0000000 --- a/depends/thirdparty/thrift/lib/c_glib/src/thrift/c_glib/transport/thrift_transport_factory.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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. - */ - -#ifndef _THRIFT_TRANSPORT_FACTORY_H -#define _THRIFT_TRANSPORT_FACTORY_H - -#include <glib-object.h> - -#include "thrift_transport.h" - -G_BEGIN_DECLS - -/*! \file thrift_transport_factory.h - * \brief Base class for Thrift Transport Factories. Used by Thrift Servers - * to obtain a client transport from an existing transport. The default - * implementation simply clones the provided transport. - */ - -/* type macros */ -#define THRIFT_TYPE_TRANSPORT_FACTORY (thrift_transport_factory_get_type ()) -#define THRIFT_TRANSPORT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_TRANSPORT_FACTORY, ThriftTransportFactory)) -#define THRIFT_IS_TRANSPORT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_TRANSPORT_FACTORY)) -#define THRIFT_TRANSPORT_FACTORY_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_TRANSPORT_FACTORY, ThriftTransportFactoryClass)) -#define THRIFT_IS_TRANSPORT_FACTORY_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_TRANSPORT_FACTORY)) -#define THRIFT_TRANSPORT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_TRANSPORT_FACTORY, ThriftTransportFactoryClass)) - -typedef struct _ThriftTransportFactory ThriftTransportFactory; - -/* Thrift Transport Factory instance */ -struct _ThriftTransportFactory -{ - GObject parent; -}; - -typedef struct _ThriftTransportFactoryClass ThriftTransportFactoryClass; - -/* Thrift Transport Factory class */ -struct _ThriftTransportFactoryClass -{ - GObjectClass parent; - - /* vtable */ - ThriftTransport *(*get_transport) (ThriftTransportFactory *factory, - ThriftTransport *transport); -}; - -/* used by THRIFT_TYPE_TRANSPORT_FACTORY */ -GType thrift_transport_factory_get_type (void); - -/* virtual public methods */ -ThriftTransport *thrift_transport_factory_get_transport (ThriftTransportFactory *factory, ThriftTransport *transport); - -G_END_DECLS - -#endif /* _THRIFT_TRANSPORT_FACTORY_H */ http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/72ea8afd/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 deleted file mode 100644 index 31e6c6b..0000000 --- a/depends/thirdparty/thrift/lib/c_glib/test/CMakeLists.txt +++ /dev/null @@ -1,170 +0,0 @@ -# -# 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/72ea8afd/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 deleted file mode 100644 index a92a9a5..0000000 --- a/depends/thirdparty/thrift/lib/c_glib/test/ContainerTest.thrift +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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/72ea8afd/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 deleted file mode 100755 index 7319743..0000000 --- a/depends/thirdparty/thrift/lib/c_glib/test/Makefile.am +++ /dev/null @@ -1,282 +0,0 @@ -# -# 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/72ea8afd/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 deleted file mode 100644 index 0e0e9fe..0000000 --- a/depends/thirdparty/thrift/lib/c_glib/test/glib.suppress +++ /dev/null @@ -1,64 +0,0 @@ -{ - 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/72ea8afd/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 deleted file mode 100644 index 89e39e2..0000000 --- a/depends/thirdparty/thrift/lib/c_glib/test/testapplicationexception.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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/72ea8afd/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 deleted file mode 100755 index cd65501..0000000 --- a/depends/thirdparty/thrift/lib/c_glib/test/testbinaryprotocol.c +++ /dev/null @@ -1,688 +0,0 @@ -/* - * 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/72ea8afd/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 deleted file mode 100755 index 3203a66..0000000 --- a/depends/thirdparty/thrift/lib/c_glib/test/testbufferedtransport.c +++ /dev/null @@ -1,287 +0,0 @@ -/* - * 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 (); -} -
