source: tests/check.c @ 3e16fb8

Last change on this file since 3e16fb8 was 3e16fb8, checked in by Jelmer Vernooij <jelmer@…>, at 2014-04-20T16:59:23Z

Fix compiler warnings in testsuite/.

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[c2fa827]1#include <stdlib.h>
2#include <glib.h>
3#include <gmodule.h>
4#include <check.h>
[b40e60d]5#include <locale.h>
[3e16fb8]6#include <sys/time.h>
[1fc2958]7#include "bitlbee.h"
[6a90967]8#include "testsuite.h"
[1fc2958]9
10global_t global;        /* Against global namespace pollution */
11
[6a90967]12gboolean g_io_channel_pair(GIOChannel **ch1, GIOChannel **ch2)
13{
14        int sock[2];
15        if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNIX, sock) < 0) {
16                perror("socketpair");
17                return FALSE;
18        }
19
20        *ch1 = g_io_channel_unix_new(sock[0]);
21        *ch2 = g_io_channel_unix_new(sock[1]);
22        return TRUE;
23}
24
[ed5df81]25irc_t *torture_irc(void)
26{
27        irc_t *irc;
28        GIOChannel *ch1, *ch2;
29        if (!g_io_channel_pair(&ch1, &ch2))
30                return NULL;
31        irc = irc_new(g_io_channel_unix_get_fd(ch1));
32        return irc;
33}
34
[1fc2958]35double gettime()
36{
37        struct timeval time[1];
38
39        gettimeofday( time, 0 );
40        return( (double) time->tv_sec + (double) time->tv_usec / 1000000 );
41}
[c2fa827]42
43/* From check_util.c */
44Suite *util_suite(void);
45
[1fc2958]46/* From check_nick.c */
47Suite *nick_suite(void);
48
[6a90967]49/* From check_md5.c */
50Suite *md5_suite(void);
51
[2305488]52/* From check_arc.c */
53Suite *arc_suite(void);
54
[7bcdde3]55/* From check_irc.c */
56Suite *irc_suite(void);
57
[c227706]58/* From check_help.c */
59Suite *help_suite(void);
60
[ed5df81]61/* From check_user.c */
62Suite *user_suite(void);
63
[7738014]64/* From check_set.c */
65Suite *set_suite(void);
66
[af97b23]67/* From check_jabber_sasl.c */
68Suite *jabber_sasl_suite(void);
69
[3e6764a]70/* From check_jabber_sasl.c */
71Suite *jabber_util_suite(void);
72
[3b4cc8f]73int main (int argc, char **argv)
[c2fa827]74{
75        int nf;
[3b4cc8f]76        SRunner *sr;
77        GOptionContext *pc;
78        gboolean no_fork = FALSE;
79        gboolean verbose = FALSE;
80        GOptionEntry options[] = {
81                {"no-fork", 'n', 0, G_OPTION_ARG_NONE, &no_fork, "Don't fork" },
82                {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL },
83                { NULL }
84        };
85
86        pc = g_option_context_new("");
87        g_option_context_add_main_entries(pc, options, NULL);
88
89        if(!g_option_context_parse(pc, &argc, &argv, NULL))
90                return 1;
91
92        g_option_context_free(pc);
93
[7bcdde3]94        log_init();
[1521a85]95        b_main_init();
[b40e60d]96        setlocale(LC_CTYPE, "");
[7bcdde3]97
98        if (verbose) {
99                log_link( LOGLVL_ERROR, LOGOUTPUT_CONSOLE );
[9225e08]100#ifdef DEBUG
[7bcdde3]101                log_link( LOGLVL_DEBUG, LOGOUTPUT_CONSOLE );
[9225e08]102#endif
[7bcdde3]103                log_link( LOGLVL_INFO, LOGOUTPUT_CONSOLE );
104                log_link( LOGLVL_WARNING, LOGOUTPUT_CONSOLE );
105        }
106
107        global.conf = conf_load( 0, NULL);
108        global.conf->runmode = RUNMODE_DAEMON;
[3b4cc8f]109
110        sr = srunner_create(util_suite());
[1fc2958]111        srunner_add_suite(sr, nick_suite());
[6a90967]112        srunner_add_suite(sr, md5_suite());
[2305488]113        srunner_add_suite(sr, arc_suite());
[7bcdde3]114        srunner_add_suite(sr, irc_suite());
[c227706]115        srunner_add_suite(sr, help_suite());
[ed5df81]116        srunner_add_suite(sr, user_suite());
[7738014]117        srunner_add_suite(sr, set_suite());
[af97b23]118        srunner_add_suite(sr, jabber_sasl_suite());
[3e6764a]119        srunner_add_suite(sr, jabber_util_suite());
[3b4cc8f]120        if (no_fork)
121                srunner_set_fork_status(sr, CK_NOFORK);
122        srunner_run_all (sr, verbose?CK_VERBOSE:CK_NORMAL);
[c2fa827]123        nf = srunner_ntests_failed(sr);
124        srunner_free(sr);
125        return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
126}
Note: See TracBrowser for help on using the repository browser.