Apache HTTPD
testoc.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 "testutil.h"
18#include "apr_thread_proc.h"
19#include "apr_errno.h"
20#include "apr_general.h"
21#include "apr_lib.h"
22#include "apr_strings.h"
23
24#if APR_HAS_OTHER_CHILD
25
26static char reasonstr[256];
27
28static void ocmaint(int reason, void *data, int status)
29{
30 switch (reason) {
32 apr_cpystrn(reasonstr, "APR_OC_REASON_DEATH",
33 strlen("APR_OC_REASON_DEATH") + 1);
34 break;
36 apr_cpystrn(reasonstr, "APR_OC_REASON_LOST",
37 strlen("APR_OC_REASON_LOST") + 1);
38 break;
40 apr_cpystrn(reasonstr, "APR_OC_REASON_UNWRITEABLE",
41 strlen("APR_OC_REASON_UNWRITEABLE") + 1);
42 break;
44 apr_cpystrn(reasonstr, "APR_OC_REASON_RESTART",
45 strlen("APR_OC_REASON_RESTART") + 1);
46 break;
47 }
48}
49
50#ifndef SIGKILL
51#define SIGKILL 1
52#endif
53
54/* It would be great if we could stress this stuff more, and make the test
55 * more granular.
56 */
57static void test_child_kill(abts_case *tc, void *data)
58{
61 apr_procattr_t *procattr = NULL;
62 const char *args[3];
63 apr_status_t rv;
64
65 args[0] = apr_pstrdup(p, "occhild" EXTENSION);
66 args[1] = apr_pstrdup(p, "-X");
67 args[2] = NULL;
68
69 rv = apr_procattr_create(&procattr, p);
71
75
77 APR_ASSERT_SUCCESS(tc, "Couldn't set copy environment", rv);
78
79 rv = apr_proc_create(&newproc, TESTBINPATH "occhild" EXTENSION, args, NULL, procattr, p);
84
85 std = newproc.in;
86
88
92
93 /* allow time for things to settle... */
95
97 ABTS_STR_EQUAL(tc, "APR_OC_REASON_DEATH", reasonstr);
98}
99#else
100
101static void oc_not_impl(abts_case *tc, void *data)
102{
103 ABTS_NOT_IMPL(tc, "Other child logic not implemented on this platform");
104}
105#endif
106
108{
109 suite = ADD_SUITE(suite)
110
111#if !APR_HAS_OTHER_CHILD
113#else
114
116
117#endif
118 return suite;
119}
120
void abts_run_test(abts_suite *ts, test_func f, void *value)
Definition abts.c:175
#define ABTS_PTR_EQUAL(a, b, c)
Definition abts.h:126
#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_STR_EQUAL(a, b, c)
Definition abts.h:123
#define ABTS_INT_EQUAL(a, b, c)
Definition abts.h:109
#define EXTENSION
Definition testutil.h:43
#define TESTBINPATH
Definition testutil.h:35
#define APR_ASSERT_SUCCESS(tc, ctxt, rv)
Definition testutil.h:58
APR Error Codes.
APR Miscellaneous library routines.
APR general purpose library routines.
APR Strings library.
APR Thread and Process Library.
#define APR_OC_REASON_RESTART
#define APR_OC_REASON_LOST
#define APR_OC_REASON_DEATH
#define APR_OC_REASON_RUNNING
#define APR_OC_REASON_UNWRITABLE
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_FULL_BLOCK
const char const char *const * args
#define APR_NO_PIPE
int reason
int int status
@ APR_PROGRAM_ENV
#define apr_time_from_sec(sec)
Definition apr_time.h:78
apr_pool_t * p
Definition md_event.c:32
return NULL
Definition mod_so.c:359
apr_file_t * in
apr_file_t * out
apr_file_t * err
abts_suite * testoc(abts_suite *suite)
Definition testoc.c:107
static void oc_not_impl(abts_case *tc, void *data)
Definition testoc.c:101
static apr_proc_t newproc
Definition testproc.c:30