[glib/wip/smcv/address-sanitizer: 28/28] tests: Mark tests with AddressSanitizer-detected leaks




commit f3783520514a6ba8d15454e14175d086883cdb0f
Author: Simon McVittie <smcv collabora com>
Date:   Fri Jan 29 19:28:25 2021 +0000

    tests: Mark tests with AddressSanitizer-detected leaks
    
    Various tests have leaks where it isn't clear whether the data is
    intentionally not freed, or leaked due to a bug. If we mark these
    tests as TODO, we can skip them under AddressSanitizer and get the
    rest to pass, giving us a baseline from which to avoid regressions.
    
    Signed-off-by: Simon McVittie <smcv collabora com>

 gio/tests/cancellable.c        |  8 +++++++
 gio/tests/contenttype.c        | 51 ++++++++++++++++++++++++++++++++++++++++--
 gio/tests/gdbus-test-codegen.c | 15 +++++++++++++
 gio/tests/gmenumodel.c         | 14 ++++++++++++
 gio/tests/testfilemonitor.c    |  8 +++++++
 glib/tests/mainloop.c          |  5 +++++
 glib/tests/thread.c            |  6 ++++-
 7 files changed, 104 insertions(+), 3 deletions(-)
---
diff --git a/gio/tests/cancellable.c b/gio/tests/cancellable.c
index d6b52c1ea..1eb7529d6 100644
--- a/gio/tests/cancellable.c
+++ b/gio/tests/cancellable.c
@@ -22,6 +22,8 @@
 
 #include <gio/gio.h>
 
+#include "glib/glib-private.h"
+
 /* How long to wait in ms for each iteration */
 #define WAIT_ITERATION (10)
 
@@ -257,6 +259,11 @@ threaded_dispose_thread_cb (gpointer user_data)
 static void
 test_cancellable_source_threaded_dispose (void)
 {
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks lots of GCancellableSource objects, see glib#2309");
+  (void) cancelled_cb;
+  (void) threaded_dispose_thread_cb;
+#else
   ThreadedDisposeData data;
   GThread *thread = NULL;
   guint i;
@@ -326,6 +333,7 @@ test_cancellable_source_threaded_dispose (void)
   g_cond_clear (&data.cond);
 
   g_ptr_array_unref (cancellables_pending_unref);
+#endif
 }
 
 int
diff --git a/gio/tests/contenttype.c b/gio/tests/contenttype.c
index 3696e3662..71e8b0df6 100644
--- a/gio/tests/contenttype.c
+++ b/gio/tests/contenttype.c
@@ -1,6 +1,8 @@
 #include <gio/gio.h>
 #include <string.h>
 
