From: Paolo Bonzini Date: Tue, 16 Mar 2021 09:02:49 +0000 (+0100) Subject: glib-compat: accept G_TEST_SLOW environment variable X-Git-Tag: v6.1.0-rc0~138^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9ba5db49aea924175b8f23edd388fa2452206d20;p=thirdparty%2Fqemu.git glib-compat: accept G_TEST_SLOW environment variable Provide an alternative way to pass the desired thoroughness of the test. Signed-off-by: Paolo Bonzini --- diff --git a/include/glib-compat.h b/include/glib-compat.h index 695a96f7ea6..4542e920d51 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -100,6 +100,23 @@ g_unix_get_passwd_entry_qemu(const gchar *user_name, GError **error) } #endif /* G_OS_UNIX */ +static inline bool +qemu_g_test_slow(void) +{ + static int cached = -1; + if (cached == -1) { + cached = g_test_slow() || getenv("G_TEST_SLOW") != NULL; + } + return cached; +} + +#undef g_test_slow +#undef g_test_thorough +#undef g_test_quick +#define g_test_slow() qemu_g_test_slow() +#define g_test_thorough() qemu_g_test_slow() +#define g_test_quick() (!qemu_g_test_slow()) + #pragma GCC diagnostic pop #endif