diff options
author | Yann Ylavic <ylavic@apache.org> | 2018-06-21 14:26:56 +0000 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2018-06-21 14:26:56 +0000 |
commit | 2c337e88b22cefb707b9502c08d33bb0c1e9bb4b (patch) | |
tree | ed92ad8dced4b2ebac411ee7b2ad02acfd5a2c09 /test | |
parent | baff3b9f942b5d179992e5801d16fd1e2d1f8131 (diff) | |
download | apr-2c337e88b22cefb707b9502c08d33bb0c1e9bb4b.tar.gz |
apr_reslist: test for ttl = 0
The current reslist implementation handles ttl=0 as no TTL when acquiring
resources (expected and documented), but as zero TTL when releasing (immediate
expiry, so resources above smax are never recycled).
This test validates the upcoming fix (r1834023).
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1834022 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r-- | test/testreslist.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/testreslist.c b/test/testreslist.c index 36333a153..78c908d2b 100644 --- a/test/testreslist.c +++ b/test/testreslist.c @@ -258,6 +258,44 @@ static void test_reslist(abts_case *tc, void *data) ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } +static void test_reslist_no_ttl(abts_case *tc, void *data) +{ + apr_status_t rv; + apr_reslist_t *rl; + my_parameters_t *params; + my_resource_t *res; + + /* Parameters (sleep not used) */ + params = apr_pcalloc(p, sizeof(*params)); + + rv = apr_reslist_create(&rl, + /*no min*/0, /*no smax*/0, /*max*/1, /*no ttl*/0, + my_constructor, my_destructor, params, p); + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + + /* Acquire/contruct one resource */ + rv = apr_reslist_acquire(rl, (void **)&res); + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + ABTS_INT_EQUAL(tc, 0, res->id); + + /* Release it before next check */ + rv = apr_reslist_release(rl, res); + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + + /* Re-acquire/release: the resource should be the same */ + rv = apr_reslist_acquire(rl, (void **)&res); + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + ABTS_INT_EQUAL(tc, 0, res->id); + + /* Release it before cleanup */ + rv = apr_reslist_release(rl, res); + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + + rv = apr_reslist_destroy(rl); + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + ABTS_INT_EQUAL(tc, params->d_count, 1); +} + #endif /* APR_HAS_THREADS */ abts_suite *testreslist(abts_suite *suite) @@ -266,6 +304,7 @@ abts_suite *testreslist(abts_suite *suite) #if APR_HAS_THREADS abts_run_test(suite, test_reslist, NULL); + abts_run_test(suite, test_reslist_no_ttl, NULL); #endif return suite; |