+#include "glib/glib-private.h"
+
 #define g_assert_content_type_equals(s1, s2)                   \
   do {                                                                 \
     const char *__s1 = (s1), *__s2 = (s2);                     \
@@ -16,6 +18,9 @@
 static void
 test_guess (void)
 {
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks xdgmime internal data, see glib#2310");
+#else
   gchar *res;
   gchar *expected;
   gchar *existing_directory;
@@ -126,11 +131,15 @@ test_guess (void)
   g_assert_false (uncertain);
   g_free (res);
   g_free (expected);
+#endif
 }
 
 static void
 test_unknown (void)
 {
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks xdgmime internal data, see glib#2310");
+#else
   gchar *unknown;
   gchar *str;
 
@@ -140,11 +149,15 @@ test_unknown (void)
   g_assert_cmpstr (str, ==, "application/octet-stream");
   g_free (str);
   g_free (unknown);
+#endif
 }
 
 static void
 test_subtype (void)
 {
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks xdgmime internal data, see glib#2310");
+#else
   gchar *plain;
   gchar *xml;
 
@@ -156,6 +169,7 @@ test_subtype (void)
 
   g_free (plain);
   g_free (xml);
+#endif
 }
 
 static gint
@@ -169,6 +183,10 @@ find_mime (gconstpointer a, gconstpointer b)
 static void
 test_list (void)
 {
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks xdgmime internal data, see glib#2310");
+  (void) find_mime;
+#else
   GList *types;
   gchar *plain;
   gchar *xml;
@@ -193,11 +211,15 @@ test_list (void)
 
   g_free (plain);
   g_free (xml);
+#endif
 }
 
 static void
 test_executable (void)
 {
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks xdgmime internal data, see glib#2310");
+#else
   gchar *type;
 
   type = g_content_type_from_mime_type ("application/x-executable");
@@ -211,11 +233,15 @@ test_executable (void)
   type = g_content_type_from_mime_type ("image/png");
   g_assert_false (g_content_type_can_be_executable (type));
   g_free (type);
+#endif
 }
 
 static void
 test_description (void)
 {
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks xdgmime internal data, see glib#2310");
+#else
   gchar *type;
   gchar *desc;
 
@@ -225,11 +251,15 @@ test_description (void)
 
   g_free (desc);
   g_free (type);
+#endif
 }
 
 static void
 test_icon (void)
 {
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks xdgmime internal data, see glib#2310");
+#else
   gchar *type;
   GIcon *icon;
 
@@ -266,12 +296,15 @@ test_icon (void)
     }
   g_object_unref (icon);
   g_free (type);
+#endif
 }
 
 static void
 test_symbolic_icon (void)
 {
-#ifndef G_OS_WIN32
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks xdgmime internal data, see glib#2310");
+#elif !defined(G_OS_WIN32)
   gchar *type;
   GIcon *icon;
 
@@ -319,6 +352,9 @@ test_symbolic_icon (void)
 static void
 test_tree (void)
 {
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks xdgmime internal data, see glib#2310");
+#else
   const gchar *tests[] = {
     "x-content/image-dcf",
     "x-content/unix-software",
@@ -343,11 +379,15 @@ test_tree (void)
       g_strfreev (types);
       g_object_unref (file);
    }
+#endif
 }
 
 static void
 test_type_is_a_special_case (void)
 {
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks xdgmime internal data, see glib#2310");
+#else
   gboolean res;
 
   g_test_bug ("782311");
@@ -359,11 +399,15 @@ test_type_is_a_special_case (void)
   res = g_content_type_is_a ("anything", "application/octet-stream");
   g_assert_true (res);
 #endif
+#endif
 }
 
 static void
 test_guess_svg_from_data (void)
 {
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks xdgmime internal data, see glib#2310");
+#else
   const gchar svgfilecontent[] = "<svg  xmlns=\"http://www.w3.org/2000/svg\"\
       xmlns:xlink=\"http://www.w3.org/1999/xlink\";>\n\
     <rect x=\"10\" y=\"10\" height=\"100\" width=\"100\"\n\
@@ -382,12 +426,15 @@ test_guess_svg_from_data (void)
 #endif
   g_assert_false (uncertain);
   g_free (res);
+#endif
 }
 
 static void
 test_mime_from_content (void)
 {
-#ifdef __APPLE__
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks xdgmime internal data, see glib#2310");
+#elif defined(__APPLE__)
   gchar *mime_type;
   mime_type = g_content_type_get_mime_type ("com.microsoft.bmp");
   g_assert_cmpstr (mime_type, ==, "image/bmp");
diff --git a/gio/tests/gdbus-test-codegen.c b/gio/tests/gdbus-test-codegen.c
index 9a3ffa927..36be37b72 100644
--- a/gio/tests/gdbus-test-codegen.c
+++ b/gio/tests/gdbus-test-codegen.c
@@ -23,6 +23,8 @@
 #include <string.h>
 #include <stdio.h>
 
+#include "glib/glib-private.h"
+
 #include "gdbus-tests.h"
 
 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_64
@@ -1302,6 +1304,18 @@ static gpointer
 check_proxies_in_thread (gpointer user_data)
 {
   GMainLoop *loop = user_data;
+#ifdef _GLIB_ADDRESS_SANITIZER
+
+  /* Silence "Not available before 2.38" when using old API */
+  G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+  g_test_incomplete ("FIXME: Leaks a GWeakRef, see glib#2312");
+  G_GNUC_END_IGNORE_DEPRECATIONS
+
+  (void) check_thread_proxies;
+  (void) check_authorize_proxy;
+  (void) check_bat_proxy;
+  (void) check_bar_proxy;
+#else
   GMainContext *thread_context;
   GMainLoop *thread_loop;
   GError *error;
@@ -1370,6 +1384,7 @@ check_proxies_in_thread (gpointer user_data)
 
   g_main_loop_unref (thread_loop);
   g_main_context_unref (thread_context);
+#endif
 
   /* this breaks out of the loop in main() (below) */
   g_main_loop_quit (loop);
diff --git a/gio/tests/gmenumodel.c b/gio/tests/gmenumodel.c
index fc0fcea48..492daf8c4 100644
--- a/gio/tests/gmenumodel.c
+++ b/gio/tests/gmenumodel.c
@@ -5,6 +5,8 @@
 
 #include "gdbus-sessionbus.h"
 
+#include "glib/glib-private.h"
+
 static gboolean
 time_out (gpointer unused G_GNUC_UNUSED)
 {
@@ -1012,11 +1014,17 @@ test_dbus_roundtrip (void)
 static void
 test_dbus_peer_roundtrip (void)
 {
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks a GCancellableSource, see glib#2313");
+  (void) peer_connection_up;
+  (void) peer_connection_down;
+#else
   PeerConnection peer;
 
   peer_connection_up (&peer);
   do_roundtrip (peer.server_connection, peer.client_connection);
   peer_connection_down (&peer);
+#endif
 }
 
 static gint items_changed_count;
@@ -1145,11 +1153,17 @@ test_dbus_subscriptions (void)
 static void
 test_dbus_peer_subscriptions (void)
 {
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks a GCancellableSource, see glib#2313");
+  (void) peer_connection_up;
+  (void) peer_connection_down;
+#else
   PeerConnection peer;
 
   peer_connection_up (&peer);
   do_subscriptions (peer.server_connection, peer.client_connection);
   peer_connection_down (&peer);
+#endif
 }
 
 static gpointer
diff --git a/gio/tests/testfilemonitor.c b/gio/tests/testfilemonitor.c
index b74dc2b71..44c70805b 100644
--- a/gio/tests/testfilemonitor.c
+++ b/gio/tests/testfilemonitor.c
@@ -4,6 +4,8 @@
 #include <stdlib.h>
 #include <gio/gio.h>
 
+#include "glib/glib-private.h"
+
 /* These tests were written for the inotify implementation.
  * Other implementations may require slight adjustments in
  * the tests, e.g. the length of timeouts
@@ -954,6 +956,11 @@ static void
 test_file_hard_links (Fixture       *fixture,
                       gconstpointer  user_data)
 {
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks an inotify data structure, see glib#2311");
+  (void) file_hard_links_output;
+  (void) file_hard_links_step;
+#else
   GError *error = NULL;
   TestData data;
 
@@ -1004,6 +1011,7 @@ test_file_hard_links (Fixture       *fixture,
   g_object_unref (data.monitor);
   g_object_unref (data.file);
   g_object_unref (data.output_stream);
+#endif
 }
 
 int
diff --git a/glib/tests/mainloop.c b/glib/tests/mainloop.c
index 563a951de..d43b2cf08 100644
--- a/glib/tests/mainloop.c
+++ b/glib/tests/mainloop.c
@@ -1645,6 +1645,10 @@ threadf (gpointer data)
 static void
 test_mainloop_wait (void)
 {
+#ifdef _GLIB_ADDRESS_SANITIZER
+  (void) threadf;
+  g_test_incomplete ("FIXME: Leaks a GMainLoop, see glib#2307");
+#else
   GMainContext *context;
   GThread *t1, *t2;
 
@@ -1657,6 +1661,7 @@ test_mainloop_wait (void)
   g_thread_join (t2);
 
   g_main_context_unref (context);
+#endif
 }
 #endif
 
diff --git a/glib/tests/thread.c b/glib/tests/thread.c
index 579ce1fca..2bae96c58 100644
--- a/glib/tests/thread.c
+++ b/glib/tests/thread.c
@@ -33,6 +33,8 @@
 
 #include <glib.h>
 
+#include "glib/glib-private.h"
+
 #ifdef G_OS_UNIX
 #include <unistd.h>
 #include <sys/resource.h>
@@ -132,7 +134,9 @@ test_thread3 (void)
 static void
 test_thread4 (void)
 {
-#ifdef HAVE_PRLIMIT
+#ifdef _GLIB_ADDRESS_SANITIZER
+  g_test_incomplete ("FIXME: Leaks a GSystemThread's name, see glib#2308");
+#elif defined(HAVE_PRLIMIT)
   struct rlimit ol, nl;
   GThread *thread;
   GError *error;


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