tests: abort if clutter_init fails

This fixes segfaults when something goes wrong during
init, but the test keeps going anyway.

Except for test-easing and test-picking, these were fixed by
sed magic:

sed -i -s -e "s/clutter_init \?(&argc, &argv)/\
if (clutter_init (\&argc, \&argv) != CLUTTER_INIT_SUCCESS)\n\
    return 1/" tests/*/*.c

http://bugzilla.clutter-project.org/show_bug.cgi?id=2574
This commit is contained in:
nobled 2011-02-22 00:19:35 +00:00 committed by Neil Roberts
parent 0d14be1aec
commit eb906d85ca
61 changed files with 132 additions and 69 deletions

View File

@ -47,7 +47,8 @@ main (int argc, char *argv[])
ClutterGeometry geom = {0, 0, SIZE, SIZE};
gint i = 0;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
cally_util_a11y_init (&argc, &argv);

View File

@ -251,7 +251,8 @@ main (int argc, char *argv[])
g_set_application_name ("AtkEditableText");
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
cally_util_a11y_init (&argc, &argv);

View File

@ -141,7 +141,8 @@ main (int argc, char *argv[])
g_set_application_name ("AtkText");
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
cally_util_a11y_init (&argc, &argv);

View File

@ -193,7 +193,8 @@ main (int argc, char *argv[])
g_set_application_name ("AtkText");
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
cally_util_a11y_init (&argc, &argv);

View File

@ -97,7 +97,8 @@ main (int argc, char *argv[])
g_set_application_name ("Clone Example");
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
cally_util_a11y_init (&argc, &argv);

View File

@ -88,7 +88,8 @@ test_animation_main (int argc, char *argv[])
ClutterColor rect_color = { 0x44, 0xdd, 0x44, 0xff };
ClutterAction *action;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);

View File

@ -52,7 +52,8 @@ test_animator_main (gint argc,
ClutterActor *stage;
ClutterActor *rects[COUNT];
gint i;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();

View File

@ -100,7 +100,8 @@ test_behave_main (int argc, char *argv[])
}
}
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Behaviours");

View File

@ -136,7 +136,8 @@ test_bin_layout_main (int argc, char *argv[])
ClutterColor *color;
ClutterAction *action;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Box test");

View File

@ -247,7 +247,8 @@ test_binding_pool_main (int argc, char *argv[])
ClutterActor *stage, *key_group;
gint group_x, group_y;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
g_signal_connect (stage,

View File

@ -239,7 +239,8 @@ test_box_layout_main (int argc, char *argv[])
ClutterLayoutManager *layout;
gint i;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Box Layout");

View File

@ -179,7 +179,8 @@ test_cairo_flowers_main (int argc, char **argv)
srand (time (NULL));
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();

View File

@ -319,7 +319,8 @@ test_clip_main (int argc, char **argv)
ClutterActor *stub_actor, *label;
gchar *file;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
data.current_clip.type = CLIP_NONE;
data.clips = NULL;

View File

@ -112,7 +112,8 @@ test_cogl_multitexture_main (int argc, char *argv[])
0, 0, 1, 1
};
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
clutter_actor_get_geometry (stage, &geom);

View File

@ -298,7 +298,8 @@ test_cogl_offscreen_main (int argc, char *argv[])
ClutterActor *stage;
ClutterActor *coglbox;
clutter_init(&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
/* Stage */
stage = clutter_stage_get_default ();

View File

@ -226,7 +226,8 @@ test_cogl_point_sprites_main (int argc, char *argv[])
GError *error = NULL;
int i;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
data.material = cogl_material_new ();
data.last_spark_time = g_timer_new ();

View File

