THRIFT-1003 Polishing c_glib code

Patch: Anatol Pomozov


git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1039299 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/c_glib/test/Makefile.am b/lib/c_glib/test/Makefile.am
index a8889be..e9f070e 100644
--- a/lib/c_glib/test/Makefile.am
+++ b/lib/c_glib/test/Makefile.am
@@ -6,25 +6,9 @@
 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 \
+  testbinaryprotocol \
   testbufferedtransport \
   testframedtransport \
   testmemorybuffer \
@@ -44,8 +28,8 @@
     ../libthrift_c_glib_la-thrift_server_transport.o \
     ../libthrift_c_glib_la-thrift_server_socket.o
 
-testprotocolbinary_SOURCES = testprotocolbinary.c
-testprotocolbinary_LDADD = \
+testbinaryprotocol_SOURCES = testbinaryprotocol.c
+testbinaryprotocol_LDADD = \
     ../libthrift_c_glib_la-thrift_protocol.o \
     ../libthrift_c_glib_la-thrift_transport.o \
     ../libthrift_c_glib_la-thrift_socket.o \
@@ -158,9 +142,7 @@
 gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest.h: ../../../test/ThriftTest.thrift
 	$(THRIFT) --gen cpp $<
 
-
 TESTS = \
-  $(testwrapper-%) \
   $(check_PROGRAMS) \
   $(check_SCRIPTS)
 
