From: Tim Janik Date: Tue, 20 Nov 2007 15:00:40 +0000 (+0000) Subject: Integrated gtester program into build process. X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=39cf400cdf2a5b1079b5bf0fd9b663f9c87bc1bf;p=dana%2Fcg-glib.git Integrated gtester program into build process. * Makefile.am: build and install gtester binary. * gtester.c: fixed up coding style and removed hard wired test coded. svn path=/trunk/; revision=5894 --- diff --git a/glib/Makefile.am b/glib/Makefile.am index 9c23fef8..6ea366dc 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -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:$@ diff --git a/glib/gtester.c b/glib/gtester.c index 78b00621..628036f8 100644 --- a/glib/gtester.c +++ b/glib/gtester.c @@ -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 + * 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 /* 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) { - GError* error = 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) { - GMainLoop* loop = 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) { - GMainLoop* loop; - 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);