[gtk+] Port display tests to g_test_trap_subprocess
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Port display tests to g_test_trap_subprocess
- Date: Thu, 30 May 2013 01:37:40 +0000 (UTC)
commit c9890d6cbb353e2df77f8a675d82e674a894ae06
Author: Matthias Clasen <mclasen redhat com>
Date: Wed May 29 21:11:14 2013 -0400
Port display tests to g_test_trap_subprocess
testsuite/gdk/display.c | 82 +++++++++++++++++++++++++----------------------
1 files changed, 44 insertions(+), 38 deletions(-)
---
diff --git a/testsuite/gdk/display.c b/testsuite/gdk/display.c
index b4f64ac..6ca7818 100644
--- a/testsuite/gdk/display.c
+++ b/testsuite/gdk/display.c
@@ -3,61 +3,63 @@
#include <gdk/gdk.h>
static void
-test_unset_display (void)
+test_unset_display_subprocess1 (void)
{
- if (g_test_trap_fork (0, 0))//G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
- {
- GdkDisplayManager *manager;
-
- g_unsetenv ("DISPLAY");
+ GdkDisplayManager *manager;
- g_assert (!gdk_init_check (NULL, NULL));
- manager = gdk_display_manager_get ();
- g_assert (manager != NULL);
- g_assert (gdk_display_manager_get_default_display (manager) == NULL);
+ g_unsetenv ("DISPLAY");
- exit (0);
- }
- g_test_trap_assert_passed ();
+ g_assert (!gdk_init_check (NULL, NULL));
+ manager = gdk_display_manager_get ();
+ g_assert (manager != NULL);
+ g_assert (gdk_display_manager_get_default_display (manager) == NULL);
+}
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
- {
- g_unsetenv ("DISPLAY");
+static void
+test_unset_display_subprocess2 (void)
+{
+ g_unsetenv ("DISPLAY");
+ gdk_init (NULL, NULL);
+}
- gdk_init (NULL, NULL);
+static void
+test_unset_display (void)
+{
+ g_test_trap_subprocess ("/display/unset-display/subprocess/1", 0, 0);
+ g_test_trap_assert_passed ();
- exit (0);
- }
+ g_test_trap_subprocess ("/display/unset-display/subprocess/2", 0, 0);
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*cannot open display*");
}
static void
-test_bad_display (void)
+test_bad_display_subprocess1 (void)
{
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
- {
- GdkDisplayManager *manager;
-
- g_setenv ("DISPLAY", "poo", TRUE);
+ GdkDisplayManager *manager;
- g_assert (!gdk_init_check (NULL, NULL));
- manager = gdk_display_manager_get ();
- g_assert (manager != NULL);
- g_assert (gdk_display_manager_get_default_display (manager) == NULL);
+ g_setenv ("DISPLAY", "poo", TRUE);
- exit (0);
- }
- g_test_trap_assert_passed ();
+ g_assert (!gdk_init_check (NULL, NULL));
+ manager = gdk_display_manager_get ();
+ g_assert (manager != NULL);
+ g_assert (gdk_display_manager_get_default_display (manager) == NULL);
+}
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
- {
- g_setenv ("DISPLAY", "poo", TRUE);
+static void
+test_bad_display_subprocess2 (void)
+{
+ g_setenv ("DISPLAY", "poo", TRUE);
+ gdk_init (NULL, NULL);
+}
- gdk_init (NULL, NULL);
+static void
+test_bad_display (void)
+{
+ g_test_trap_subprocess ("/display/bad-display/subprocess/1", 0, 0);
+ g_test_trap_assert_passed ();
- exit (0);
- }
+ g_test_trap_subprocess ("/display/bad-display/subprocess/2", 0, 0);
g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*cannot open display*");
}
@@ -68,7 +70,11 @@ main (int argc, char *argv[])
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/display/unset-display", test_unset_display);
+ g_test_add_func ("/display/unset-display/subprocess/1", test_unset_display_subprocess1);
+ g_test_add_func ("/display/unset-display/subprocess/2", test_unset_display_subprocess2);
g_test_add_func ("/display/bad-display", test_bad_display);
+ g_test_add_func ("/display/bad-display/subprocess/1", test_bad_display_subprocess1);
+ g_test_add_func ("/display/bad-display/subprocess/2", test_bad_display_subprocess2);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]