@@ -212,18 +194,13 @@
 	    ${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
+    *.gcov
diff --git a/lib/c_glib/test/test-wrapper.sh.in b/lib/c_glib/test/test-wrapper.sh.in
deleted file mode 100644
index 956b2d1..0000000
--- a/lib/c_glib/test/test-wrapper.sh.in
+++ /dev/null
@@ -1,58 +0,0 @@
-# /bin/sh
-
-command="$0"
-
-stripcommand=`echo "$command" | sed 's/testwrapper-//'`
-
-"$stripcommand" "$@" || exit $?
-
-if test "x@ENABLE_COVERAGE@" = "x1"; then
-  # linux: 97.67% of 86 lines executed in file ../src/test123.h
-  # bsd: 100.00% of 196 source lines executed in file testbimap.c
-
-  extrastripcommand=`echo "$stripcommand" | sed 's/\.\///'`
-    ${GCOV:-gcov} "$extrastripcommand" 2>&1                        \
-  | perl -ne 'BEGIN { $file = undef; }
-      next if m!^Creating!;
-      next if m!creating!;
-      next if m!^$!;
-      next if m!not exhausted!;
-      next if m!^Unexpected EOF!;
-      if (m!([\d\.]+)\% of \d+( source)? lines executed in file (.+)!)
-        {
-          do
-            {
-              if ( $3 !~ m#^/# )
-                {
-                  $a = $3 =~ m%([\-\w\.]+)$%;
-                  print STDERR $_;
-                  print "$1.gcov\n";
-                }
-            } if $1 < 110.0;
-        }
-      elsif (m#^File .(.*?).$#)
-        {
-          $file = $1;
-        }
-      elsif (m#Lines executed:([\d\.]+)\% of (\d+)#)
-        {
-          $percent = $1;
-          $lines = $2;
-          do
-            {
-              if ( $file !~ m#^/# )
-                {
-                  $a = $file =~ m%([\-\w\.]+)$%;
-                  print STDERR "$percent% of $lines executed in file $file\n";
-                  print "$1.gcov\n";
-                }
-            } if $percent < 110.0;
-        }
-      else
-        {
-          print
-        }'                 \
-  | xargs grep -n -A2 -B2 '#####.*\w'
-  exit 0
-fi
-
diff --git a/lib/c_glib/test/testprotocolbinary.c b/lib/c_glib/test/testbinaryprotocol.c
similarity index 94%
rename from lib/c_glib/test/testprotocolbinary.c
rename to lib/c_glib/test/testbinaryprotocol.c
index c8a54b9..94813e2 100644
--- a/lib/c_glib/test/testprotocolbinary.c
+++ b/lib/c_glib/test/testbinaryprotocol.c
@@ -1,3 +1,22 @@
+/*
+ * 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 <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -639,14 +658,15 @@
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
-  g_type_init ();
-  test_create_and_destroy ();
-  test_initialize ();
-  test_read_and_write_primitives ();
-  test_read_and_write_complex_types ();
+  g_type_init();
+  g_test_init (&argc, &argv, NULL);
 
-  return 0;
+  g_test_add_func ("/testmemorybuffer/CreateAndDestroy", test_create_and_destroy);
+  g_test_add_func ("/testmemorybuffer/Initialize", test_initialize);
+  g_test_add_func ("/testmemorybuffer/ReadAndWritePrimitives", test_read_and_write_primitives);
+  g_test_add_func ("/testmemorybuffer/ReadAndWriteComplexTypes", test_read_and_write_complex_types);
+
+  return g_test_run ();
 }
-
diff --git a/lib/c_glib/test/testbufferedtransport.c b/lib/c_glib/test/testbufferedtransport.c
index 6759509..fb49c8f 100644
--- a/lib/c_glib/test/testbufferedtransport.c
+++ b/lib/c_glib/test/testbufferedtransport.c
@@ -1,3 +1,22 @@
+/*
+ * 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>
 
@@ -176,13 +195,15 @@
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
   g_type_init();
-  test_create_and_destroy();
-  test_open_and_close();
-  test_read_and_write();
+  g_test_init (&argc, &argv, NULL);
 
-  return 0;
+  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);
+
+  return g_test_run ();
 }
 
diff --git a/lib/c_glib/test/testdebugproto.c b/lib/c_glib/test/testdebugproto.c
index b111e12..f0654f1 100644
--- a/lib/c_glib/test/testdebugproto.c
+++ b/lib/c_glib/test/testdebugproto.c
@@ -1,3 +1,22 @@
+/*
+ * 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 <math.h>
 #include <glib-object.h>
 
@@ -7,12 +26,9 @@
 
 #include "gen-c_glib/t_test_debug_proto_test_types.h"
 
-
-int
-main(void)
+static void
+test_debug_proto(void)
 {
-  g_type_init ();
-
   TTestOneOfEach *ooe = NULL;
   TTestNesting *n = NULL;
   TTestHolyMoley *hm = NULL;
@@ -62,3 +78,15 @@
   return 0;
 }
 
+int
+main(int argc, char *argv[])
+{
+  g_type_init();
+  g_test_init (&argc, &argv, NULL);
+
+  g_test_add_func ("/testdebugproto/DebugProto", test_debug_proto);
+
+  return g_test_run ();
+}
+
+
diff --git a/lib/c_glib/test/testframedtransport.c b/lib/c_glib/test/testframedtransport.c
index 23951f7..3269bf5 100644
--- a/lib/c_glib/test/testframedtransport.c
+++ b/lib/c_glib/test/testframedtransport.c
@@ -1,3 +1,22 @@
+/*
+ * 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>
 
@@ -164,13 +183,14 @@
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
   g_type_init();
-  test_create_and_destroy();
-  test_open_and_close();
-  test_read_and_write();
+  g_test_init (&argc, &argv, NULL);
 
-  return 0;
+  g_test_add_func ("/testframedtransport/CreateAndDestroy", test_create_and_destroy);
+  g_test_add_func ("/testframedtransport/OpenAndClose", test_open_and_close);
+  g_test_add_func ("/testframedtransport/ReadAndWrite", test_read_and_write);
+
+  return g_test_run ();
 }
-
diff --git a/lib/c_glib/test/testmemorybuffer.c b/lib/c_glib/test/testmemorybuffer.c
index 52b18bf..65901bf 100644
--- a/lib/c_glib/test/testmemorybuffer.c
+++ b/lib/c_glib/test/testmemorybuffer.c
@@ -1,3 +1,22 @@
+/*
+ * 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>
 
@@ -63,13 +82,14 @@
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
   g_type_init();
-  test_create_and_destroy();
-  test_open_and_close();
-  test_read_and_write();
+  g_test_init (&argc, &argv, NULL);
 
-  return 0;
+  g_test_add_func ("/testmemorybuffer/CreateAndDestroy", test_create_and_destroy);
+  g_test_add_func ("/testmemorybuffer/OpenAndClose", test_open_and_close);
+  g_test_add_func ("/testmemorybuffer/ReadAndWrite", test_read_and_write);
+
+  return g_test_run ();
 }
-
diff --git a/lib/c_glib/test/testoptionalrequired.c b/lib/c_glib/test/testoptionalrequired.c
index cf44413..7165d93 100644
--- a/lib/c_glib/test/testoptionalrequired.c
+++ b/lib/c_glib/test/testoptionalrequired.c
@@ -1,3 +1,22 @@
+/*
+ * 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 <glib.h>
 
@@ -167,16 +186,17 @@
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
-  g_type_init ();
-  test_old_school1 ();
-  test_simple ();
-  test_tricky1 ();
-  test_tricky2 ();
-  test_tricky3 ();
-  test_tricky4 ();
-  return 0;
+  g_type_init();
+  g_test_init (&argc, &argv, NULL);
+
+  g_test_add_func ("/testoptionalrequired/OldSchool", test_old_school1);
+  g_test_add_func ("/testoptionalrequired/Simple", test_simple);
+  g_test_add_func ("/testoptionalrequired/Tricky1", test_tricky1);
+  g_test_add_func ("/testoptionalrequired/Tricky2", test_tricky2);
+  g_test_add_func ("/testoptionalrequired/Tricky3", test_tricky3);
+  g_test_add_func ("/testoptionalrequired/Tricky4", test_tricky4);
+
+  return g_test_run ();
 }
-
-
diff --git a/lib/c_glib/test/testsimpleserver.c b/lib/c_glib/test/testsimpleserver.c
index 182e9ef..282a6e8 100644
--- a/lib/c_glib/test/testsimpleserver.c
+++ b/lib/c_glib/test/testsimpleserver.c
@@ -1,3 +1,22 @@
+/*
+ * 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 <glib.h>
 #include <stdlib.h>
@@ -5,6 +24,7 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
+#include "thrift.h"
 #include "processor/thrift_processor.h"
 #include "transport/thrift_server_socket.h"
 
@@ -27,6 +47,8 @@
 };
 typedef struct _TestProcessorClass TestProcessorClass;
 
+G_DEFINE_TYPE(TestProcessor, test_processor, THRIFT_TYPE_PROCESSOR)
+
 gboolean
 test_processor_process (ThriftProcessor *processor, ThriftProtocol *in,
                         ThriftProtocol *out)
@@ -35,38 +57,15 @@
 }
 
 static void
-test_processor_class_init (ThriftProcessorClass *proc)
+test_processor_init (TestProcessor *p)
 {
-  proc->process = test_processor_process;
+  THRIFT_UNUSED_VAR (p);
 }
 
-GType
-test_processor_get_type (void)
+static void
+test_processor_class_init (TestProcessorClass *proc)
 {
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo info =
-    {
-      sizeof (TestProcessorClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) test_processor_class_init,
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof (TestProcessor),
-      0, /* n_preallocs */
-      NULL, /* instance_init */
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (THRIFT_TYPE_PROCESSOR,
-                                   "TestProcessorType",
-                                   &info, 0);
-  }
-
-  return type;
+  (THRIFT_PROCESSOR_CLASS(proc))->process = test_processor_process;
 }
 
 static void
@@ -104,10 +103,12 @@
 }
 
 int
-main (void)
+main(int argc, char *argv[])
 {
-  g_type_init ();
-  test_server ();
+  g_type_init();
+  g_test_init (&argc, &argv, NULL);
 
-  return 0;
+  g_test_add_func ("/testsimpleserver/SimpleServer", test_server);
+
+  return g_test_run ();
 }
diff --git a/lib/c_glib/test/teststruct.c b/lib/c_glib/test/teststruct.c
index cb401e2..ec543be 100644
--- a/lib/c_glib/test/teststruct.c
+++ b/lib/c_glib/test/teststruct.c
@@ -1,3 +1,22 @@
+/*
+ * 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 <glib-object.h>
 
@@ -20,67 +39,13 @@
 GType thrift_test_struct_get_type (void);
 
 #define THRIFT_TYPE_TEST_STRUCT (thrift_test_struct_get_type ())
-#define THRIFT_TEST_STRUCT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-                                     THRIFT_TYPE_TEST_STRUCT, \
-                                     ThriftTestStruct))
-#define THRIFT_TEST_STRUCT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), \
-                                         THRIFT_TYPE_TEST_STRUCT, \
-                                         ThriftTestStructClass))
-#define THRIFT_IS_TEST_STRUCT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-                                        THRIFT_TYPE_TEST_STRUCT))
-#define THRIFT_IS_TEST_STRUCT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), \
-                                            THRIFT_TYPE_TEST_STRUCT))
-#define THRIFT_TEST_STRUCT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-                                               THRIFT_TYPE_TEST_STRUCT, \
-                                               ThriftTestStructClass))
+#define THRIFT_TEST_STRUCT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_TEST_STRUCT, ThriftTestStruct))
+#define THRIFT_TEST_STRUCT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_TEST_STRUCT, ThriftTestStructClass))
+#define THRIFT_IS_TEST_STRUCT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_TEST_STRUCT))
+#define THRIFT_IS_TEST_STRUCT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_TEST_STRUCT))
+#define THRIFT_TEST_STRUCT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_TEST_STRUCT, ThriftTestStructClass))
 
-/* test declarations */
-gint32 thrift_test_struct_read (ThriftStruct *object, ThriftProtocol *protocol,
-                                GError **error);
-gint32 thrift_test_struct_write (ThriftStruct *object, ThriftProtocol *protocol,
-                                 GError **error);
-
-static void
-thrift_test_struct_class_init (ThriftTestStructClass *cls)
-{
-  ThriftStructClass *ts_cls = THRIFT_STRUCT_CLASS (cls);
-  ts_cls->read = thrift_test_struct_read;
-  ts_cls->write = thrift_test_struct_write;
-}
-
-static void
-thrift_test_struct_instance_init (ThriftTestStruct *s)
-{
-  (void) s;
-}
-
-GType
-thrift_test_struct_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo type_info =
-    {
-      sizeof (ThriftTestStructClass),
-      NULL,
-      NULL,
-      (GClassInitFunc) thrift_test_struct_class_init,
-      NULL,
-      NULL,
-      sizeof (ThriftTestStruct),
-      0,
-      (GInstanceInitFunc) thrift_test_struct_instance_init,
-      NULL, 
-    };
-
-    type = g_type_register_static (THRIFT_TYPE_STRUCT,
-                                   "ThriftTestStructType", &type_info, 0);
-  }
-
-  return type;
-}
+G_DEFINE_TYPE(ThriftTestStruct, thrift_test_struct, THRIFT_TYPE_STRUCT)
 
 gint32
 thrift_test_struct_read (ThriftStruct *object, ThriftProtocol *protocol,
@@ -96,6 +61,19 @@
   return 0;
 }
 
