Apache HTTPD
testmmap.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_mmap.h"
19#include "apr_errno.h"
20#include "apr_general.h"
21#include "apr_lib.h"
22#include "apr_file_io.h"
23#include "apr_strings.h"
24
25/* hmmm, what is a truly portable define for the max path
26 * length on a platform?
27 */
28#define PATH_LEN 255
29
30#if !APR_HAS_MMAP
31static void not_implemented(abts_case *tc, void *data)
32{
33 ABTS_NOT_IMPL(tc, "MMAP functions");
34}
35
36#else
37
38static char test_string[256]; /* read from the datafile */
39static apr_mmap_t *themmap = NULL;
40static apr_file_t *thefile = NULL;
41static char *file1;
44
45static void create_filename(abts_case *tc, void *data)
46{
47 char *oldfileptr;
48
50#ifndef NETWARE
51#ifdef WIN32
52 ABTS_TRUE(tc, file1[1] == ':');
53#else
54 ABTS_TRUE(tc, file1[0] == '/');
55#endif
56#endif
57 ABTS_TRUE(tc, file1[strlen(file1) - 1] != '/');
58
60 file1 = apr_pstrcat(p, file1,"/data/mmap_datafile.txt" ,NULL);
62}
63
64static void test_file_close(abts_case *tc, void *data)
65{
66 apr_status_t rv;
67
70}
71
72static void read_expected_contents(abts_case *tc, void *data)
73{
74 apr_status_t rv;
75 apr_size_t nbytes = sizeof(test_string) - 1;
76
79 test_string[nbytes] = '\0';
80 thisfsize = strlen(test_string);
81}
82
83static void test_file_open(abts_case *tc, void *data)
84{
85 apr_status_t rv;
86
90}
91
92static void test_get_filesize(abts_case *tc, void *data)
93{
94 apr_status_t rv;
95
98 ABTS_ASSERT(tc, "File size mismatch", thisfsize == thisfinfo.size);
99}
100
101static void test_mmap_create(abts_case *tc, void *data)
102{
103 apr_status_t rv;
104
109}
110
111static void test_mmap_contents(abts_case *tc, void *data)
112{
113
115 ABTS_PTR_NOTNULL(tc, themmap->mm);
117
118 /* Must use nEquals since the string is not guaranteed to be NULL terminated */
120}
121
122static void test_mmap_delete(abts_case *tc, void *data)
123{
124 apr_status_t rv;
125
129}
130
131static void test_mmap_offset(abts_case *tc, void *data)
132{
133 apr_status_t rv;
134 void *addr;
135
137 rv = apr_mmap_offset(&addr, themmap, 5);
138
140 /* Must use nEquals since the string is not guaranteed to be NULL terminated */
142}
143#endif
144
146{
147 suite = ADD_SUITE(suite)
148
149#if APR_HAS_MMAP
159#else
161#endif
162
163 return suite;
164}
165
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 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_NOT_IMPL(a, b)
Definition abts.h:129
#define ABTS_STR_NEQUAL(a, b, c, d)
Definition abts.h:124
#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 general purpose library routines.
APR MMAP routines.
APR Strings library.
apr_size_t size
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
apr_file_t * thefile
void apr_size_t * nbytes
void * data
#define APR_FOPEN_READ
Definition apr_file_io.h:54
#define APR_GREAD
#define APR_UREAD
#define APR_FINFO_NORM
apr_sockaddr_t * addr
#define APR_MMAP_READ
Definition apr_mmap.h:46
apr_pool_t * p
Definition md_event.c:32
return NULL
Definition mod_so.c:359
static void not_implemented(abts_case *tc, void *data)
Definition testmmap.c:31
abts_suite * testmmap(abts_suite *suite)
Definition testmmap.c:145