[glib/wip/pwithnall/error-tests-nonliteral] tests: Only run g_error_new_valist() programmer error test on Linux




commit 885d65077eec34434cbfd363de5ffcf813f0bb1d
Author: Philip Withnall <pwithnall endlessos org>
Date:   Thu Jan 7 16:03:28 2021 +0000

    tests: Only run g_error_new_valist() programmer error test on Linux
    
    On FreeBSD it always crashes due to the platform’s `vasprintf()`
    implementation being less forgiving than Linux’s. That’s fine.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 glib/tests/error.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/glib/tests/error.c b/glib/tests/error.c
index cbf146a2e..4f4c6b3c7 100644
--- a/glib/tests/error.c
+++ b/glib/tests/error.c
@@ -100,6 +100,12 @@ static void
 test_new_valist_invalid_va (gpointer dummy,
                          ...)
 {
+#ifdef __linux__
+  /* Only worth testing this on Linux; if other platforms regress on this legacy
+   * behaviour, we don’t care. In particular, calling g_error_new_valist() with
+   * a %NULL format will crash on FreeBSD as its implementation of vasprintf()
+   * is less forgiving than Linux’s. That’s fine: it’s a programmer error in
+   * either case. */
   const struct
     {
       GQuark domain;
@@ -119,6 +125,8 @@ test_new_valist_invalid_va (gpointer dummy,
       GError *error = NULL, *error_copy = NULL;
       va_list ap;
 
+      g_test_message ("Test %" G_GSIZE_FORMAT, i);
+
       va_start (ap, dummy);
 
 #pragma GCC diagnostic push
@@ -145,6 +153,9 @@ test_new_valist_invalid_va (gpointer dummy,
 
       va_end (ap);
     }
+#else  /* if !__linux__ */
+  g_test_skip ("g_error_new_valist() programmer error handling is only relevant on Linux");
+#endif  /* !__linux__ */
 }
 
 static void


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