+static void
+thrift_test_struct_class_init (ThriftTestStructClass *cls)
+{
+  ThriftStructClass *ts_cls = THRIFT_STRUCT_CLASS (cls);
+  ts_cls->read = thrift_test_struct_read;
+  ts_cls->write = thrift_test_struct_write;
+}
+
+static void
+thrift_test_struct_init (ThriftTestStruct *s)
+{
+  THRIFT_UNUSED_VAR (s);
+}
 
 static void
 test_initialize_object (void)
@@ -112,10 +90,12 @@
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
-  g_type_init ();
-  test_initialize_object ();
+  g_type_init();
+  g_test_init (&argc, &argv, NULL);
 
-  return 0;
+  g_test_add_func ("/teststruct/InitializeObject", test_initialize_object);
+
+  return g_test_run ();
 }
diff --git a/lib/c_glib/test/testthrifttest.c b/lib/c_glib/test/testthrifttest.c
index 6020f9c..b14b606 100644
--- a/lib/c_glib/test/testthrifttest.c
+++ b/lib/c_glib/test/testthrifttest.c
@@ -7,22 +7,22 @@
 static const char TEST_ADDRESS[] = "localhost";
 static const int TEST_PORT = 64444;
 
-static void thrift_server (const int port);
-
 static void
-thrift_server (const int port)
+test_thrift_server (const int port)
 {
   ThriftServerSocket *tsocket = g_object_new (THRIFT_TYPE_SERVER_SOCKET,
-                                              "port", port, NULL);
+                                              "port", TEST_PORT, NULL);
 
   g_object_unref (tsocket);
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
-  g_type_init ();
-  thrift_server (TEST_PORT);
-  return 0;
-}
+  g_type_init();
+  g_test_init (&argc, &argv, NULL);
 
