apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rpl...@apache.org
Subject svn commit: r563104 - /apr/apr-util/trunk/test/testreslist.c
Date Mon, 06 Aug 2007 10:48:32 GMT
Author: rpluem
Date: Mon Aug  6 03:48:32 2007
New Revision: 563104

URL: http://svn.apache.org/viewvc?view=rev&rev=563104
Log:
* Add a test case for PR 40348.

Modified:
    apr/apr-util/trunk/test/testreslist.c

Modified: apr/apr-util/trunk/test/testreslist.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/test/testreslist.c?view=diff&rev=563104&r1=563103&r2=563104
==============================================================================
--- apr/apr-util/trunk/test/testreslist.c (original)
+++ apr/apr-util/trunk/test/testreslist.c Mon Aug  6 03:48:32 2007
@@ -74,6 +74,7 @@
 {
     my_resource_t *res = resource;
     my_parameters_t *my_params = params;
+    res->id = my_params->d_count++;
 
     apr_sleep(my_params->sleep_upon_destruct);
 
@@ -152,6 +153,47 @@
     }
 }
 
+static void test_shrinking(abts_case *tc, apr_reslist_t *rl)
+{
+    apr_status_t rv;
+    my_resource_t *resources[RESLIST_HMAX];
+    my_resource_t *res;
+    void *vp;
+    int i;
+    int sleep_time = RESLIST_TTL / RESLIST_HMAX;
+
+    /* deplete all possible resources from the resource list */
+    for (i = 0; i < RESLIST_HMAX; i++) {
+        rv = apr_reslist_acquire(rl, (void**)&resources[i]);
+        ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
+    }
+
+    /* Free all resources above RESLIST_SMAX - 1 */
+    for (i = RESLIST_SMAX - 1; i < RESLIST_HMAX; i++) {
+        rv = apr_reslist_release(rl, resources[i]);
+        ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
+    }
+
+    for (i = 0; i < RESLIST_HMAX; i++) {
+        rv = apr_reslist_acquire(rl, &vp);
+        ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
+        res = vp;
+        apr_sleep(sleep_time);
+        rv = apr_reslist_release(rl, res);
+        ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
+    }
+    apr_sleep(sleep_time);
+
+    /*
+     * Now free the remaining elements. This should trigger the shrinking of
+     * the list
+     */
+    for (i = 0; i < RESLIST_SMAX - 1; i++) {
+        rv = apr_reslist_release(rl, resources[i]);
+        ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
+    }
+}
+
 static void test_reslist(abts_case *tc, void *data)
 {
     int i;
@@ -193,6 +235,9 @@
     ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
     test_timeout(tc, rl);
+
+    test_shrinking(tc, rl);
+    ABTS_INT_EQUAL(tc, RESLIST_SMAX, params->c_count - params->d_count);
 
     rv = apr_reslist_destroy(rl);
     ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);



Mime
View raw message