~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to srclib/apr-util/test/test_apu.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
 
2
 * applicable.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * 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
/* Some simple functions to make the test apps easier to write and
 
18
 * a bit more consistent...
 
19
 * this is a >copy< of apr_test.h
 
20
 */
 
21
 
 
22
/* Things to bear in mind when using these...
 
23
 *
 
24
 * If you include '\t' within the string passed in it won't be included
 
25
 * in the spacing, so use spaces instead :)
 
26
 * 
 
27
 */ 
 
28
 
 
29
#ifndef APU_TEST_INCLUDES
 
30
#define APU_TEST_INCLUDES
 
31
 
 
32
#include "apr_strings.h"
 
33
#include "apr_time.h"
 
34
 
 
35
#define TEST_EQ(str, func, value, good, bad) \
 
36
    printf("%-60s", str); \
 
37
    { \
 
38
    apr_status_t rv; \
 
39
    if ((rv = func) == value){ \
 
40
        char errmsg[200]; \
 
41
        printf("%s\n", bad); \
 
42
        fprintf(stderr, "Error was %d : %s\n", rv, \
 
43
                apr_strerror(rv, (char*)&errmsg, 200)); \
 
44
        exit(-1); \
 
45
    } \
 
46
    printf("%s\n", good); \
 
47
    }
 
48
 
 
49
#define TEST_NEQ(str, func, value, good, bad) \
 
50
    printf("%-60s", str); \
 
51
    { \
 
52
    apr_status_t rv; \
 
53
    if ((rv = func) != value){ \
 
54
        char errmsg[200]; \
 
55
        printf("%s\n", bad); \
 
56
        fprintf(stderr, "Error was %d : %s\n", rv, \
 
57
                apr_strerror(rv, (char*)&errmsg, 200)); \
 
58
        exit(-1); \
 
59
    } \
 
60
    printf("%s\n", good); \
 
61
    }
 
62
 
 
63
#define TEST_STATUS(str, func, testmacro, good, bad) \
 
64
    printf("%-60s", str); \
 
65
    { \
 
66
        apr_status_t rv = func; \
 
67
        if (!testmacro(rv)) { \
 
68
            char errmsg[200]; \
 
69
            printf("%s\n", bad); \
 
70
            fprintf(stderr, "Error was %d : %s\n", rv, \
 
71
                    apr_strerror(rv, (char*)&errmsg, 200)); \
 
72
            exit(-1); \
 
73
        } \
 
74
        printf("%s\n", good); \
 
75
    }
 
76
 
 
77
#define STD_TEST_NEQ(str, func) \
 
78
        TEST_NEQ(str, func, APR_SUCCESS, "OK", "Failed");
 
79
 
 
80
#define PRINT_ERROR(rv) \
 
81
    { \
 
82
        char errmsg[200]; \
 
83
        fprintf(stderr, "Error was %d : %s\n", rv, \
 
84
                apr_strerror(rv, (char*)&errmsg, 200)); \
 
85
        exit(-1); \
 
86
    }
 
87
 
 
88
#define MSG_AND_EXIT(msg) \
 
89
    printf("%s\n", msg); \
 
90
    exit (-1);
 
91
 
 
92
#define TIME_FUNCTION(time, function) \
 
93
    { \
 
94
        apr_time_t tt = apr_time_now(); \
 
95
        function; \
 
96
        time = apr_time_now() - tt; \
 
97
    }
 
98
    
 
99
    
 
100
#endif /* APU_TEST_INCLUDES */