apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r1531554 - in /apr/apr/trunk: CMakeLists.txt test/testlockperf.c
Date Sat, 12 Oct 2013 16:06:15 GMT
Author: trawick
Date: Sat Oct 12 16:06:15 2013
New Revision: 1531554

URL: http://svn.apache.org/r1531554
Log:
don't spend 10 minutes in testlockperf during make test/check on Windows

Modified:
    apr/apr/trunk/CMakeLists.txt
    apr/apr/trunk/test/testlockperf.c

Modified: apr/apr/trunk/CMakeLists.txt
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CMakeLists.txt?rev=1531554&r1=1531553&r2=1531554&view=diff
==============================================================================
--- apr/apr/trunk/CMakeLists.txt (original)
+++ apr/apr/trunk/CMakeLists.txt Sat Oct 12 16:06:15 2013
@@ -547,7 +547,6 @@ IF(APR_BUILD_TESTAPR)
 
   # Add tests for programs that run by themselves with no arguments.
   SET(simple_tests
-    testlockperf
     testmutexscope
     testucs
   )
@@ -556,6 +555,9 @@ IF(APR_BUILD_TESTAPR)
     ADD_TEST(NAME ${simple} COMMAND ${simple})
   ENDFOREACH()
 
+  # testlockperf takes forever on Windows with default counter limit
+  ADD_TEST(NAME testlockperf COMMAND testlockperf -c 50000)
+
   # dbd and sendfile are run multiple times with different parameters.
   FOREACH(somedbd ${dbd_drivers})
     ADD_TEST(NAME dbd-${somedbd} COMMAND dbd ${somedbd})

Modified: apr/apr/trunk/test/testlockperf.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testlockperf.c?rev=1531554&r1=1531553&r2=1531554&view=diff
==============================================================================
--- apr/apr/trunk/test/testlockperf.c (original)
+++ apr/apr/trunk/test/testlockperf.c Sat Oct 12 16:06:15 2013
@@ -35,11 +35,12 @@ int main(void)
 }
 #else /* !APR_HAS_THREADS */
 
-#define MAX_COUNTER 1000000
+#define DEFAULT_MAX_COUNTER 1000000
 #define MAX_THREADS 6
 
 static int verbose = 0;
 static long mutex_counter;
+static long max_counter = DEFAULT_MAX_COUNTER;
 
 static apr_thread_mutex_t *thread_lock;
 void * APR_THREAD_FUNC thread_mutex_func(apr_thread_t *thd, void *data);
@@ -58,7 +59,7 @@ void * APR_THREAD_FUNC thread_mutex_func
 {
     int i;
 
-    for (i = 0; i < MAX_COUNTER; i++) {
+    for (i = 0; i < max_counter; i++) {
         apr_thread_mutex_lock(thread_lock);
         mutex_counter++;
         apr_thread_mutex_unlock(thread_lock);
@@ -70,7 +71,7 @@ void * APR_THREAD_FUNC thread_rwlock_fun
 {
     int i;
 
-    for (i = 0; i < MAX_COUNTER; i++) {
+    for (i = 0; i < max_counter; i++) {
         apr_thread_rwlock_wrlock(thread_rwlock);
         mutex_counter++;
         apr_thread_rwlock_unlock(thread_rwlock);
@@ -120,7 +121,7 @@ int test_thread_mutex(int num_threads)
     time_stop = apr_time_now();
     printf("microseconds: %" APR_INT64_T_FMT " usec\n",
            (time_stop - time_start));
-    if (mutex_counter != MAX_COUNTER * num_threads)
+    if (mutex_counter != max_counter * num_threads)
         printf("error: counter = %ld\n", mutex_counter);
 
     return APR_SUCCESS;
@@ -168,7 +169,7 @@ int test_thread_mutex_nested(int num_thr
     time_stop = apr_time_now();
     printf("microseconds: %" APR_INT64_T_FMT " usec\n",
            (time_stop - time_start));
-    if (mutex_counter != MAX_COUNTER * num_threads)
+    if (mutex_counter != max_counter * num_threads)
         printf("error: counter = %ld\n", mutex_counter);
 
     return APR_SUCCESS;
@@ -216,7 +217,7 @@ int test_thread_rwlock(int num_threads)
     time_stop = apr_time_now();
     printf("microseconds: %" APR_INT64_T_FMT " usec\n",
            (time_stop - time_start));
-    if (mutex_counter != MAX_COUNTER * num_threads)
+    if (mutex_counter != max_counter * num_threads)
         printf("error: counter = %ld\n", mutex_counter);
 
     return APR_SUCCESS;
@@ -244,8 +245,11 @@ int main(int argc, const char * const *a
         exit(-1);
     }
         
-    while ((rv = apr_getopt(opt, "v", &optchar, &optarg)) == APR_SUCCESS) {
-        if (optchar == 'v') {
+    while ((rv = apr_getopt(opt, "c:v", &optchar, &optarg)) == APR_SUCCESS) {
+        if (optchar == 'c') {
+            max_counter = atol(optarg);
+        }
+        else if (optchar == 'v') {
             verbose = 1;
         }
     }



Mime
View raw message