+  g_test_add_func ("/testthrift/Server", test_thrift_server);
+
+  return g_test_run ();
+}
diff --git a/lib/c_glib/test/testthrifttestclient.cpp b/lib/c_glib/test/testthrifttestclient.cpp
index 4b5b841..15389a5 100644
--- a/lib/c_glib/test/testthrifttestclient.cpp
+++ b/lib/c_glib/test/testthrifttestclient.cpp
@@ -1,3 +1,21 @@
+/*
+ * 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.
+ */
 
 /* test a C client with a C++ server */
 
diff --git a/lib/c_glib/test/testtransportsocket.c b/lib/c_glib/test/testtransportsocket.c
index 14579c8..279da86 100644
--- a/lib/c_glib/test/testtransportsocket.c
+++ b/lib/c_glib/test/testtransportsocket.c
@@ -1,3 +1,22 @@
+/*
+ * 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>
 
@@ -188,13 +207,15 @@
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
   g_type_init();
-  test_create_and_destroy();
-  test_open_and_close();
-  test_read_and_write();
+  g_test_init (&argc, &argv, NULL);
 
-  return 0;
+  g_test_add_func ("/testtransportsocket/CreateAndDestroy", test_create_and_destroy);
+  g_test_add_func ("/testtransportsocket/OpenAndClose", test_open_and_close);
+  g_test_add_func ("/testtransportsocket/ReadAndWrite", test_read_and_write);
+
+  return g_test_run ();
 }