From ea5e74aebad96c373c18618d12f2dc042fe01427 Mon Sep 17 00:00:00 2001 From: Damien Lespiau Date: Fri, 26 Jun 2009 12:02:31 +0200 Subject: [tests] Check for errors in g_option_context_parse() ./tests/test-yuv-upload -f1 made the test segfault for instance. Checking for errors helps a lot, who knew? --- tests/test-rgb-upload.c | 13 +++++++++++-- tests/test-yuv-upload.c | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/test-rgb-upload.c b/tests/test-rgb-upload.c index ba20b5d..8491f5a 100644 --- a/tests/test-rgb-upload.c +++ b/tests/test-rgb-upload.c @@ -102,6 +102,7 @@ int main (int argc, char *argv[]) { GOptionContext *context; + GError *error = NULL; gboolean result; ClutterActor *stage; ClutterActor *texture; @@ -118,7 +119,15 @@ main (int argc, char *argv[]) g_option_context_add_group (context, gst_init_get_option_group ()); g_option_context_add_group (context, clutter_get_option_group ()); g_option_context_add_main_entries (context, options, NULL); - g_option_context_parse (context, &argc, &argv, NULL); + + if (!g_option_context_parse (context, &argc, &argv, &error)) + { + g_option_context_free (context); + + g_print ("%s\n", error->message); + g_error_free (error); + exit(EXIT_FAILURE); + } stage = clutter_stage_get_default (); clutter_actor_set_size (CLUTTER_ACTOR (stage), 320.0f, 240.0f); @@ -167,5 +176,5 @@ main (int argc, char *argv[]) clutter_main(); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/test-yuv-upload.c b/tests/test-yuv-upload.c index a319f5e..abc399e 100644 --- a/tests/test-yuv-upload.c +++ b/tests/test-yuv-upload.c @@ -101,6 +101,7 @@ int main (int argc, char *argv[]) { GOptionContext *context; + GError *error = NULL; gboolean result; ClutterActor *stage; ClutterActor *texture; @@ -117,7 +118,15 @@ main (int argc, char *argv[]) g_option_context_add_group (context, gst_init_get_option_group ()); g_option_context_add_group (context, clutter_get_option_group ()); g_option_context_add_main_entries (context, options, NULL); - g_option_context_parse (context, &argc, &argv, NULL); + + if (!g_option_context_parse (context, &argc, &argv, &error)) + { + g_option_context_free (context); + + g_print ("%s\n", error->message); + g_error_free (error); + exit(EXIT_FAILURE); + } stage = clutter_stage_get_default (); clutter_actor_set_size (CLUTTER_ACTOR(stage), 320.0f, 240.0f); @@ -162,5 +171,5 @@ main (int argc, char *argv[]) clutter_main(); - return 0; + return EXIT_SUCCESS; } -- cgit v1.2.1