[glib/fix-refcount-macro-non-gcc] glib/tests/refcount.c: Only expect saturation tests to pass on GCC



commit 27c7084df2acce48e53c3218a67126fa4190af3a
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Jun 14 17:05:09 2019 +0800

    glib/tests/refcount.c: Only expect saturation tests to pass on GCC
    
    From grefcount.h, in order to disable warnings when G_DISABLE_CHECKS is
    defined, we need to make use of the GCC-isque-only __extension__ for it
    to work.  This means that in the saturation tests, we can only expect no
    warnings to show if we are building on GCC-isque compilers with
    G_DISABLE_CHECKS defined.
    
    This will fix the refcount-macro test on Visual Studio builds at least.

 glib/tests/refcount.c | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)
---
diff --git a/glib/tests/refcount.c b/glib/tests/refcount.c
index dfccc92c7..51c6baf50 100644
--- a/glib/tests/refcount.c
+++ b/glib/tests/refcount.c
@@ -76,7 +76,8 @@ test_grefcount (void)
 
 /* test_grefcount_saturation: Saturating a grefcount counter
  * does not cause an overflow; additionally, if we're building
- * with checks enabled, it'll cause a warning
+ * with checks enabled or with non-GCC compilers, it'll cause a
+ * warning
  */
 static void
 test_grefcount_saturation (void)
@@ -97,18 +98,18 @@ test_grefcount_saturation (void)
       exit (0);
     }
 
-  g_test_trap_subprocess (NULL, 0, 0);
+  g_test_trap_subprocess (NULL, 0, G_TEST_SUBPROCESS_INHERIT_STDOUT);
 
-#ifndef G_DISABLE_CHECKS
-  /* Ensure that we got a warning when building with checks; the
-   * test will fail because of the critical warning being caught
-   * by GTest
+#if defined (G_DISABLE_CHECKS) && defined (__GNUC__)
+  /* With checks disabled we don't get any warning */
+  g_test_trap_assert_passed ();
+#else
+  /* Ensure that we got a warning when building with checks or with
+   * non-GCC compilers; the test will fail because of the critical
+   * warning being caught by GTest
    */
   g_test_trap_assert_failed ();
   g_test_trap_assert_stderr ("*saturation*");
-#else
-  /* With checks disabled we don't get any warning */
-  g_test_trap_assert_passed ();
 #endif
 }
 
@@ -167,9 +168,9 @@ test_gatomicrefcount (void)
   g_assert_true (g_atomic_ref_count_dec (&a));
 }
 
-/* test_grefcount_saturation: Saturating a gatomicrefcount counter
- * does not cause an overflow; additionally, if we're building
- * with checks enabled, it'll cause a warning
+/* test_gatomicrefcount_saturation: Saturating a gatomicrefcount counter
+ * does not cause an overflow; additionally, if we're building with
+ * checks enabled or with non-GCC compilers, it'll cause a warning
  */
 static void
 test_gatomicrefcount_saturation (void)
@@ -192,16 +193,16 @@ test_gatomicrefcount_saturation (void)
 
   g_test_trap_subprocess (NULL, 0, 0);
 
-#ifndef G_DISABLE_CHECKS
-  /* Ensure that we got a warning when building with checks; the
-   * test will fail because of the critical warning being caught
-   * by GTest
+#if defined (G_DISABLE_CHECKS) && defined (__GNUC__)
+  /* With checks disabled we don't get any warning */
+  g_test_trap_assert_passed ();
+#else
+  /* Ensure that we got a warning when building with checks or with
+   * non-GCC compilers; the test will fail because of the critical
+   * warning being caught by GTest
    */
   g_test_trap_assert_failed ();
   g_test_trap_assert_stderr ("*saturation*");
-#else
-  /* With checks disabled we don't get any warning */
-  g_test_trap_assert_passed ();
 #endif
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]