From commits-return-8519-apmail-apr-commits-archive=apr.apache.org@apr.apache.org Mon Aug 06 10:48:54 2007 Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 24792 invoked from network); 6 Aug 2007 10:48:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Aug 2007 10:48:53 -0000 Received: (qmail 46795 invoked by uid 500); 6 Aug 2007 10:48:52 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 46763 invoked by uid 500); 6 Aug 2007 10:48:52 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 46752 invoked by uid 99); 6 Aug 2007 10:48:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Aug 2007 03:48:52 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Aug 2007 10:48:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D01481A981C; Mon, 6 Aug 2007 03:48:32 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r563104 - /apr/apr-util/trunk/test/testreslist.c Date: Mon, 06 Aug 2007 10:48:32 -0000 To: commits@apr.apache.org From: rpluem@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070806104832.D01481A981C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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);