Integrated gtester program into build process.
authorTim Janik <timj@src.gnome.org>
Tue, 20 Nov 2007 15:00:40 +0000 (15:00 +0000)
committerTim Janik <timj@src.gnome.org>
Tue, 20 Nov 2007 15:00:40 +0000 (15:00 +0000)
* Makefile.am: build and install gtester binary.

* gtester.c: fixed up coding style and removed hard wired test coded.

svn path=/trunk/; revision=5894

glib/Makefile.am
glib/gtester.c

index 9c23fef8e68d086f53265d32b419a85bff3ed3df..6ea366dcc9655446f35351e65f9b6c853c18bb5a 100644 (file)
@@ -282,18 +282,26 @@ libglib_2_0_la_LDFLAGS = \
        -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
        -export-dynamic $(no_undefined) $(export_symbols)
 
+INSTALL_PROGS=
+
 if OS_WIN32
-bin_PROGRAMS = gspawn-win32-helper gspawn-win32-helper-console
+INSTALL_PROGS += gspawn-win32-helper gspawn-win32-helper-console
 gspawn_win32_helper_LDADD = libglib-2.0.la
 gspawn_win32_helper_LDFLAGS = -mwindows
 gspawn_win32_helper_console_LDADD = libglib-2.0.la
+gspawn-win32-helper-console.c:
+       echo '#include "gspawn-win32-helper.c"' >$@
 
 glib-win32-res.o: glib.rc
        $(WINDRES) glib.rc $@
 endif
 
-gspawn-win32-helper-console.c:
-       echo '#include "gspawn-win32-helper.c"' >$@
+bin_PROGRAMS    = ${INSTALL_PROGS}
+
+INSTALL_PROGS  += gtester
+gtester_SOURCES         = gtester.c
+gtester_LDADD   = libglib-2.0.la
+
 
 glib-2.0.lib: libglib-2.0.la glib.def
        lib -name:libglib-2.0-$(LT_CURRENT_MINUS_AGE).dll -def:glib.def -out:$@
index 78b006213765e2039a341b084384ec061c262550..628036f8fa17271e3e359b3b4bd1df9b15cf2614 100644 (file)
@@ -1,64 +1,63 @@
-/* This file is part of gtester
+/* GLib testing framework runner
+ * Copyright (C) 2007 Sven Herzberg
+ * Copyright (C) 2007 Tim Janik
  *
- * AUTHORS
- *     Sven Herzberg  <herzi@gnome-de.org>
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
  *
- * Copyright (C) 2007  Sven Herzberg
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
  */
-
 #include <glib.h>
 
 /* the read buffer size in bytes */
 #define READ_BUFFER_SIZE 1024
 
+/* --- variables --- */
 static GIOChannel* out = NULL;
 
+/* --- functions --- */
 static gboolean
-child_out_cb (GIOChannel  * source,
-             GIOCondition  condition,
-             gpointer      data)
+child_out_cb (GIOChannel  *source,
+             GIOCondition condition,
+             gpointer     data)
 {
-  GErrorerror = NULL;
+  GError *error = NULL;
   gsize length = 0;
   gchar buffer[READ_BUFFER_SIZE];
   GIOStatus status = G_IO_STATUS_NORMAL;
 
-  while (status == G_IO_STATUS_NORMAL) {
-    status = g_io_channel_read_chars (source, buffer, sizeof (buffer), &length, &error);
-
-    switch (status) {
-    case G_IO_STATUS_NORMAL:
-           // FIXME: this is where the parsing happens
-           g_print ("%d\n", length);
-           break;
-    case G_IO_STATUS_AGAIN:
-           /* retry later */
-           break;
-    case G_IO_STATUS_ERROR:
-           /* fall through into EOF */
-           g_warning ("Error while reading data: %s",
-                      error->message);
-           g_error_free (error);
-    case G_IO_STATUS_EOF:
-           return FALSE;
+  while (status == G_IO_STATUS_NORMAL)
+    {
+      status = g_io_channel_read_chars (source, buffer, sizeof (buffer), &length, &error);
+
+      switch (status)
+        {
+        case G_IO_STATUS_NORMAL:
+          // FIXME: this is where the parsing happens
+          g_print ("read output bytes: %d\n", length);
+          break;
+        case G_IO_STATUS_AGAIN:
+          /* retry later */
+          break;
+        case G_IO_STATUS_ERROR:
+          /* fall through into EOF */
+          g_warning ("Error while reading data: %s",
+                     error->message);
+          g_error_free (error);
+        case G_IO_STATUS_EOF:
+          return FALSE;
+        }
     }
-  }
-
   return TRUE;
 }
 
@@ -67,7 +66,7 @@ child_watch_cb (GPid     pid,
                gint     status,
                gpointer data)
 {
-  GMainLooploop = data;
+  GMainLoop *loop = data;
 
   g_spawn_close_pid (pid);
 
@@ -77,31 +76,29 @@ child_watch_cb (GPid     pid,
 }
 
 int
-main (int   argc,
-      char**argv)
+main (int    argc,
+      char **argv)
 {
-  GMainLooploop;
-  GError   error = NULL;
+  GMainLoop *loop;
+  GError    *error = NULL;
   GPid       pid = 0;
-  gchar    * working_folder;
-  gchar    * child_argv[] = {
-    "git-annotate",
-    "--incremental",
-    "ChangeLog",
+  gchar     *working_folder;
+  gchar     *child_argv[] = {
+    "/bin/ls",
     NULL
   };
   gint        child_out;
 
-  working_folder = g_strdup ("/home/herzi/Hacking/Imendio/WebKit/WebCore"); //g_get_current_dir ();
+  working_folder = g_strdup ("."); // g_get_current_dir ();
   g_spawn_async_with_pipes (working_folder,
-                child_argv, NULL /* envp */,
-                G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
-                NULL, NULL,
-                &pid,
-                NULL,
-                &child_out,
-                NULL,
-                &error);
+                            child_argv, NULL /* envp */,
+                            G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
+                            NULL, NULL,
+                            &pid,
+                            NULL,
+                            &child_out,
+                            NULL,
+                            &error);
   g_free (working_folder);
 
   if (error)
@@ -112,14 +109,11 @@ main (int   argc,
 
   loop = g_main_loop_new (NULL, FALSE);
 
-  g_child_watch_add (pid,
-                    child_watch_cb,
-                    loop);
+  g_child_watch_add (pid, child_watch_cb, loop);
 
   out = g_io_channel_unix_new (child_out);
   g_io_channel_set_flags (out, G_IO_FLAG_NONBLOCK, NULL); // FIXME: GError
-  g_io_add_watch (out, G_IO_IN,
-                 child_out_cb, loop);
+  g_io_add_watch (out, G_IO_IN, child_out_cb, loop);
 
   g_main_loop_run (loop);
   g_main_loop_unref (loop);