1
/* Copyright 2002-2007 Justin Erenkrantz and Greg Stein
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at
7
* http://www.apache.org/licenses/LICENSE-2.0
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
22
#include <apr_pools.h>
27
/** These macros are provided by APR itself from version 1.3.
28
* Definitions are provided here for when using older versions of APR.
31
/** index into an apr_array_header_t */
33
#define APR_ARRAY_IDX(ary,i,type) (((type *)(ary)->elts)[i])
36
/** easier array-pushing syntax */
37
#ifndef APR_ARRAY_PUSH
38
#define APR_ARRAY_PUSH(ary,type) (*((type *)apr_array_push(ary)))
41
extern apr_pool_t *test_pool;
43
/* CuTest declarations */
44
CuSuite *getsuite(void);
46
CuSuite *test_context(void);
47
CuSuite *test_buckets(void);
48
CuSuite *test_ssl(void);
50
/* Test setup declarations */
54
#define CHUNCKED_REQUEST(len, body)\
55
"GET / HTTP/1.1" CRLF\
56
"Transfer-Encoding: chunked" CRLF\
63
#define CHUNKED_RESPONSE(len, body)\
64
"HTTP/1.1 200 OK" CRLF\
65
"Transfer-Encoding: chunked" CRLF\
72
#define CHUNKED_EMPTY_RESPONSE\
73
"HTTP/1.1 200 OK" CRLF\
74
"Transfer-Encoding: chunked" CRLF\
84
SERVER_KILL_CONNECTION
88
} test_server_action_t;
91
/* Pool for resource allocation. */
94
serf_context_t *context;
95
serf_connection_t *connection;
96
serf_bucket_alloc_t *bkt_alloc;
99
/* Array of actions which server will replay when client connected. */
100
test_server_action_t *action_list;
101
/* Size of action_list array. */
102
apr_size_t action_count;
103
/* Index of current action. */
104
apr_size_t cur_action;
106
/* Position in action buffer. */
107
apr_size_t action_buf_pos;
109
/* Address for server binding. */
110
apr_sockaddr_t *serv_addr;
111
apr_socket_t *serv_sock;
113
/* Accepted client socket. NULL if there is no client socket. */
114
apr_socket_t *client_sock;
116
/* An extra baton which can be freely used by tests. */
121
#define TEST_SERVER_DUMP 1
123
/* Default port for our test server. */
124
#define SERV_PORT 12345
125
#define SERV_PORT_STR "12345"
127
apr_status_t test_server_create(test_baton_t **tb,
128
test_server_action_t *action_list,
129
apr_size_t action_count,
131
const char *host_url,
132
apr_sockaddr_t *address,
133
serf_connection_setup_t conn_setup,
136
apr_status_t test_server_run(test_baton_t *tb,
137
apr_short_interval_time_t duration,
140
apr_status_t test_server_destroy(test_baton_t *tb, apr_pool_t *pool);
142
#ifndef APR_VERSION_AT_LEAST /* Introduced in APR 1.3.0 */
143
#define APR_VERSION_AT_LEAST(major,minor,patch) \
144
(((major) < APR_MAJOR_VERSION) \
145
|| ((major) == APR_MAJOR_VERSION && (minor) < APR_MINOR_VERSION) \
146
|| ((major) == APR_MAJOR_VERSION && (minor) == APR_MINOR_VERSION && \
147
(patch) <= APR_PATCH_VERSION))
148
#endif /* APR_VERSION_AT_LEAST */
150
#endif /* TEST_SERF_H */