From bcd4385a0e1fe34f0be6cac906ff32ab42c43d3c Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Tue, 21 Sep 2010 13:17:53 +0100 Subject: [PATCH] test-conform: Delay initializing Clutter until a test is run Instead of calling clutter_init immediately, test-conformance now only calls it as part of test_conform_simple_fixture_setup. The conformance tests assert that only one test is run per instance of test-conformance so it should never end up calling clutter_init twice. Delaying clutter_init has the advantage that calling "test-conformance -l" will still work even on systems with no X server. This could be useful for automated build systems. --- tests/conform/test-conform-common.c | 21 +++++++++++++++++++++ tests/conform/test-conform-main.c | 15 --------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/tests/conform/test-conform-common.c b/tests/conform/test-conform-common.c index 8ff8d0d6f..e6fc55dfe 100644 --- a/tests/conform/test-conform-common.c +++ b/tests/conform/test-conform-common.c @@ -1,4 +1,7 @@ +#include "config.h" + #include +#include #ifdef COGL_HAS_XLIB #include @@ -16,6 +19,7 @@ void test_conform_simple_fixture_setup (TestConformSimpleFixture *fixture, gconstpointer data) { + const TestConformSharedState *shared_state = data; static int counter = 0; if (counter != 0) @@ -27,6 +31,23 @@ test_conform_simple_fixture_setup (TestConformSimpleFixture *fixture, "$ make test-report"); counter++; +#ifdef HAVE_CLUTTER_GLX + { + /* on X11 we need a display connection to run the test suite */ + const gchar *display = g_getenv ("DISPLAY"); + if (!display || *display == '\0') + { + g_print ("No DISPLAY found. Unable to run the conformance " + "test suite without a display.\n"); + + exit (EXIT_SUCCESS); + } + } +#endif + + g_assert (clutter_init (shared_state->argc_addr, shared_state->argv_addr) + == CLUTTER_INIT_SUCCESS); + #ifdef COGL_HAS_XLIB /* A lot of the tests depend on a specific stage / framebuffer size * when they read pixels back to verify the results of the test. diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c index 978ce4be4..a6b236164 100644 --- a/tests/conform/test-conform-main.c +++ b/tests/conform/test-conform-main.c @@ -69,18 +69,6 @@ static void clutter_test_init (gint *argc, gchar ***argv) { -#ifdef HAVE_CLUTTER_GLX - /* on X11 we need a display connection to run the test suite */ - const gchar *display = g_getenv ("DISPLAY"); - if (!display || *display == '\0') - { - g_print ("No DISPLAY found. Unable to run the conformance " - "test suite without a display."); - - exit (EXIT_SUCCESS); - } -#endif - /* Turning of sync-to-vblank removes a dependency on the specifics of the * test environment. It also means that the timeline-only tests are * throttled to a reasonable frame rate rather than running in tight @@ -97,9 +85,6 @@ clutter_test_init (gint *argc, shared_state = g_new0 (TestConformSharedState, 1); shared_state->argc_addr = argc; shared_state->argv_addr = argv; - - g_assert (clutter_init (shared_state->argc_addr, shared_state->argv_addr) - == CLUTTER_INIT_SUCCESS); } int