[glib/wip/gcleanup: 33/79] 642026: Run less locking iterations under valgrind



commit d01d884234a769dc67278722538ea57bcc4b6f1b
Author: Stef Walter <stefw gnome org>
Date:   Fri Nov 8 08:44:20 2013 +0100

    642026: Run less locking iterations under valgrind
    
    Otherwise these tests are prohibitively slow.  Under valgrind the
    same race conditions aren't likely to show up anyway.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711744

 glib/tests/642026.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/glib/tests/642026.c b/glib/tests/642026.c
index 05f9f25..ab23d27 100644
--- a/glib/tests/642026.c
+++ b/glib/tests/642026.c
@@ -14,9 +14,11 @@
 
 #include <glib.h>
 
+#include "valgrind.h"
+
 /* On smcv's laptop, 1e4 iterations didn't always exhibit the bug, but 1e5
  * iterations exhibited it 10/10 times in practice. YMMV. */
-#define ITERATIONS 100000
+static guint iterations = 100000;
 
 static GStaticPrivate sp;
 static GMutex *mutex;
@@ -56,7 +58,7 @@ testcase (void)
 
   g_mutex_lock (mutex);
 
-  for (i = 0; i < ITERATIONS; i++)
+  for (i = 0; i < iterations; i++)
     {
       GThread *t1;
 
@@ -85,6 +87,10 @@ main (int argc,
   g_test_init (&argc, &argv, NULL);
   g_test_bug_base ("https://bugzilla.gnome.org/show_bug.cgi?id=";);
 
+  /* This stuff is extremely slow in valgrind */
+  if (RUNNING_ON_VALGRIND)
+    iterations = 10;
+
   g_test_add_func ("/glib/642026", testcase);
 
   return g_test_run ();


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