@ -107,7 +107,8 @@ test_cogl_primitives_main (int argc, char *argv[])
ClutterActor *coglbox;
ClutterTimeline *tl;
clutter_init(&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
tl = clutter_timeline_new (G_N_ELEMENTS (paint_func) * 1000);
clutter_timeline_set_loop (tl, TRUE);

View File

@ -364,7 +364,8 @@ test_cogl_shader_arbfp_main (int argc, char *argv[])
GError *error;
ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_new ();

View File

@ -319,7 +319,8 @@ test_cogl_shader_glsl_main (int argc, char *argv[])
GError *error;
ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_new ();

View File

@ -198,7 +198,8 @@ test_cogl_tex_convert_main (int argc, char *argv[])
ClutterActor *stage;
ClutterActor *coglbox;
clutter_init(&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
/* Stage */
stage = clutter_stage_get_default ();

View File

@ -195,7 +195,8 @@ test_cogl_tex_foreign_main (int argc, char *argv[])
ClutterActor *stage;
ClutterActor *coglbox;
clutter_init(&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
/* Stage */
stage = clutter_stage_get_default ();

View File

@ -245,7 +245,8 @@ test_cogl_tex_getset_main (int argc, char *argv[])
ClutterActor *stage;
ClutterActor *coglbox;
clutter_init(&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
/* Stage */
stage = clutter_stage_get_default ();

View File

@ -361,7 +361,8 @@ test_cogl_tex_polygon_main (int argc, char *argv[])
ClutterTimeline *timeline;
ClutterColor blue = { 0x30, 0x30, 0xff, 0xff };
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
/* Stage */
stage = clutter_stage_get_default ();

View File

@ -186,7 +186,8 @@ test_cogl_tex_tile_main (int argc, char *argv[])
ClutterActor *coglbox;
ClutterTimeline *timeline;
clutter_init(&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
/* Stage */
stage = clutter_stage_get_default ();

View File

@ -333,7 +333,8 @@ test_cogl_vertex_buffer_main (int argc, char *argv[])
ClutterGeometry stage_geom;
gint dummy_width, dummy_height;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();

View File

@ -117,7 +117,8 @@ test_constraints_main (int argc, char *argv[])
ClutterColor rect_color;
gint i;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_new ();
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

View File

@ -118,7 +118,8 @@ test_depth_main (int argc, char *argv[])
ClutterActor *group, *hand, *label, *rect, *janus, *box;
GError *error;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Depth Test");

View File

@ -221,7 +221,8 @@ test_devices_main (int argc, char **argv)
/* force enabling X11 support */
clutter_x11_enable_xinput ();
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
app = g_new0 (TestDevicesApp, 1);
app->devices = g_hash_table_new (g_direct_hash, g_direct_equal) ;

View File

@ -203,12 +203,14 @@ test_easing_main (int argc, char *argv[])
gchar *text;
gfloat stage_width, stage_height;
gfloat label_width, label_height;
GError *error = NULL;
clutter_init_with_args (&argc, &argv,
if (clutter_init_with_args (&argc, &argv,
NULL,
test_easing_entries,
NULL,
NULL);
&error) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);

View File

@ -268,7 +268,8 @@ test_events_main (int argc, char *argv[])
ncol = { 0, 0, 0, 0xff },
xcol = { 0xff, 0, 0xff, 0xff };
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;

View File

@ -50,7 +50,8 @@ test_fbo_main (int argc, char *argv[])
int x_pos = 200;
int y_pos = 100;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
if (clutter_feature_available (CLUTTER_FEATURE_OFFSCREEN) == FALSE)
g_error("This test requires CLUTTER_FEATURE_OFFSCREEN");

View File

@ -72,7 +72,8 @@ test_fullscreen_main (int argc, char *argv[])
{
ClutterActor *stage;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
g_signal_connect (stage,

View File

@ -155,7 +155,8 @@ test_grab_main (int argc, char *argv[])
ccol = { 0, 0xff, 0xff, 0xff },
ycol = { 0xff, 0xff, 0, 0xff };
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
g_print ("Red box: aquire grab on press, releases it on next button release\n");
g_print ("Blue box: aquire grab on press, destroys the blue box actor on release\n");

View File

@ -748,7 +748,8 @@ test_layout_main (int argc, char *argv[])
gint i, size;
GError *error = NULL;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
clutter_actor_set_size (stage, 800, 600);

View File

@ -211,7 +211,8 @@ test_model_main (int argc, char *argv[])
{
ClutterModel *model;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
model = clutter_list_model_new (N_COLUMNS,
G_TYPE_INT, "Foo",

View File

@ -116,7 +116,8 @@ test_multistage_main (int argc, char *argv[])
ClutterActor *label;
gint width, height;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage_default = clutter_stage_get_default ();
clutter_stage_set_title (CLUTTER_STAGE (stage_default), "Default Stage");

View File

@ -102,7 +102,8 @@ test_path_constraint_main (int argc,
ClutterPath *path;
ClutterColor rect_color = { 0xcc, 0x00, 0x00, 0xff };
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Path Constraint");

View File

@ -259,7 +259,8 @@ test_pixmap_main (int argc, char **argv)
int i;
int row_height;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
xdpy = clutter_x11_get_default_display ();
XSynchronize (xdpy, True);

View File

@ -58,7 +58,8 @@ test_scale_main (int argc, char *argv[])
ClutterAlpha *alpha;
ClutterBehaviour *behave;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();

View File

@ -140,7 +140,8 @@ test_script_main (int argc, char *argv[])
gchar *file;
gint res;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
script = clutter_script_new ();
g_assert (CLUTTER_IS_SCRIPT (script));

View File

@ -73,7 +73,8 @@ test_scrolling_main (int argc, char *argv[])
ClutterAction *action;
gint i;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Scrolling");

View File

@ -14,7 +14,8 @@ test_shader_effects_main (int argc, char *argv[])
ClutterActor *stage, *hand, *label, *rect;
gchar *file;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
/* Make a timeline */
timeline = clutter_timeline_new (7692);

View File

@ -308,7 +308,8 @@ test_shader_main (gint argc, gchar *argv[])
GError *error;
gchar *file;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Shaders");

View File

@ -9,7 +9,8 @@ test_snap_constraint_main (int argc,
{
ClutterActor *stage, *layer_a, *layer_b, *layer_c;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
/* the main container */
stage = clutter_stage_new ();

View File

@ -132,7 +132,8 @@ test_stage_read_pixels_main (int argc, char **argv)
{
CallbackData data;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
data.idle_source = 0;
data.stage = clutter_stage_get_default ();

View File

@ -41,7 +41,8 @@ test_stage_sizing_main (int argc, char *argv[])
gfloat width;
ClutterActor *stage, *rect, *label;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();

View File

@ -52,7 +52,8 @@ test_state_animator_main (gint argc,
ClutterActor *stage;
ClutterActor *rects[40];
gint i;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();

View File

@ -96,7 +96,8 @@ test_state_main (gint argc,
ClutterActor *stage;
ClutterState *layout_state;
gint i;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
layout_state = clutter_state_new ();

View File

@ -168,7 +168,8 @@ test_table_layout_main (int argc, char *argv[])
ClutterActor *box;
gchar *file;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Table Layout");

View File

@ -272,7 +272,8 @@ test_text_field_main (gint argc,
ClutterActor *box, *entry;
ClutterLayoutManager *table;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Text Fields");

View File

@ -20,7 +20,8 @@ test_text_main (gint argc,
ClutterColor cursor_color = { 0xff, 0x33, 0x33, 0xff };
ClutterColor background_color = { 0x00, 0x00, 0x00, 0xff };
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
clutter_stage_set_color (CLUTTER_STAGE (stage), &background_color);

View File

@ -125,7 +125,8 @@ test_texture_async_main (int argc, char *argv[])
ClutterColor stage_color = { 0x12, 0x34, 0x56, 0xff };
gchar *path;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
g_thread_init (NULL);
stage = clutter_stage_get_default ();

View File

@ -12,7 +12,8 @@ test_texture_material_main (int argc, char *argv[])
g_thread_init (NULL);
clutter_threads_init ();
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Texture Material");

View File

@ -54,7 +54,8 @@ test_texture_quality_main (int argc, char *argv[])
GError *error;
gchar *file;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);

View File

@ -57,7 +57,8 @@ test_textures_main (int argc, char *argv[])
ClutterActor *stage;
gint i, j;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
clutter_actor_show_all (CLUTTER_ACTOR (stage));

View File

@ -190,7 +190,8 @@ test_threads_main (int argc, char *argv[])
g_thread_init (NULL);
clutter_threads_init ();
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Threading");

View File

@ -101,7 +101,8 @@ test_unproject_main (int argc, char *argv[])
}
}
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();

View File

@ -75,16 +75,18 @@ main (int argc, char **argv)
const ClutterColor black = { 0x00, 0x00, 0x00, 0xff };
ClutterColor color = { 0x00, 0x00, 0x00, 0xff };
ClutterActor *stage, *rect;
GError *error = NULL;
g_setenv ("CLUTTER_VBLANK", "none", FALSE);
g_setenv ("CLUTTER_DEFAULT_FPS", "1000", FALSE);
g_setenv ("CLUTTER_SHOW_FPS", "1", FALSE);
clutter_init_with_args (&argc, &argv,
if (clutter_init_with_args (&argc, &argv,
NULL,
entries,
NULL,
NULL);
&error) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
clutter_actor_set_size (stage, 512, 512);

View File

@ -87,7 +87,8 @@ main (int argc, char *argv[])
{
ClutterActor *stage;
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();

View File

@ -114,7 +114,8 @@ main (int argc, char *argv[])
g_setenv ("CLUTTER_VBLANK", "none", FALSE);
g_setenv ("CLUTTER_DEFAULT_FPS", "1000", FALSE);
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
if (argc != 3)
{

View File

@ -50,7 +50,8 @@ main (int argc, char *argv[])
g_setenv ("CLUTTER_VBLANK", "none", FALSE);
g_setenv ("CLUTTER_DEFAULT_FPS", "1000", FALSE);
clutter_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_get_default ();
clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);