source: tests/check.c @ f7ca587

Last change on this file since f7ca587 was b40e60d, checked in by Wilmer van der Gaast <wilmer@…>, at 2010-07-29T08:57:01Z

Fixing http_encode(): BitlBee now calls setlocale() (for nickname
transliteration to work), which changes the behaviour of isalpha() (turns
out it's not a simple macro). For HTTP-encoding, this sucks, especially
when doing OAuth (which is very picky about the way HTTP encoding is done).
This should fix problems some people were seeing with posting Twitter
messages containing accents.

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