src/test/test.c
author Tero Marttila <terom@fixme.fi>
Mon, 04 May 2009 20:55:04 +0300
branchnew-transport
changeset 168 a58ad50911fc
parent 167 src/test.c@0d2d8ca879d8
child 188 6fd4706a4180
permissions -rw-r--r--
refactor test.c into tests/*
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
     1
#include "test.h"
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
     3
#include "../sock.h"
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
     4
73
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
     5
#include <getopt.h>
50
46c3983638d3 add dump_str function to test
Tero Marttila <terom@fixme.fi>
parents: 49
diff changeset
     6
46c3983638d3 add dump_str function to test
Tero Marttila <terom@fixme.fi>
parents: 49
diff changeset
     7
/**
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
     8
 * The global state
50
46c3983638d3 add dump_str function to test
Tero Marttila <terom@fixme.fi>
parents: 49
diff changeset
     9
 */
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    10
struct test_ctx _test_ctx;
43
42f5dc680930 improve irc_conn test
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    11
52
97604efda1ce add test_sock_push, and filter argument to test main()
Tero Marttila <terom@fixme.fi>
parents: 51
diff changeset
    12
/**
90
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    13
 * Setup the global sock_stream state
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    14
 */
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    15
static struct event_base* setup_sock (void)
90
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    16
{
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    17
    struct event_base *ev_base;
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    18
    struct error_info err;
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    19
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    20
    assert((ev_base = event_base_new()));
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    21
    assert_success(sock_init(ev_base, &err));
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    22
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    23
    return ev_base;
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    24
}
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    25
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    26
/**
73
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    27
 * Command-line option codes
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    28
 */
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    29
enum option_code {
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    30
    OPT_HELP            = 'h',
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    31
    OPT_DEBUG           = 'd',
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    32
    OPT_QUIET           = 'q',
90
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    33
    OPT_LIST            = 'l',
73
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    34
    
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    35
    /** Options without short names */
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    36
    _OPT_EXT_BEGIN      = 0x00ff,
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    37
};
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    38
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    39
/**
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    40
 * Command-line option definitions
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    41
 */
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    42
static struct option options[] = {
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    43
    {"help",            0,  NULL,   OPT_HELP        },
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    44
    {"debug",           0,  NULL,   OPT_DEBUG       },
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    45
    {"quiet",           0,  NULL,   OPT_QUIET       },
90
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    46
    {"list",            0,  NULL,   OPT_LIST        },
73
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    47
    {0,                 0,  0,      0               },
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    48
};
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    49
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    50
/**
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    51
 * Display --help output on stdout
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    52
 */
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    53
static void usage (const char *exe) 
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    54
{
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    55
    printf("Usage: %s [OPTIONS]\n", exe);
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    56
    printf("\n");
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    57
    printf(" --help / -h            display this message\n");
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    58
    printf(" --debug / -d           display DEBUG log messages\n");
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    59
    printf(" --quiet / -q           supress INFO log messages\n");
90
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    60
    printf(" --list / -l            list all tests\n");
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    61
}
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    62
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    63
/**
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    64
 * Output the given list of tests on stdout
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    65
 */
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    66
static void list_tests (const struct test *tests)
90
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    67
{
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    68
    const struct test *test;
90
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    69
    
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    70
    printf("Available tests:\n");
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    71
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    72
    for (test = tests; test->name; test++) {
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    73
        printf("\t%s\n", test->name);
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
    74
    }
73
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    75
}
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
    76
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    77
/**
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    78
 * Run the given NULL-terminated list of tests, optionally filtering against the given filter.
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    79
 *
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    80
 * Returns the number of tests run, which may be zero.
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    81
 */
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    82
static size_t run_tests (const struct test tests[], const char *filter)
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    83
{
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    84
    size_t test_count = 0;
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    85
    const struct test *test;
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    86
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    87
    // run each test in turn
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    88
    for (test = tests; test->name; test++) {
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    89
        // filter out if given
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    90
        if ((filter && strcmp(test->name, filter)) || (!filter && test->optional))
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    91
            continue;
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    92
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    93
        log_info("Running test: %s", test->name);
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    94
        
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    95
        // count and run
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    96
        test_count++;
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    97
        test->func();
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    98
    }
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    99
    
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   100
    return test_count;
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   101
}
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   102
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   103
int main (int argc, char **argv)
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   104
{
73
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   105
    int opt, option_index;
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   106
    const char *filter = NULL;
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   107
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   108
    size_t test_count;
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   109
73
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   110
    // parse options
90
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   111
    while ((opt = getopt_long(argc, argv, "hdql", options, &option_index)) != -1) {
73
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   112
        switch (opt) {
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   113
            case OPT_HELP:
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   114
                usage(argv[0]);
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   115
                exit(EXIT_SUCCESS);
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   116
            
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   117
            case OPT_DEBUG:
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   118
                set_log_level(LOG_DEBUG);
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   119
                break;
52
97604efda1ce add test_sock_push, and filter argument to test main()
Tero Marttila <terom@fixme.fi>
parents: 51
diff changeset
   120
73
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   121
            case OPT_QUIET:
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   122
                set_log_level(LOG_WARN);
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   123
                break;
90
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   124
           
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   125
            case OPT_LIST:
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   126
                list_tests(_tests);
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   127
                exit(EXIT_SUCCESS);
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   128
73
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   129
            case '?':
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   130
                usage(argv[0]);
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   131
                exit(EXIT_FAILURE);
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   132
        }
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   133
    }
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   134
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   135
    // parse positional arguments
73
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   136
    if (optind < argc) {
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   137
        if (optind == argc - 1) {
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   138
            // filter
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   139
            filter = argv[optind];
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   140
            
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   141
            log_info("only running tests: %s", filter);
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   142
        } else {
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   143
            FATAL("too many arguments");
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   144
        }
52
97604efda1ce add test_sock_push, and filter argument to test main()
Tero Marttila <terom@fixme.fi>
parents: 51
diff changeset
   145
    }
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   146
90
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   147
    // setup the sockets stuff
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   148
    _test_ctx.ev_base = setup_sock();
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   149
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   150
    // run tests
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   151
    if ((test_count = run_tests(_tests, filter)) == 0)
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   152
        FATAL("no tests run");
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   153
    
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   154
    // log
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   155
    log_info("done, ran %zu tests", test_count);
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   156
    
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   157
    // ok
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   158
    return EXIT_SUCCESS;
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   159
}
52
97604efda1ce add test_sock_push, and filter argument to test main()
Tero Marttila <terom@fixme.fi>
parents: 51
diff changeset
   160