~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to srclib/apr/test/testud.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
 
2
 * applicable.
 
3
 *
 
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
 
7
 *
 
8
 *     http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
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.
 
15
 */
 
16
 
 
17
#include <stdio.h>
 
18
#include <stdlib.h>
 
19
#include "apr_file_io.h"
 
20
#include "apr_errno.h"
 
21
#include "apr_general.h"
 
22
#include "apr_lib.h"
 
23
#include "apr_strings.h"
 
24
#include "testutil.h"
 
25
 
 
26
static apr_pool_t *pool;
 
27
static char *testdata;
 
28
static int cleanup_called = 0;
 
29
 
 
30
static apr_status_t string_cleanup(void *data)
 
31
{
 
32
    cleanup_called = 1;
 
33
    return APR_SUCCESS;
 
34
}
 
35
 
 
36
static void set_userdata(abts_case *tc, void *data)
 
37
{
 
38
    apr_status_t rv;
 
39
 
 
40
    rv = apr_pool_userdata_set(testdata, "TEST", string_cleanup, pool);
 
41
    ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
42
}
 
43
 
 
44
static void get_userdata(abts_case *tc, void *data)
 
45
{
 
46
    apr_status_t rv;
 
47
    void *retdata;
 
48
 
 
49
    rv = apr_pool_userdata_get(&retdata, "TEST", pool);
 
50
    ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
51
    ABTS_STR_EQUAL(tc, retdata, testdata);
 
52
}
 
53
 
 
54
static void get_nonexistkey(abts_case *tc, void *data)
 
55
{
 
56
    apr_status_t rv;
 
57
    void *retdata;
 
58
 
 
59
    rv = apr_pool_userdata_get(&retdata, "DOESNTEXIST", pool);
 
60
    ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
61
    ABTS_PTR_EQUAL(tc, retdata, NULL);
 
62
}
 
63
 
 
64
static void post_pool_clear(abts_case *tc, void *data)
 
65
{
 
66
    apr_status_t rv;
 
67
    void *retdata;
 
68
 
 
69
    rv = apr_pool_userdata_get(&retdata, "DOESNTEXIST", pool);
 
70
    ABTS_INT_EQUAL(tc, rv, APR_SUCCESS);
 
71
    ABTS_PTR_EQUAL(tc, retdata, NULL);
 
72
}
 
73
 
 
74
abts_suite *testud(abts_suite *suite)
 
75
{
 
76
    suite = ADD_SUITE(suite)
 
77
 
 
78
    apr_pool_create(&pool, p);
 
79
    testdata = apr_pstrdup(pool, "This is a test\n");
 
80
 
 
81
    abts_run_test(suite, set_userdata, NULL);
 
82
    abts_run_test(suite, get_userdata, NULL);
 
83
    abts_run_test(suite, get_nonexistkey, NULL);
 
84
 
 
85
    apr_pool_clear(pool);
 
86
 
 
87
    abts_run_test(suite, post_pool_clear, NULL);
 
88
 
 
89
    return suite;
 
90
}
 
91