[glib: 2/3] tests: Reduce iteration counts on gdbus-threading test



commit 238c7749703ef9bf1de6e6b27ebf04c8c4b02b4b
Author: Philip Withnall <withnall endlessm com>
Date:   Mon Feb 24 12:19:52 2020 +0000

    tests: Reduce iteration counts on gdbus-threading test
    
    When running under CI, each iteration takes so long that the total test
    time is around 200s. If the CI runner is highly loaded, this can tip it
    over the timeout of 360s.
    
    Reduce the iteration counts unless running the test thoroughly.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    Helps: #1515

 gio/tests/gdbus-threading.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/gio/tests/gdbus-threading.c b/gio/tests/gdbus-threading.c
index 9eebe27df..2b89fb079 100644
--- a/gio/tests/gdbus-threading.c
+++ b/gio/tests/gdbus-threading.c
@@ -406,7 +406,7 @@ test_sleep_in_thread_func (gpointer _data)
 static void
 test_method_calls_on_proxy (GDBusProxy *proxy)
 {
-  guint n;
+  guint n, divisor;
 
   /*
    * Check that multiple threads can do calls without interferring with
@@ -425,6 +425,11 @@ test_method_calls_on_proxy (GDBusProxy *proxy)
    * again with sync calls
    */
 
+  if (g_test_thorough ())
+    divisor = 1;
+  else
+    divisor = 10;
+
   for (n = 0; n < 2; n++)
     {
       gboolean do_async;
@@ -443,7 +448,7 @@ test_method_calls_on_proxy (GDBusProxy *proxy)
 
       data1.proxy = proxy;
       data1.msec = 40;
-      data1.num = 100;
+      data1.num = 100 / divisor;
       data1.async = do_async;
       thread1 = g_thread_new ("sleep",
                               test_sleep_in_thread_func,
@@ -451,7 +456,7 @@ test_method_calls_on_proxy (GDBusProxy *proxy)
 
       data2.proxy = proxy;
       data2.msec = 20;
-      data2.num = 200;
+      data2.num = 200 / divisor;
       data2.async = do_async;
       thread2 = g_thread_new ("sleep2",
                               test_sleep_in_thread_func,
@@ -459,7 +464,7 @@ test_method_calls_on_proxy (GDBusProxy *proxy)
 
       data3.proxy = proxy;
       data3.msec = 100;
-      data3.num = 40;
+      data3.num = 40 / divisor;
       data3.async = do_async;
       thread3 = g_thread_new ("sleep3",
                               test_sleep_in_thread_func,
@@ -476,8 +481,8 @@ test_method_calls_on_proxy (GDBusProxy *proxy)
       //g_debug ("Elapsed time for %s = %d msec", n == 0 ? "async" : "sync", elapsed_msec);
 
       /* elapsed_msec should be 4000 msec +/- change for overhead/inaccuracy */
-      g_assert_cmpint (elapsed_msec, >=, 3950);
-      g_assert_cmpint (elapsed_msec,  <, 30000);
+      g_assert_cmpint (elapsed_msec, >=, 3950 / divisor);
+      g_assert_cmpint (elapsed_msec,  <, 30000 / divisor);
 
       if (g_test_verbose ())
         g_printerr (" ");
@@ -575,7 +580,7 @@ test_threaded_singleton (void)
   if (g_test_thorough ())
     n = 100000;
   else
-    n = 5000;
+    n = 1000;
 
   for (i = 0; i < n; i++)
     {


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