Apache HTTPD
testsockopt.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#include "apr_network_io.h"
18#include "apr_errno.h"
19#include "apr_general.h"
20#include "apr_lib.h"
21#include "testutil.h"
22
24
25static void create_socket(abts_case *tc, void *data)
26{
27 apr_status_t rv;
28
32}
33
34static void set_keepalive(abts_case *tc, void *data)
35{
36 apr_status_t rv;
38
41
44 ABTS_INT_EQUAL(tc, 1, ck);
45}
46
47static void set_debug(abts_case *tc, void *data)
48{
51
52 /* On some platforms APR_SO_DEBUG can only be set as root; just test
53 * for get/set consistency of this option. */
56 APR_ASSERT_SUCCESS(tc, "get SO_DEBUG option", rv2);
57 if (rv1 == APR_SUCCESS) {
58 ABTS_INT_EQUAL(tc, 1, ck);
59 } else {
60 ABTS_INT_EQUAL(tc, 0, ck);
61 }
62}
63
80
81static void corkable(abts_case *tc, void *data)
82{
83#if !APR_HAVE_CORKABLE_TCP
84 ABTS_NOT_IMPL(tc, "TCP isn't corkable");
85#else
86 apr_status_t rv;
88
91
94 ABTS_INT_EQUAL(tc, 1, ck);
95
98
101 ABTS_INT_EQUAL(tc, 1, ck);
102
105 /* TCP_NODELAY is now in an unknown state; it may be zero if
106 * TCP_NOPUSH and TCP_NODELAY are mutually exclusive on this
107 * platform, e.g. Linux < 2.6. */
108
111
114 ABTS_INT_EQUAL(tc, 1, ck);
115#endif
116}
117
118static void close_socket(abts_case *tc, void *data)
119{
120 apr_status_t rv;
121
124}
125
127{
128 suite = ADD_SUITE(suite)
129
134 abts_run_test(suite, corkable, NULL);
136
137 return suite;
138}
139
void abts_run_test(abts_suite *ts, test_func f, void *value)
Definition abts.c:175
#define ADD_SUITE(suite)
Definition abts.h:67
#define ABTS_PTR_NOTNULL(a, b)
Definition abts.h:125
#define ABTS_NOT_IMPL(a, b)
Definition abts.h:129
#define ABTS_INT_EQUAL(a, b, c)
Definition abts.h:109
#define APR_ASSERT_SUCCESS(tc, ctxt, rv)
Definition testutil.h:58
APR Error Codes.
APR Miscellaneous library routines.
APR general purpose library routines.
APR Network library.
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_INET
#define APR_SO_KEEPALIVE
#define APR_TCP_NODELAY
#define APR_SO_DEBUG
#define APR_TCP_NOPUSH
apr_pool_t * p
Definition md_event.c:32
return NULL
Definition mod_so.c:359
abts_suite * testsockopt(abts_suite *suite)
static void close_socket(abts_case *tc, void *data)
static void corkable(abts_case *tc, void *data)
Definition testsockopt.c:81
static apr_socket_t * sock
Definition testsockopt.c:23
static void set_debug(abts_case *tc, void *data)
Definition testsockopt.c:47
static void set_keepalive(abts_case *tc, void *data)
Definition testsockopt.c:34
static void remove_keepalive(abts_case *tc, void *data)
Definition testsockopt.c:64
static void create_socket(abts_case *tc, void *data)
Definition testsockopt.c:25
apr_status_t apr_socket_close(apr_socket_t *thesocket)
Definition sockets.c:211
apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type, int protocol, apr_pool_t *cont)
Definition sockets.c:116
apr_status_t apr_socket_opt_set(apr_socket_t *sock, apr_int32_t opt, apr_int32_t on)
Definition sockopt.c:113
apr_status_t apr_socket_opt_get(apr_socket_t *sock, apr_int32_t opt, apr_int32_t *on)
Definition sockopt.c:362