THRIFT-582 C(c_glib) implementation of Thrift

Patch: Anatol Pomozov and Michael Lum


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1027933 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/c_glib/test/Makefile.am b/lib/c_glib/test/Makefile.am
new file mode 100644
index 0000000..a8889be
--- /dev/null
+++ b/lib/c_glib/test/Makefile.am
@@ -0,0 +1,229 @@
+SUBDIRS =
+
+AM_CPPFLAGS = -g -Wall -I../src $(GLIB_CFLAGS)
+AM_LDFLAGS = $(GLIB_LIBS) $(GOBJECT_LIBS) @GCOV_LDFLAGS@
+
+CFLAGS = @GCOV_CFLAGS@
+CXXFLAGS = -g
+
+check_SCRIPTS = \
+  testwrapper-testtransportsocket \
+  testwrapper-testprotocolbinary \
+  testwrapper-testbufferedtransport \
+  testwrapper-testframedtransport \
+  testwrapper-testmemorybuffer \
+  testwrapper-teststruct \
+  testwrapper-testsimpleserver \
+  testwrapper-testdebugproto \
+  testwrapper-testoptionalrequired \
+  testwrapper-testthrifttest
+
+if WITH_CPP
+  check_SCRIPTS += testwrapper-testthrifttestclient
+endif
+
+check_PROGRAMS = \
+  testtransportsocket \
+  testprotocolbinary \
+  testbufferedtransport \
+  testframedtransport \
+  testmemorybuffer \
+  teststruct \
+  testsimpleserver \
+  testdebugproto \
+  testoptionalrequired \
+  testthrifttest
+
+if WITH_CPP
+  check_PROGRAMS += testthrifttestclient
+endif
+
+testtransportsocket_SOURCES = testtransportsocket.c
+testtransportsocket_LDADD = \
+    ../libthrift_c_glib_la-thrift_transport.o \
+    ../libthrift_c_glib_la-thrift_server_transport.o \
+    ../libthrift_c_glib_la-thrift_server_socket.o
+
+testprotocolbinary_SOURCES = testprotocolbinary.c
+testprotocolbinary_LDADD = \
+    ../libthrift_c_glib_la-thrift_protocol.o \
+    ../libthrift_c_glib_la-thrift_transport.o \
+    ../libthrift_c_glib_la-thrift_socket.o \
+    ../libthrift_c_glib_la-thrift_server_transport.o \
+    ../libthrift_c_glib_la-thrift_server_socket.o
+
+testbufferedtransport_SOURCES = testbufferedtransport.c
+testbufferedtransport_LDADD = \
+    ../libthrift_c_glib_la-thrift_transport.o \
+    ../libthrift_c_glib_la-thrift_socket.o \
+    ../libthrift_c_glib_la-thrift_server_transport.o \
+    ../libthrift_c_glib_la-thrift_server_socket.o
+
+testframedtransport_SOURCES = testframedtransport.c
+testframedtransport_LDADD = \
+    ../libthrift_c_glib_la-thrift_transport.o \
+    ../libthrift_c_glib_la-thrift_socket.o \
+    ../libthrift_c_glib_la-thrift_server_transport.o \
+    ../libthrift_c_glib_la-thrift_server_socket.o
+
+testmemorybuffer_SOURCES = testmemorybuffer.c
+testmemorybuffer_LDADD = \
+    ../libthrift_c_glib_la-thrift_transport.o
+
+teststruct_SOURCES = teststruct.c
+teststruct_LDADD = \
+    ../libthrift_c_glib_la-thrift_protocol.o \
+    ../libthrift_c_glib_la-thrift_transport.o
+
+testsimpleserver_SOURCES = testsimpleserver.c
+testsimpleserver_LDADD = \
+    ../libthrift_c_glib_la-thrift_protocol.o \
+    ../libthrift_c_glib_la-thrift_transport.o \
+    ../libthrift_c_glib_la-thrift_transport_factory.o \
+    ../libthrift_c_glib_la-thrift_processor.o \
+    ../libthrift_c_glib_la-thrift_protocol_factory.o \
+    ../libthrift_c_glib_la-thrift_binary_protocol.o \
+    ../libthrift_c_glib_la-thrift_binary_protocol_factory.o \
+    ../libthrift_c_glib_la-thrift_socket.o \
+    ../libthrift_c_glib_la-thrift_server_transport.o \
+    ../libthrift_c_glib_la-thrift_server_socket.o \
+    ../libthrift_c_glib_la-thrift_server.o
+
+testdebugproto_SOURCES = testdebugproto.c
+testdebugproto_LDADD = libtestgenc.la
+
+testoptionalrequired_SOURCES = testoptionalrequired.c
+testoptionalrequired_LDADD = \
+    ../libthrift_c_glib_la-thrift_protocol.o \
+    ../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
+
+libtestgenc_la_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
+libtestgenc_la_LIBADD = $(top_builddir)/lib/c_glib/libthrift_c_glib.la
+
+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_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.h: ../../../test/ThriftTest.thrift
+	$(THRIFT) --gen cpp $<
+
+
+TESTS = \
+  $(testwrapper-%) \
+  $(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}  ./$<
+
+testwrapper-%: % test-wrapper.sh
+	@ln -sf test-wrapper.sh $@
+
+clean-local:
+	$(RM) -r gen-c_glib gen-cpp
+
+CLEANFILES =                            \
+    testwrapper-*                       \
+    *.bb                                \
+    *.bbg                               \
+    *.da                                \
+    *.gcno                              \
+    *.gcda                              \
+    *.gcov                              \
+    test-wrapper.sh