src/test/test.c
author Tero Marttila <terom@fixme.fi>
Fri, 08 May 2009 00:12:15 +0300
changeset 188 6fd4706a4180
parent 168 a58ad50911fc
child 195 42aedce3e2eb
permissions -rw-r--r--
add a run_test to test.c to improve the log_info output
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
/**
188
6fd4706a4180 add a run_test to test.c to improve the log_info output
Tero Marttila <terom@fixme.fi>
parents: 168
diff changeset
    78
 * Run the given test, updating the given counter
6fd4706a4180 add a run_test to test.c to improve the log_info output
Tero Marttila <terom@fixme.fi>
parents: 168
diff changeset
    79
 */
6fd4706a4180 add a run_test to test.c to improve the log_info output
Tero Marttila <terom@fixme.fi>
parents: 168
diff changeset
    80
static void run_test (const struct test *test, size_t *test_count)
6fd4706a4180 add a run_test to test.c to improve the log_info output
Tero Marttila <terom@fixme.fi>
parents: 168
diff changeset
    81
{
6fd4706a4180 add a run_test to test.c to improve the log_info output
Tero Marttila <terom@fixme.fi>
parents: 168
diff changeset
    82
    log_info("%s", test->name);
6fd4706a4180 add a run_test to test.c to improve the log_info output
Tero Marttila <terom@fixme.fi>
parents: 168
diff changeset
    83
6fd4706a4180 add a run_test to test.c to improve the log_info output
Tero Marttila <terom@fixme.fi>
parents: 168
diff changeset
    84
    // count and run
6fd4706a4180 add a run_test to test.c to improve the log_info output
Tero Marttila <terom@fixme.fi>
parents: 168
diff changeset
    85
    (*test_count)++;
6fd4706a4180 add a run_test to test.c to improve the log_info output
Tero Marttila <terom@fixme.fi>
parents: 168
diff changeset
    86
    test->func();
6fd4706a4180 add a run_test to test.c to improve the log_info output
Tero Marttila <terom@fixme.fi>
parents: 168
diff changeset
    87
}
6fd4706a4180 add a run_test to test.c to improve the log_info output
Tero Marttila <terom@fixme.fi>
parents: 168
diff changeset
    88
6fd4706a4180 add a run_test to test.c to improve the log_info output
Tero Marttila <terom@fixme.fi>
parents: 168
diff changeset
    89
/**
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    90
 * 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
    91
 *
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    92
 * 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
    93
 */
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    94
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
    95
{
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    96
    size_t test_count = 0;
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
    97
    const struct test *test;
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
    // run each test in turn
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   100
    for (test = tests; test->name; test++) {
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   101
        // filter out if given
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   102
        if ((filter && strcmp(test->name, filter)) || (!filter && test->optional))
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   103
            continue;
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   104
        
188
6fd4706a4180 add a run_test to test.c to improve the log_info output
Tero Marttila <terom@fixme.fi>
parents: 168
diff changeset
   105
        // run it
6fd4706a4180 add a run_test to test.c to improve the log_info output
Tero Marttila <terom@fixme.fi>
parents: 168
diff changeset
   106
        run_test(test, &test_count);
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   107
    }
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   108
    
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   109
    return test_count;
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   110
}
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   111
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   112
int main (int argc, char **argv)
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   113
{
73
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   114
    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
   115
    const char *filter = NULL;
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   116
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   117
    size_t test_count;
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   118
73
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   119
    // parse options
90
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   120
    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
   121
        switch (opt) {
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   122
            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
   123
                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
   124
                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
   125
            
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   126
            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
   127
                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
   128
                break;
52
97604efda1ce add test_sock_push, and filter argument to test main()
Tero Marttila <terom@fixme.fi>
parents: 51
diff changeset
   129
73
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   130
            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
   131
                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
   132
                break;
90
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   133
           
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   134
            case OPT_LIST:
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   135
                list_tests(_tests);
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   136
                exit(EXIT_SUCCESS);
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   137
73
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   138
            case '?':
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   139
                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
   140
                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
   141
        }
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   142
    }
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   143
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   144
    // 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
   145
    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
   146
        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
   147
            // filter
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   148
            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
   149
            
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   150
            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
   151
        } else {
2780a73c71f3 add set_log_level function, and add --debug/--quiet options to test
Tero Marttila <terom@fixme.fi>
parents: 72
diff changeset
   152
            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
   153
        }
52
97604efda1ce add test_sock_push, and filter argument to test main()
Tero Marttila <terom@fixme.fi>
parents: 51
diff changeset
   154
    }
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   155
90
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   156
    // setup the sockets stuff
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   157
    _test_ctx.ev_base = setup_sock();
9d489b1039b2 implement irc_queue, with some basic functionality tests
Tero Marttila <terom@fixme.fi>
parents: 89
diff changeset
   158
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   159
    // run tests
168
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   160
    if ((test_count = run_tests(_tests, filter)) == 0)
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   161
        FATAL("no tests run");
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   162
    
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   163
    // log
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   164
    log_info("done, ran %zu tests", test_count);
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   165
    
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   166
    // ok
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   167
    return EXIT_SUCCESS;
a58ad50911fc refactor test.c into tests/*
Tero Marttila <terom@fixme.fi>
parents: 167
diff changeset
   168
}
52
97604efda1ce add test_sock_push, and filter argument to test main()
Tero Marttila <terom@fixme.fi>
parents: 51
diff changeset
   169