1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
19
#include "apr_file_io.h"
20
#include "apr_errno.h"
21
#include "apr_general.h"
23
#include "apr_strings.h"
26
static apr_pool_t *pool;
27
static char *testdata;
28
static int cleanup_called = 0;
30
static apr_status_t string_cleanup(void *data)
36
static void set_userdata(abts_case *tc, void *data)
40
rv = apr_pool_userdata_set(testdata, "TEST", string_cleanup, pool);
41
ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
44
static void get_userdata(abts_case *tc, void *data)
49
rv = apr_pool_userdata_get(&retdata, "TEST", pool);
50
ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
51
ABTS_STR_EQUAL(tc, retdata, testdata);
54
static void get_nonexistkey(abts_case *tc, void *data)
59
rv = apr_pool_userdata_get(&retdata, "DOESNTEXIST", pool);
60
ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
61
ABTS_PTR_EQUAL(tc, retdata, NULL);
64
static void post_pool_clear(abts_case *tc, void *data)
69
rv = apr_pool_userdata_get(&retdata, "DOESNTEXIST", pool);
70
ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
71
ABTS_PTR_EQUAL(tc, retdata, NULL);
74
abts_suite *testud(abts_suite *suite)
76
suite = ADD_SUITE(suite)
78
apr_pool_create(&pool, p);
79
testdata = apr_pstrdup(pool, "This is a test\n");
81
abts_run_test(suite, set_userdata, NULL);
82
abts_run_test(suite, get_userdata, NULL);
83
abts_run_test(suite, get_nonexistkey, NULL);
87
abts_run_test(suite, post_pool_clear, NULL);