Fix memory leak when maintaining resources. When extra resources are
[apr-util.git] / test / test_apu.h
blob40d39dc9fa20c5eddc6c4ea14929cad279ee60f9
1 /* Copyright 2000-2004 The Apache Software Foundation
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.
16 /* Some simple functions to make the test apps easier to write and
17 * a bit more consistent...
18 * this is a >copy< of apr_test.h
21 /* Things to bear in mind when using these...
23 * If you include '\t' within the string passed in it won't be included
24 * in the spacing, so use spaces instead :)
26 */
28 #ifndef APU_TEST_INCLUDES
29 #define APU_TEST_INCLUDES
31 #include "apr_strings.h"
32 #include "apr_time.h"
34 #define TEST_EQ(str, func, value, good, bad) \
35 printf("%-60s", str); \
36 { \
37 apr_status_t rv; \
38 if ((rv = func) == value){ \
39 char errmsg[200]; \
40 printf("%s\n", bad); \
41 fprintf(stderr, "Error was %d : %s\n", rv, \
42 apr_strerror(rv, (char*)&errmsg, 200)); \
43 exit(-1); \
44 } \
45 printf("%s\n", good); \
48 #define TEST_NEQ(str, func, value, good, bad) \
49 printf("%-60s", str); \
50 { \
51 apr_status_t rv; \
52 if ((rv = func) != value){ \
53 char errmsg[200]; \
54 printf("%s\n", bad); \
55 fprintf(stderr, "Error was %d : %s\n", rv, \
56 apr_strerror(rv, (char*)&errmsg, 200)); \
57 exit(-1); \
58 } \
59 printf("%s\n", good); \
62 #define TEST_STATUS(str, func, testmacro, good, bad) \
63 printf("%-60s", str); \
64 { \
65 apr_status_t rv = func; \
66 if (!testmacro(rv)) { \
67 char errmsg[200]; \
68 printf("%s\n", bad); \
69 fprintf(stderr, "Error was %d : %s\n", rv, \
70 apr_strerror(rv, (char*)&errmsg, 200)); \
71 exit(-1); \
72 } \
73 printf("%s\n", good); \
76 #define STD_TEST_NEQ(str, func) \
77 TEST_NEQ(str, func, APR_SUCCESS, "OK", "Failed");
79 #define PRINT_ERROR(rv) \
80 { \
81 char errmsg[200]; \
82 fprintf(stderr, "Error was %d : %s\n", rv, \
83 apr_strerror(rv, (char*)&errmsg, 200)); \
84 exit(-1); \
87 #define MSG_AND_EXIT(msg) \
88 printf("%s\n", msg); \
89 exit (-1);
91 #define TIME_FUNCTION(time, function) \
92 { \
93 apr_time_t tt = apr_time_now(); \
94 function; \
95 time = apr_time_now() - tt; \
99 #endif /* APU_TEST_INCLUDES */