From 76fa22ad6b955c173949311e00554c149bd6f07a Mon Sep 17 00:00:00 2001 From: Thomas James Alexander Thurman Date: Fri, 23 Jan 2009 04:32:36 +0000 Subject: some basic option parsing * test/veracity/veracity.c: some basic option parsing svn path=/branches/veracity/; revision=4086 --- ChangeLog | 4 ++++ test/veracity/veracity.c | 47 +++++++++++++++++++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1964e626..bd0411c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-01-22 Thomas Thurman + + * test/veracity/veracity.c: some basic option parsing + 2009-01-22 Thomas Thurman Fix autotools thanks to Andreas Dalsgaard; diff --git a/test/veracity/veracity.c b/test/veracity/veracity.c index 31ab5102..794aef2d 100644 --- a/test/veracity/veracity.c +++ b/test/veracity/veracity.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -147,8 +149,8 @@ gconf_test (char *test) static void die (const char *reason) { - fprintf (stderr, "Fatal error: %s\n", reason); - exit (255); + g_error ("Fatal error: %s\n", reason); + exit (EXIT_FAILURE); } static void @@ -160,9 +162,7 @@ start_dbus_daemon () ssize_t size; if (pipe (pipes)==-1) - { - die ("Can't create pipes to talk to dbus"); - } + die ("Can't create pipes to talk to dbus"); if (!(dbus_daemon = fork())) { @@ -292,16 +292,43 @@ finish () XCloseDisplay (current_display); } +gboolean list = FALSE; +gboolean naked = FALSE; + +static GOptionEntry entries[] = + { + { "list-tests", 'l', 0, G_OPTION_ARG_NONE, &list, "List all available tests", NULL }, + { "naked", 'n', 0, G_OPTION_ARG_NONE, &naked, "Don't hide the X server when it runs", NULL }, + { NULL } + }; + int main (int argc, char *argv[]) { - start (); + GError *error = NULL; + GOptionContext *context = g_option_context_new ("- test metacity"); + + g_option_context_add_main_entries (context, entries, /*GETTEXT_PACKAGE*/"veracity"); + g_option_context_add_group (context, gtk_get_option_group (TRUE)); + if (!g_option_context_parse (context, &argc, &argv, &error)) + die (error->message); + + if (list) + { + die ("List mode not implemented."); + } + else + { + start (); + + run_test ("unit/reparent.scm"); - run_test ("001-reparent.scm"); + finish (); - finish (); + /* I'm making a note here: HUGE SUCCESS. */ + exit(EXIT_SUCCESS); + } - /* I'm making a note here: HUGE SUCCESS. */ - exit(EXIT_SUCCESS); + exit(EXIT_FAILURE); } -- cgit v1.2.1