Apache HTTPD
testpools.c
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. 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
18#include "apr_general.h"
19#include "apr_pools.h"
20#include "apr_errno.h"
21#include "apr_file_io.h"
22#include <string.h>
23#include <stdlib.h>
24#include <stdio.h>
25#if APR_HAVE_UNISTD_H
26#include <unistd.h>
27#endif
28#include "testutil.h"
29
30#define ALLOC_BYTES 1024
31
34
35static void alloc_bytes(abts_case *tc, void *data)
36{
37 int i;
38 char *alloc;
39
41 ABTS_PTR_NOTNULL(tc, alloc);
42
43 for (i=0;i<ALLOC_BYTES;i++) {
44 char *ptr = alloc + i;
45 *ptr = 0xa;
46 }
47 /* This is just added to get the positive. If this test fails, the
48 * suite will seg fault.
49 */
50 ABTS_TRUE(tc, 1);
51}
52
53static void calloc_bytes(abts_case *tc, void *data)
54{
55 int i;
56 char *alloc;
57
59 ABTS_PTR_NOTNULL(tc, alloc);
60
61 for (i=0;i<ALLOC_BYTES;i++) {
62 char *ptr = alloc + i;
63 ABTS_TRUE(tc, *ptr == '\0');
64 }
65}
66
67static void parent_pool(abts_case *tc, void *data)
68{
69 apr_status_t rv;
70
74}
75
76static void child_pool(abts_case *tc, void *data)
77{
78 apr_status_t rv;
79
83}
84
85static void test_ancestor(abts_case *tc, void *data)
86{
88}
89
90static void test_notancestor(abts_case *tc, void *data)
91{
93}
94
96{
97 return APR_SUCCESS;
98}
99
100static char *checker_data = "Hello, world.";
101
103{
105}
106
107static void test_cleanups(abts_case *tc, void *data)
108{
109 apr_status_t rv;
110 int n;
111
112 /* do this several times to test the cleanup freelist handling. */
113 for (n = 0; n < 5; n++) {
120
122 ABTS_ASSERT(tc, "nullop cleanup run OK", rv == APR_SUCCESS);
124 ABTS_ASSERT(tc, "cleanup passed correct data", rv == APR_SUCCESS);
126 ABTS_ASSERT(tc, "cleanup passed correct data", rv == APR_EGENERAL);
127
128 if (n == 2) {
129 /* clear the pool to check that works */
131 }
132
133 if (n % 2 == 0) {
134 /* throw another random cleanup into the mix */
138 }
139 }
140}
141
143{
144 suite = ADD_SUITE(suite)
145
153
154 return suite;
155}
156
int n
Definition ap_regex.h:278
void abts_run_test(abts_suite *ts, test_func f, void *value)
Definition abts.c:175
#define ABTS_TRUE(a, b)
Definition abts.h:127
#define ADD_SUITE(suite)
Definition abts.h:67
#define ABTS_PTR_NOTNULL(a, b)
Definition abts.h:125
#define ABTS_ASSERT(a, b, c)
Definition abts.h:130
#define ABTS_INT_EQUAL(a, b, c)
Definition abts.h:109
APR Error Codes.
APR File I/O Handling.
APR Miscellaneous library routines.
APR memory allocation.
#define APR_EGENERAL
Definition apr_errno.h:313
apr_size_t size
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
void * data
#define apr_pool_create(newpool, parent)
Definition apr_pools.h:322
#define apr_pcalloc(p, size)
Definition apr_pools.h:465
apr_pool_t * p
Definition md_event.c:32
return NULL
Definition mod_so.c:359
int i
Definition mod_so.c:347
static void parent_pool(abts_case *tc, void *data)
Definition testpools.c:67
static apr_pool_t * pchild
Definition testpools.c:33
static apr_pool_t * pmain
Definition testpools.c:32
static char * checker_data
Definition testpools.c:100
static apr_status_t checker_cleanup(void *data)
Definition testpools.c:102
static void test_notancestor(abts_case *tc, void *data)
Definition testpools.c:90
static void test_ancestor(abts_case *tc, void *data)
Definition testpools.c:85
static void alloc_bytes(abts_case *tc, void *data)
Definition testpools.c:35
static void child_pool(abts_case *tc, void *data)
Definition testpools.c:76
static void calloc_bytes(abts_case *tc, void *data)
Definition testpools.c:53
#define ALLOC_BYTES
Definition testpools.c:30
static apr_status_t success_cleanup(void *data)
Definition testpools.c:95
static void test_cleanups(abts_case *tc, void *data)
Definition testpools.c:107
abts_suite * testpool(abts_suite *suite)
Definition testpools.c:142