Apache HTTPD
testproc.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_thread_proc.h"
18#include "apr_errno.h"
19#include "apr_general.h"
20#include "apr_lib.h"
21#include "apr_strings.h"
22#include "testutil.h"
23
24#define TESTSTR "This is a test"
25
26#define PROC_CHILD_NAME TESTBINPATH "proc_child" EXTENSION
27
28static char *proc_child;
29
31
32static void test_create_proc(abts_case *tc, void *data)
33{
34 const char *args[2];
37 apr_status_t rv;
39 char *buf;
40
43
47
48 rv = apr_procattr_dir_set(attr, "data");
50
53
54 args[0] = "proc_child" EXTENSION;
55 args[1] = NULL;
56
58 attr, p);
60
62
63 length = strlen(TESTSTR);
66 ABTS_SIZE_EQUAL(tc, strlen(TESTSTR), length);
67
70
72 length = 256;
77}
78
79static void test_proc_wait(abts_case *tc, void *data)
80{
81 apr_status_t rv;
82
85}
86
87static void test_file_redir(abts_case *tc, void *data)
88{
92 apr_status_t rv;
93 const char *args[2];
97 char *buf;
98
99 testfile = NULL;
100 rv = apr_file_open(&testfile, "data/stdin",
104 rv = apr_file_open(&testout, "data/stdout",
108 rv = apr_file_open(&testerr, "data/stderr",
112
113 length = strlen(TESTSTR);
115 offset = 0;
118 ABTS_ASSERT(tc, "File position mismatch, expected 0", offset == 0);
119
120 rv = apr_procattr_create(&attr, p);
128 rv = apr_procattr_dir_set(attr, "data");
132
133 args[0] = "proc_child";
134 args[1] = NULL;
135
137 attr, p);
139
142
143 offset = 0;
146
147 length = 256;
152
153
157
158 rv = apr_file_remove("data/stdin", p);;
160 rv = apr_file_remove("data/stdout", p);;
162 rv = apr_file_remove("data/stderr", p);;
164}
165
167{
168 suite = ADD_SUITE(suite)
169
174
175 return suite;
176}
177
void abts_run_test(abts_suite *ts, test_func f, void *value)
Definition abts.c:175
#define ABTS_SIZE_EQUAL(a, b, c)
Definition abts.h:121
#define ADD_SUITE(suite)
Definition abts.h:67
#define ABTS_STR_EQUAL(a, b, c)
Definition abts.h:123
#define ABTS_ASSERT(a, b, c)
Definition abts.h:130
#define ABTS_INT_EQUAL(a, b, c)
Definition abts.h:109
#define EXTENSION
Definition testutil.h:43
APR Error Codes.
APR Miscellaneous library routines.
APR general purpose library routines.
APR Strings library.
APR Thread and Process Library.
const unsigned char * buf
Definition util_md5.h:50
#define APR_CHILD_DONE
Definition apr_errno.h:446
int apr_off_t * length
apr_size_t size
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
apr_seek_where_t apr_off_t * offset
void * data
#define APR_FOPEN_EXCL
Definition apr_file_io.h:63
#define APR_FOPEN_WRITE
Definition apr_file_io.h:55
#define APR_FOPEN_READ
Definition apr_file_io.h:54
#define APR_FOPEN_CREATE
Definition apr_file_io.h:56
#define APR_OS_DEFAULT
#define APR_SET
#define apr_pcalloc(p, size)
Definition apr_pools.h:465
const char const char *const const char *const apr_procattr_t * attr
#define APR_FULL_BLOCK
const char const char *const * args
#define APR_NO_PIPE
@ APR_WAIT
@ APR_PROGRAM_ENV
apr_pool_t * p
Definition md_event.c:32
return NULL
Definition mod_so.c:359
apr_file_t * in
apr_file_t * out
abts_suite * testfile(abts_suite *suite)
Definition testfile.c:2230
#define TESTSTR
Definition testproc.c:24
static void test_file_redir(abts_case *tc, void *data)
Definition testproc.c:87
static apr_proc_t newproc
Definition testproc.c:30
static void test_proc_wait(abts_case *tc, void *data)
Definition testproc.c:79
abts_suite * testproc(abts_suite *suite)
Definition testproc.c:166
#define PROC_CHILD_NAME
Definition testproc.c:26
static void test_create_proc(abts_case *tc, void *data)
Definition testproc.c:32
static char * proc_child
Definition testproc.c:28