From 59a2bff8e2db004282b5bea4f1f577a2dfdd8950 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 27 May 2020 15:16:25 +0100 Subject: [PATCH] cogl tests: Normally skip tests that are not expected to succeed If a test is not expected to succeed, then running it could be considered to be a waste of resources, particularly if the failure might manifest as an indefinite hang (see cogl!11), or if the test is likely to dump core and trigger "expensive" crash-reporting mechanisms like systemd-coredump, corekeeper, abrt or apport. Skip the tests that are expected to fail. They can still be requested via an environment variable, which can be set after fixing a bug to check which tests are now passing. Originally cogl!15, adapted for mutter's fork of cogl to use gboolean instead of CoglBool. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1272 Signed-off-by: Simon McVittie --- cogl/test-fixtures/test-utils.c | 4 +++- cogl/test-fixtures/test-utils.h | 2 +- cogl/tests/conform/test-conform-main.c | 15 +++++++++++---- cogl/tests/unit/test-unit-main.c | 18 ++++++++++++------ 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/cogl/test-fixtures/test-utils.c b/cogl/test-fixtures/test-utils.c index 47586867e..a59160f09 100644 --- a/cogl/test-fixtures/test-utils.c +++ b/cogl/test-fixtures/test-utils.c @@ -77,7 +77,7 @@ is_boolean_env_set (const char *variable) return ret; } -void +gboolean test_utils_init (TestFlags requirement_flags, TestFlags known_failure_flags) { @@ -156,6 +156,8 @@ test_utils_init (TestFlags requirement_flags, g_print ("WARNING: Missing required feature[s] for this test\n"); else if (known_failure) g_print ("WARNING: Test is known to fail\n"); + + return (!missing_requirement && !known_failure); } void diff --git a/cogl/test-fixtures/test-utils.h b/cogl/test-fixtures/test-utils.h index fe76a53e3..b584badec 100644 --- a/cogl/test-fixtures/test-utils.h +++ b/cogl/test-fixtures/test-utils.h @@ -68,7 +68,7 @@ typedef enum extern CoglContext *test_ctx; extern CoglFramebuffer *test_fb; -void +gboolean test_utils_init (TestFlags requirement_flags, TestFlags known_failure_flags); diff --git a/cogl/tests/conform/test-conform-main.c b/cogl/tests/conform/test-conform-main.c index 5afa0ed8f..e1f32c5e2 100644 --- a/cogl/tests/conform/test-conform-main.c +++ b/cogl/tests/conform/test-conform-main.c @@ -15,10 +15,17 @@ G_STMT_START { \ if (strcmp (#FUNC, argv[1]) == 0) \ { \ - test_utils_init (REQUIREMENTS, KNOWN_FAIL_REQUIREMENTS); \ - FUNC (); \ - test_utils_fini (); \ - exit (0); \ + if (test_utils_init (REQUIREMENTS, KNOWN_FAIL_REQUIREMENTS) \ + || g_getenv ("COGL_TEST_TRY_EVERYTHING") != NULL) \ + { \ + FUNC (); \ + test_utils_fini (); \ + exit (0); \ + } \ + else \ + { \ + exit (1); \ + } \ } \ } G_STMT_END diff --git a/cogl/tests/unit/test-unit-main.c b/cogl/tests/unit/test-unit-main.c index 4be6700ef..cb446de62 100644 --- a/cogl/tests/unit/test-unit-main.c +++ b/cogl/tests/unit/test-unit-main.c @@ -36,10 +36,16 @@ main (int argc, char **argv) return 1; } - test_utils_init (unit_test->requirement_flags, - unit_test->known_failure_flags); - unit_test->run (); - test_utils_fini (); - - return 0; + if (test_utils_init (unit_test->requirement_flags, + unit_test->known_failure_flags) + || g_getenv ("COGL_TEST_TRY_EVERYTHING") != NULL) + { + unit_test->run (); + test_utils_fini (); + return 0; + } + else + { + return 1; + } }