source: tests/check.c @ d2d2b80

Last change on this file since d2d2b80 was 5ebff60, checked in by dequis <dx@…>, at 2015-02-20T22:50:54Z

Reindent everything to K&R style with tabs

Used uncrustify, with the configuration file in ./doc/uncrustify.cfg

Commit author set to "Indent <please@…>" so that it's easier to
skip while doing git blame.

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