You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@apache.org on 2013/10/12 18:17:44 UTC

svn commit: r1531556 - in /apr/apr/branches/1.5.x: ./ CMakeLists.txt test/testlockperf.c

Author: trawick
Date: Sat Oct 12 16:17:43 2013
New Revision: 1531556

URL: http://svn.apache.org/r1531556
Log:
Merge r1531554 from trunk:

don't spend 10 minutes in testlockperf during make test/check on Windows

Modified:
    apr/apr/branches/1.5.x/   (props changed)
    apr/apr/branches/1.5.x/CMakeLists.txt
    apr/apr/branches/1.5.x/test/testlockperf.c

Propchange: apr/apr/branches/1.5.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r1531554

Modified: apr/apr/branches/1.5.x/CMakeLists.txt
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/CMakeLists.txt?rev=1531556&r1=1531555&r2=1531556&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/CMakeLists.txt (original)
+++ apr/apr/branches/1.5.x/CMakeLists.txt Sat Oct 12 16:17:43 2013
@@ -362,7 +362,6 @@ IF(APR_BUILD_TESTAPR)
 
   # Add tests for programs that run by themselves with no arguments.
   SET(simple_tests
-    testlockperf
     testmutexscope
     testucs
   )
@@ -371,6 +370,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)
+
   # sendfile runs multiple times with different parameters.
   FOREACH(sendfile_mode blocking nonblocking timeout)
     ADD_TEST(NAME sendfile-${sendfile_mode} COMMAND sendfile client ${sendfile_mode} startserver)

Modified: apr/apr/branches/1.5.x/test/testlockperf.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/test/testlockperf.c?rev=1531556&r1=1531555&r2=1531556&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/test/testlockperf.c (original)
+++ apr/apr/branches/1.5.x/test/testlockperf.c Sat Oct 12 16:17:43 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;
         }
     }