[cogl] conform: explicitly check value of boolean env vars
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] conform: explicitly check value of boolean env vars
- Date: Fri, 15 Feb 2013 17:41:30 +0000 (UTC)
commit 25a8cf3607a482ca390eb9841295d1b365cbe53b
Author: Robert Bragg <robert linux intel com>
Date: Fri Feb 15 17:21:04 2013 +0000
conform: explicitly check value of boolean env vars
For the boolean environment variables that affect the running of the
conformance tests we now explicitly check the value of those variables
so that "0", "off" and "false" (upper or lower case) will be considered
as FALSE instead of just interpreting set as TRUE and unset as FALSE. If
the value is set to something entirely spurious then we abort with a
warning message. Thanks to Artie Eoff for suggesting this change.
https://bugzilla.gnome.org/show_bug.cgi?id=693894
Reviewed-by: Neil Roberts <neil linux intel com>
tests/conform/test-utils.c | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/tests/conform/test-utils.c b/tests/conform/test-utils.c
index 653791e..a3d1c14 100644
--- a/tests/conform/test-utils.c
+++ b/tests/conform/test-utils.c
@@ -78,6 +78,33 @@ check_flags (TestFlags flags,
return TRUE;
}
+CoglBool
+is_boolean_env_set (const char *variable)
+{
+ char *val = getenv (variable);
+ CoglBool ret;
+
+ if (!val)
+ return FALSE;
+
+ if (g_ascii_strcasecmp (val, "1") == 0 ||
+ g_ascii_strcasecmp (val, "on") == 0 ||
+ g_ascii_strcasecmp (val, "true") == 0)
+ ret = TRUE;
+ else if (g_ascii_strcasecmp (val, "0") == 0 ||
+ g_ascii_strcasecmp (val, "off") == 0 ||
+ g_ascii_strcasecmp (val, "false") == 0)
+ ret = FALSE;
+ else
+ {
+ g_critical ("Spurious boolean environment variable value (%s=%s)",
+ variable, val);
+ ret = TRUE;
+ }
+
+ return ret;
+}
+
void
test_utils_init (TestFlags requirement_flags,
TestFlags known_failure_flags)
@@ -99,7 +126,8 @@ test_utils_init (TestFlags requirement_flags,
"$ make test-report");
counter++;
- if (g_getenv ("COGL_TEST_VERBOSE") || g_getenv ("V"))
+ if (is_boolean_env_set ("COGL_TEST_VERBOSE") ||
+ is_boolean_env_set ("V"))
cogl_test_is_verbose = TRUE;
if (g_getenv ("G_DEBUG"))
@@ -123,7 +151,7 @@ test_utils_init (TestFlags requirement_flags,
missing_requirement = !check_flags (requirement_flags, renderer);
known_failure = !check_flags (known_failure_flags, renderer);
- if (getenv ("COGL_TEST_ONSCREEN"))
+ if (is_boolean_env_set ("COGL_TEST_ONSCREEN"))
{
onscreen = cogl_onscreen_new (test_ctx, 640, 480);
test_fb = COGL_FRAMEBUFFER (onscreen);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]