Blame test/test_apu.h

Packit 383869
/* Licensed to the Apache Software Foundation (ASF) under one or more
Packit 383869
 * contributor license agreements.  See the NOTICE file distributed with
Packit 383869
 * this work for additional information regarding copyright ownership.
Packit 383869
 * The ASF licenses this file to You under the Apache License, Version 2.0
Packit 383869
 * (the "License"); you may not use this file except in compliance with
Packit 383869
 * the License.  You may obtain a copy of the License at
Packit 383869
 *
Packit 383869
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 383869
 *
Packit 383869
 * Unless required by applicable law or agreed to in writing, software
Packit 383869
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 383869
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 383869
 * See the License for the specific language governing permissions and
Packit 383869
 * limitations under the License.
Packit 383869
 */
Packit 383869
Packit 383869
/* Some simple functions to make the test apps easier to write and
Packit 383869
 * a bit more consistent...
Packit 383869
 * this is a >copy< of apr_test.h
Packit 383869
 */
Packit 383869
Packit 383869
/* Things to bear in mind when using these...
Packit 383869
 *
Packit 383869
 * If you include '\t' within the string passed in it won't be included
Packit 383869
 * in the spacing, so use spaces instead :)
Packit 383869
 * 
Packit 383869
 */ 
Packit 383869
Packit 383869
#ifndef APU_TEST_INCLUDES
Packit 383869
#define APU_TEST_INCLUDES
Packit 383869
Packit 383869
#include "apr_strings.h"
Packit 383869
#include "apr_time.h"
Packit 383869
Packit 383869
#define TEST_EQ(str, func, value, good, bad) \
Packit 383869
    printf("%-60s", str); \
Packit 383869
    { \
Packit 383869
    apr_status_t rv; \
Packit 383869
    if ((rv = func) == value){ \
Packit 383869
        char errmsg[200]; \
Packit 383869
        printf("%s\n", bad); \
Packit 383869
        fprintf(stderr, "Error was %d : %s\n", rv, \
Packit 383869
                apr_strerror(rv, (char*)&errmsg, 200)); \
Packit 383869
        exit(-1); \
Packit 383869
    } \
Packit 383869
    printf("%s\n", good); \
Packit 383869
    }
Packit 383869
Packit 383869
#define TEST_NEQ(str, func, value, good, bad) \
Packit 383869
    printf("%-60s", str); \
Packit 383869
    { \
Packit 383869
    apr_status_t rv; \
Packit 383869
    if ((rv = func) != value){ \
Packit 383869
        char errmsg[200]; \
Packit 383869
        printf("%s\n", bad); \
Packit 383869
        fprintf(stderr, "Error was %d : %s\n", rv, \
Packit 383869
                apr_strerror(rv, (char*)&errmsg, 200)); \
Packit 383869
        exit(-1); \
Packit 383869
    } \
Packit 383869
    printf("%s\n", good); \
Packit 383869
    }
Packit 383869
Packit 383869
#define TEST_STATUS(str, func, testmacro, good, bad) \
Packit 383869
    printf("%-60s", str); \
Packit 383869
    { \
Packit 383869
        apr_status_t rv = func; \
Packit 383869
        if (!testmacro(rv)) { \
Packit 383869
            char errmsg[200]; \
Packit 383869
            printf("%s\n", bad); \
Packit 383869
            fprintf(stderr, "Error was %d : %s\n", rv, \
Packit 383869
                    apr_strerror(rv, (char*)&errmsg, 200)); \
Packit 383869
            exit(-1); \
Packit 383869
        } \
Packit 383869
        printf("%s\n", good); \
Packit 383869
    }
Packit 383869
Packit 383869
#define STD_TEST_NEQ(str, func) \
Packit 383869
	TEST_NEQ(str, func, APR_SUCCESS, "OK", "Failed");
Packit 383869
Packit 383869
#define PRINT_ERROR(rv) \
Packit 383869
    { \
Packit 383869
        char errmsg[200]; \
Packit 383869
        fprintf(stderr, "Error was %d : %s\n", rv, \
Packit 383869
                apr_strerror(rv, (char*)&errmsg, 200)); \
Packit 383869
        exit(-1); \
Packit 383869
    }
Packit 383869
Packit 383869
#define MSG_AND_EXIT(msg) \
Packit 383869
    printf("%s\n", msg); \
Packit 383869
    exit (-1);
Packit 383869
Packit 383869
#define TIME_FUNCTION(time, function) \
Packit 383869
    { \
Packit 383869
        apr_time_t tt = apr_time_now(); \
Packit 383869
        function; \
Packit 383869
        time = apr_time_now() - tt; \
Packit 383869
    }
Packit 383869
    
Packit 383869
    
Packit 383869
#endif /* APU_TEST_INCLUDES */