From c2fa8279933a103d6576d891e85c1801d90c65ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 16 Jun 2006 13:48:52 +0200 Subject: Add unit testing infrastructure. --- tests/Makefile | 14 ++++++++++++++ tests/check.c | 17 +++++++++++++++++ tests/check_util.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 tests/Makefile create mode 100644 tests/check.c create mode 100644 tests/check_util.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 00000000..3a27a430 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,14 @@ +include ../Makefile.settings + +LFLAGS +=-lcheck + +all: check + ./check + +check: check.o check_util.o ../util.o + @echo '*' Linking $@ + @$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS) $(EFLAGS) + +%.o: %.c + @echo '*' Compiling $< + @$(CC) -c $(CFLAGS) $< -o $@ diff --git a/tests/check.c b/tests/check.c new file mode 100644 index 00000000..999da16a --- /dev/null +++ b/tests/check.c @@ -0,0 +1,17 @@ +#include +#include +#include +#include + +/* From check_util.c */ +Suite *util_suite(void); + +int main (void) +{ + int nf; + SRunner *sr = srunner_create(util_suite()); + srunner_run_all (sr, CK_NORMAL); + nf = srunner_ntests_failed(sr); + srunner_free(sr); + return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/tests/check_util.c b/tests/check_util.c new file mode 100644 index 00000000..52e8174c --- /dev/null +++ b/tests/check_util.c @@ -0,0 +1,34 @@ +#include +#include +#include +#include +#include +#include "irc.h" +#include "set.h" +#include "util.h" + +START_TEST(test_strip_linefeed) +{ + int i; + const char *get[] = { "Test", "Test\r", "Test\rX\r", NULL }; + const char *expected[] = { "Test", "Test", "TestX", NULL }; + + for (i = 0; get[i]; i++) { + char copy[20]; + strcpy(copy, get[i]); + strip_linefeed(copy); + fail_unless (strcmp(copy, expected[i]) == 0, + "(%d) strip_linefeed broken: %s -> %s (expected: %s)", + i, get[i], copy, expected[i]); + } +} +END_TEST + +Suite *util_suite (void) +{ + Suite *s = suite_create("Util"); + TCase *tc_core = tcase_create("Core"); + suite_add_tcase (s, tc_core); + tcase_add_test (tc_core, test_strip_linefeed); + return s; +} -- cgit v1.2.3 From 1fc2958b1e503b782081692c1a503bc7bba19fe1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 16 Jun 2006 14:07:51 +0200 Subject: Add checks for nick functions as well, fix bug where nick lengths weren't being honored. --- tests/Makefile | 4 +++- tests/check.c | 15 ++++++++++++ tests/check_nick.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/check_util.c | 19 +++++++++++++++ 4 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 tests/check_nick.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 3a27a430..ce8ed690 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -5,7 +5,9 @@ LFLAGS +=-lcheck all: check ./check -check: check.o check_util.o ../util.o +main_objs = account.o bitlbee.o conf.o crypting.o help.o ini.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_text.o url.o user.o util.o + +check: check.o check_util.o check_nick.o $(addprefix ../, $(main_objs)) ../protocols/protocols.o @echo '*' Linking $@ @$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS) $(EFLAGS) diff --git a/tests/check.c b/tests/check.c index 999da16a..5cfb7dfd 100644 --- a/tests/check.c +++ b/tests/check.c @@ -2,14 +2,29 @@ #include #include #include +#include "bitlbee.h" + +global_t global; /* Against global namespace pollution */ + +double gettime() +{ + struct timeval time[1]; + + gettimeofday( time, 0 ); + return( (double) time->tv_sec + (double) time->tv_usec / 1000000 ); +} /* From check_util.c */ Suite *util_suite(void); +/* From check_nick.c */ +Suite *nick_suite(void); + int main (void) { int nf; SRunner *sr = srunner_create(util_suite()); + srunner_add_suite(sr, nick_suite()); srunner_run_all (sr, CK_NORMAL); nf = srunner_ntests_failed(sr); srunner_free(sr); diff --git a/tests/check_nick.c b/tests/check_nick.c new file mode 100644 index 00000000..5858e512 --- /dev/null +++ b/tests/check_nick.c @@ -0,0 +1,70 @@ +#include +#include +#include +#include +#include +#include "irc.h" +#include "set.h" +#include "util.h" + +START_TEST(test_nick_strip) +{ + int i; + const char *get[] = { "test:", "test", "test\n", + "thisisaveryveryveryverylongnick", + "thisisave:ryveryveryverylongnick", + "t::::est", + NULL }; + const char *expected[] = { "test", "test", "test", + "thisisaveryveryveryveryl", + "thisisaveryveryveryveryl", + "test", + NULL }; + + for (i = 0; get[i]; i++) { + char copy[30]; + strcpy(copy, get[i]); + nick_strip(copy); + fail_unless (strcmp(copy, expected[i]) == 0, + "(%d) nick_strip broken: %s -> %s (expected: %s)", + i, get[i], copy, expected[i]); + } +} +END_TEST + +START_TEST(test_nick_ok_ok) +{ + const char *nicks[] = { "foo", "bar", "bla[", "blie]", + "BreEZaH", "\\od^~", NULL }; + int i; + + for (i = 0; nicks[i]; i++) { + fail_unless (nick_ok(nicks[i]) == 1, + "nick_ok() failed: %s", nicks[i]); + } +} +END_TEST + +START_TEST(test_nick_ok_notok) +{ + const char *nicks[] = { "thisisaveryveryveryveryveryveryverylongnick", + "\nillegalchar", "", "nick%", NULL }; + int i; + + for (i = 0; nicks[i]; i++) { + fail_unless (nick_ok(nicks[i]) == 0, + "nick_ok() succeeded for invalid: %s", nicks[i]); + } +} +END_TEST + +Suite *nick_suite (void) +{ + Suite *s = suite_create("Nick"); + TCase *tc_core = tcase_create("Core"); + suite_add_tcase (s, tc_core); + tcase_add_test (tc_core, test_nick_ok_ok); + tcase_add_test (tc_core, test_nick_ok_notok); + tcase_add_test (tc_core, test_nick_strip); + return s; +} diff --git a/tests/check_util.c b/tests/check_util.c index 52e8174c..e771238f 100644 --- a/tests/check_util.c +++ b/tests/check_util.c @@ -24,11 +24,30 @@ START_TEST(test_strip_linefeed) } END_TEST +START_TEST(test_strip_newlines) +{ + int i; + const char *get[] = { "Test", "Test\r\n", "Test\nX\n", NULL }; + const char *expected[] = { "Test", "Test ", "Test X ", NULL }; + + for (i = 0; get[i]; i++) { + char copy[20], *ret; + strcpy(copy, get[i]); + ret = strip_newlines(copy); + fail_unless (strcmp(copy, expected[i]) == 0, + "(%d) strip_newlines broken: %s -> %s (expected: %s)", + i, get[i], copy, expected[i]); + fail_unless (copy == ret, "Original string not returned"); + } +} +END_TEST + Suite *util_suite (void) { Suite *s = suite_create("Util"); TCase *tc_core = tcase_create("Core"); suite_add_tcase (s, tc_core); tcase_add_test (tc_core, test_strip_linefeed); + tcase_add_test (tc_core, test_strip_newlines); return s; } -- cgit v1.2.3 From 66b9e86eafc3709c491f96c917069db8b6a0c895 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Jul 2006 15:33:31 +0200 Subject: Add support for checking test suite coverage using gcov. --- tests/Makefile | 9 +++++++-- tests/check_nick.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index ce8ed690..206331f4 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -2,12 +2,17 @@ include ../Makefile.settings LFLAGS +=-lcheck -all: check +all: check ./check +clean: + rm -f check *.o + main_objs = account.o bitlbee.o conf.o crypting.o help.o ini.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_text.o url.o user.o util.o -check: check.o check_util.o check_nick.o $(addprefix ../, $(main_objs)) ../protocols/protocols.o +test_objs = check.o check_util.o check_nick.o + +check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o @echo '*' Linking $@ @$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS) $(EFLAGS) diff --git a/tests/check_nick.c b/tests/check_nick.c index 5858e512..b235d260 100644 --- a/tests/check_nick.c +++ b/tests/check_nick.c @@ -22,7 +22,7 @@ START_TEST(test_nick_strip) NULL }; for (i = 0; get[i]; i++) { - char copy[30]; + char copy[60]; strcpy(copy, get[i]); nick_strip(copy); fail_unless (strcmp(copy, expected[i]) == 0, -- cgit v1.2.3 From 2c7df621d2337437a46b0ccee6a7801bc04db8f4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Dec 2006 13:15:09 +0100 Subject: Fix testsuite. --- tests/Makefile | 4 ++-- tests/check_nick.c | 2 +- tests/check_util.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 206331f4..f0456063 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -8,11 +8,11 @@ all: check clean: rm -f check *.o -main_objs = account.o bitlbee.o conf.o crypting.o help.o ini.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_text.o url.o user.o util.o +main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o test_objs = check.o check_util.o check_nick.o -check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o +check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../lib/lib.o @echo '*' Linking $@ @$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS) $(EFLAGS) diff --git a/tests/check_nick.c b/tests/check_nick.c index b235d260..714c4fdc 100644 --- a/tests/check_nick.c +++ b/tests/check_nick.c @@ -5,7 +5,7 @@ #include #include "irc.h" #include "set.h" -#include "util.h" +#include "misc.h" START_TEST(test_nick_strip) { diff --git a/tests/check_util.c b/tests/check_util.c index e771238f..ee365735 100644 --- a/tests/check_util.c +++ b/tests/check_util.c @@ -5,7 +5,7 @@ #include #include "irc.h" #include "set.h" -#include "util.h" +#include "misc.h" START_TEST(test_strip_linefeed) { -- cgit v1.2.3 From 6a909671115ba5fac94c212c249264bf25ec8840 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Dec 2006 14:26:22 +0100 Subject: Add tests for md5. --- tests/Makefile | 2 +- tests/check.c | 18 ++++++++++++++++++ tests/check_md5.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/testsuite.h | 6 ++++++ 4 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 tests/check_md5.c create mode 100644 tests/testsuite.h (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index f0456063..6a97e8ac 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -10,7 +10,7 @@ clean: main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o -test_objs = check.o check_util.o check_nick.o +test_objs = check.o check_util.o check_nick.o check_md5.o check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../lib/lib.o @echo '*' Linking $@ diff --git a/tests/check.c b/tests/check.c index 5cfb7dfd..294580b7 100644 --- a/tests/check.c +++ b/tests/check.c @@ -3,9 +3,23 @@ #include #include #include "bitlbee.h" +#include "testsuite.h" global_t global; /* Against global namespace pollution */ +gboolean g_io_channel_pair(GIOChannel **ch1, GIOChannel **ch2) +{ + int sock[2]; + if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNIX, sock) < 0) { + perror("socketpair"); + return FALSE; + } + + *ch1 = g_io_channel_unix_new(sock[0]); + *ch2 = g_io_channel_unix_new(sock[1]); + return TRUE; +} + double gettime() { struct timeval time[1]; @@ -20,11 +34,15 @@ Suite *util_suite(void); /* From check_nick.c */ Suite *nick_suite(void); +/* From check_md5.c */ +Suite *md5_suite(void); + int main (void) { int nf; SRunner *sr = srunner_create(util_suite()); srunner_add_suite(sr, nick_suite()); + srunner_add_suite(sr, md5_suite()); srunner_run_all (sr, CK_NORMAL); nf = srunner_ntests_failed(sr); srunner_free(sr); diff --git a/tests/check_md5.c b/tests/check_md5.c new file mode 100644 index 00000000..4b99d300 --- /dev/null +++ b/tests/check_md5.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include +#include +#include +#include "md5.h" + +/* From RFC 1321 */ +struct md5_test { + const char *str; + md5_byte_t expected[16]; +} tests[] = { + { "", + { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e } }, + { "a", + { 0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8, 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 } }, + { "abc", + { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 } }, + { "message digest", + { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d, 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 } }, + { "abcdefghijklmnopqrstuvwxyz", + { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b } }, + { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5, 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f } }, + { "12345678901234567890123456789012345678901234567890123456789012345678901234567890", + { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55, 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a } }, + + { NULL }, +}; + +static void check_sums(int l) +{ + int i; + for (i = 0; tests[i].str; i++) { + md5_byte_t sum[16]; + tcase_fn_start (tests[i].str, __FILE__, __LINE__); + md5_state_t state; + int di; + + md5_init(&state); + md5_append(&state, (const md5_byte_t *)tests[i].str, strlen(tests[i].str)); + md5_finish(&state, sum); + + fail_if(memcmp(tests[i].expected, sum, 16) != 0, "%s failed", tests[i].str); + } +} + +Suite *md5_suite (void) +{ + Suite *s = suite_create("MD5"); + TCase *tc_core = tcase_create("Core"); + suite_add_tcase (s, tc_core); + tcase_add_test (tc_core, check_sums); + return s; +} diff --git a/tests/testsuite.h b/tests/testsuite.h new file mode 100644 index 00000000..dacaf8a3 --- /dev/null +++ b/tests/testsuite.h @@ -0,0 +1,6 @@ +#ifndef __BITLBEE_CHECK_H__ +#define __BITLBEE_CHECK_H__ + +gboolean g_io_channel_pair(GIOChannel **ch1, GIOChannel **ch2); + +#endif /* __BITLBEE_CHECK_H__ */ -- cgit v1.2.3 From 3b4cc8f0af7a4d9e1fae69e12a438b15f9206003 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Dec 2006 14:34:15 +0100 Subject: Support arguments passed to tests/check to enable verbose logging or to disable forking (for debugging purposes). --- tests/check.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/check.c b/tests/check.c index 294580b7..6cba4302 100644 --- a/tests/check.c +++ b/tests/check.c @@ -37,13 +37,35 @@ Suite *nick_suite(void); /* From check_md5.c */ Suite *md5_suite(void); -int main (void) +int main (int argc, char **argv) { int nf; - SRunner *sr = srunner_create(util_suite()); + SRunner *sr; + GOptionContext *pc; + gboolean no_fork = FALSE; + gboolean verbose = FALSE; + GOptionEntry options[] = { + {"no-fork", 'n', 0, G_OPTION_ARG_NONE, &no_fork, "Don't fork" }, + {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL }, + { NULL } + }; + int i; + + pc = g_option_context_new(""); + g_option_context_add_main_entries(pc, options, NULL); + + if(!g_option_context_parse(pc, &argc, &argv, NULL)) + return 1; + + g_option_context_free(pc); + + + sr = srunner_create(util_suite()); srunner_add_suite(sr, nick_suite()); srunner_add_suite(sr, md5_suite()); - srunner_run_all (sr, CK_NORMAL); + if (no_fork) + srunner_set_fork_status(sr, CK_NOFORK); + srunner_run_all (sr, verbose?CK_VERBOSE:CK_NORMAL); nf = srunner_ntests_failed(sr); srunner_free(sr); return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; -- cgit v1.2.3 From 7bcdde3d31f0e5b53601b90aa33ebd820c770172 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Dec 2006 14:57:25 +0100 Subject: Some simple tests for irc_*() --- tests/Makefile | 4 ++-- tests/check.c | 15 +++++++++++++ tests/check_irc.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 tests/check_irc.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 6a97e8ac..9dd3df7c 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -3,14 +3,14 @@ include ../Makefile.settings LFLAGS +=-lcheck all: check - ./check + ./check $(CHECKFLAGS) clean: rm -f check *.o main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o -test_objs = check.o check_util.o check_nick.o check_md5.o +test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../lib/lib.o @echo '*' Linking $@ diff --git a/tests/check.c b/tests/check.c index 6cba4302..42ff067f 100644 --- a/tests/check.c +++ b/tests/check.c @@ -37,6 +37,9 @@ Suite *nick_suite(void); /* From check_md5.c */ Suite *md5_suite(void); +/* From check_irc.c */ +Suite *irc_suite(void); + int main (int argc, char **argv) { int nf; @@ -59,10 +62,22 @@ int main (int argc, char **argv) g_option_context_free(pc); + log_init(); + + if (verbose) { + log_link( LOGLVL_ERROR, LOGOUTPUT_CONSOLE ); + log_link( LOGLVL_DEBUG, LOGOUTPUT_CONSOLE ); + log_link( LOGLVL_INFO, LOGOUTPUT_CONSOLE ); + log_link( LOGLVL_WARNING, LOGOUTPUT_CONSOLE ); + } + + global.conf = conf_load( 0, NULL); + global.conf->runmode = RUNMODE_DAEMON; sr = srunner_create(util_suite()); srunner_add_suite(sr, nick_suite()); srunner_add_suite(sr, md5_suite()); + srunner_add_suite(sr, irc_suite()); if (no_fork) srunner_set_fork_status(sr, CK_NOFORK); srunner_run_all (sr, verbose?CK_VERBOSE:CK_NORMAL); diff --git a/tests/check_irc.c b/tests/check_irc.c new file mode 100644 index 00000000..c1cf05a5 --- /dev/null +++ b/tests/check_irc.c @@ -0,0 +1,65 @@ +#include +#include +#include +#include +#include +#include +#include "irc.h" +#include "testsuite.h" + +START_TEST(test_connect) + GIOChannel *ch1, *ch2; + irc_t *irc; + char *raw; + fail_unless(g_io_channel_pair(&ch1, &ch2)); + + irc = irc_new(g_io_channel_unix_get_fd(ch1)); + + irc_free(irc); + + fail_unless(g_io_channel_read_to_end(ch2, &raw, NULL, NULL) == G_IO_STATUS_NORMAL); + + fail_if(strcmp(raw, "") != 0); + + g_free(raw); +END_TEST + +START_TEST(test_login) + GIOChannel *ch1, *ch2; + irc_t *irc; + GError *error = NULL; + char *raw; + fail_unless(g_io_channel_pair(&ch1, &ch2)); + + g_io_channel_set_flags(ch1, G_IO_FLAG_NONBLOCK, NULL); + g_io_channel_set_flags(ch2, G_IO_FLAG_NONBLOCK, NULL); + + irc = irc_new(g_io_channel_unix_get_fd(ch1)); + + fail_unless(g_io_channel_write_chars(ch2, "NICK bla\r\n" + "USER a a a a\r\n", -1, NULL, NULL) == G_IO_STATUS_NORMAL); + fail_unless(g_io_channel_flush(ch2, NULL) == G_IO_STATUS_NORMAL); + + g_main_iteration(FALSE); + irc_free(irc); + + fail_unless(g_io_channel_read_to_end(ch2, &raw, NULL, NULL) == G_IO_STATUS_NORMAL); + + fail_unless(strstr(raw, "001") != NULL); + fail_unless(strstr(raw, "002") != NULL); + fail_unless(strstr(raw, "003") != NULL); + fail_unless(strstr(raw, "004") != NULL); + fail_unless(strstr(raw, "005") != NULL); + + g_free(raw); +END_TEST + +Suite *irc_suite (void) +{ + Suite *s = suite_create("IRC"); + TCase *tc_core = tcase_create("Core"); + suite_add_tcase (s, tc_core); + tcase_add_test (tc_core, test_connect); + tcase_add_test (tc_core, test_login); + return s; +} -- cgit v1.2.3 From 9225e08f377026e653e31468d53df9d328dd7951 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 24 Dec 2006 02:47:20 +0100 Subject: Fix check for non-debug builds. --- tests/check.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/check.c b/tests/check.c index 42ff067f..f70ccae7 100644 --- a/tests/check.c +++ b/tests/check.c @@ -66,7 +66,9 @@ int main (int argc, char **argv) if (verbose) { log_link( LOGLVL_ERROR, LOGOUTPUT_CONSOLE ); +#ifdef DEBUG log_link( LOGLVL_DEBUG, LOGOUTPUT_CONSOLE ); +#endif log_link( LOGLVL_INFO, LOGOUTPUT_CONSOLE ); log_link( LOGLVL_WARNING, LOGOUTPUT_CONSOLE ); } -- cgit v1.2.3 From c227706bc921c3bb426eb315c0d097df30aa9d16 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 24 Dec 2006 20:35:13 +0100 Subject: Refactor the help code to take a filename rather than using the global struct. --- tests/Makefile | 2 +- tests/check.c | 4 ++++ tests/check_help.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/check_help.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 9dd3df7c..3ddd1570 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -10,7 +10,7 @@ clean: main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o -test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o +test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o check_help.o check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../lib/lib.o @echo '*' Linking $@ diff --git a/tests/check.c b/tests/check.c index f70ccae7..069b3c57 100644 --- a/tests/check.c +++ b/tests/check.c @@ -40,6 +40,9 @@ Suite *md5_suite(void); /* From check_irc.c */ Suite *irc_suite(void); +/* From check_help.c */ +Suite *help_suite(void); + int main (int argc, char **argv) { int nf; @@ -80,6 +83,7 @@ int main (int argc, char **argv) srunner_add_suite(sr, nick_suite()); srunner_add_suite(sr, md5_suite()); srunner_add_suite(sr, irc_suite()); + srunner_add_suite(sr, help_suite()); if (no_fork) srunner_set_fork_status(sr, CK_NOFORK); srunner_run_all (sr, verbose?CK_VERBOSE:CK_NORMAL); diff --git a/tests/check_help.c b/tests/check_help.c new file mode 100644 index 00000000..7e5283e3 --- /dev/null +++ b/tests/check_help.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include +#include +#include "help.h" + +START_TEST(test_help_none) + help_t *h, *r; + r = help_init(&h, "/dev/null"); + fail_if(r == NULL); + fail_if(r != h); +END_TEST + +START_TEST(test_help_nonexistent) + help_t *h, *r; + r = help_init(&h, "/dev/null"); + fail_unless(help_get(&h, "nonexistent") == NULL); +END_TEST + +Suite *help_suite (void) +{ + Suite *s = suite_create("Help"); + TCase *tc_core = tcase_create("Core"); + suite_add_tcase (s, tc_core); + tcase_add_test (tc_core, test_help_none); + tcase_add_test (tc_core, test_help_nonexistent); + return s; +} -- cgit v1.2.3 From 7bee5af91e56f1e58232b895fd40c367aec67e8a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 24 Dec 2006 22:47:18 +0100 Subject: Add tests for set_url(). Fixed a bug where the default port wasn't set when socks5 was used. --- tests/check_util.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'tests') diff --git a/tests/check_util.c b/tests/check_util.c index ee365735..284ddba3 100644 --- a/tests/check_util.c +++ b/tests/check_util.c @@ -6,6 +6,7 @@ #include "irc.h" #include "set.h" #include "misc.h" +#include "url.h" START_TEST(test_strip_linefeed) { @@ -42,6 +43,66 @@ START_TEST(test_strip_newlines) } END_TEST +START_TEST(test_set_url_http) + url_t url; + + fail_if (0 == url_set(&url, "http://host/")); + fail_unless (!strcmp(url.host, "host")); + fail_unless (!strcmp(url.file, "/")); + fail_unless (!strcmp(url.user, "")); + fail_unless (!strcmp(url.pass, "")); + fail_unless (url.proto == PROTO_HTTP); + fail_unless (url.port == 80); +END_TEST + +START_TEST(test_set_url_https) + url_t url; + + fail_if (0 == url_set(&url, "https://ahost/AimeeMann")); + fail_unless (!strcmp(url.host, "ahost")); + fail_unless (!strcmp(url.file, "/AimeeMann")); + fail_unless (!strcmp(url.user, "")); + fail_unless (!strcmp(url.pass, "")); + fail_unless (url.proto == PROTO_HTTPS); + fail_unless (url.port == 443); +END_TEST + +START_TEST(test_set_url_port) + url_t url; + + fail_if (0 == url_set(&url, "https://ahost:200/Lost/In/Space")); + fail_unless (!strcmp(url.host, "ahost")); + fail_unless (!strcmp(url.file, "/Lost/In/Space")); + fail_unless (!strcmp(url.user, "")); + fail_unless (!strcmp(url.pass, "")); + fail_unless (url.proto == PROTO_HTTPS); + fail_unless (url.port == 200); +END_TEST + +START_TEST(test_set_url_username) + url_t url; + + fail_if (0 == url_set(&url, "socks4://user@ahost/Space")); + fail_unless (!strcmp(url.host, "ahost")); + fail_unless (!strcmp(url.file, "/Space")); + fail_unless (!strcmp(url.user, "user")); + fail_unless (!strcmp(url.pass, "")); + fail_unless (url.proto == PROTO_SOCKS4); + fail_unless (url.port == 1080); +END_TEST + +START_TEST(test_set_url_username_pwd) + url_t url; + + fail_if (0 == url_set(&url, "socks5://user:pass@ahost/")); + fail_unless (!strcmp(url.host, "ahost")); + fail_unless (!strcmp(url.file, "/")); + fail_unless (!strcmp(url.user, "user")); + fail_unless (!strcmp(url.pass, "pass")); + fail_unless (url.proto == PROTO_SOCKS5); + fail_unless (url.port == 1080); +END_TEST + Suite *util_suite (void) { Suite *s = suite_create("Util"); @@ -49,5 +110,10 @@ Suite *util_suite (void) suite_add_tcase (s, tc_core); tcase_add_test (tc_core, test_strip_linefeed); tcase_add_test (tc_core, test_strip_newlines); + tcase_add_test (tc_core, test_set_url_http); + tcase_add_test (tc_core, test_set_url_https); + tcase_add_test (tc_core, test_set_url_port); + tcase_add_test (tc_core, test_set_url_username); + tcase_add_test (tc_core, test_set_url_username_pwd); return s; } -- cgit v1.2.3 From ed5df815732d311b228993627f5d8b8c8e3eb4e0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 21 Jan 2007 22:17:11 +0100 Subject: Add unit testing for user code --- tests/Makefile | 2 +- tests/check.c | 14 ++++++++++ tests/check_user.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/testsuite.h | 1 + 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 tests/check_user.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 3ddd1570..b9da83c9 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -10,7 +10,7 @@ clean: main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o -test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o check_help.o +test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o check_help.o check_user.o check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../lib/lib.o @echo '*' Linking $@ diff --git a/tests/check.c b/tests/check.c index 069b3c57..9fee07e3 100644 --- a/tests/check.c +++ b/tests/check.c @@ -20,6 +20,16 @@ gboolean g_io_channel_pair(GIOChannel **ch1, GIOChannel **ch2) return TRUE; } +irc_t *torture_irc(void) +{ + irc_t *irc; + GIOChannel *ch1, *ch2; + if (!g_io_channel_pair(&ch1, &ch2)) + return NULL; + irc = irc_new(g_io_channel_unix_get_fd(ch1)); + return irc; +} + double gettime() { struct timeval time[1]; @@ -43,6 +53,9 @@ Suite *irc_suite(void); /* From check_help.c */ Suite *help_suite(void); +/* From check_user.c */ +Suite *user_suite(void); + int main (int argc, char **argv) { int nf; @@ -84,6 +97,7 @@ int main (int argc, char **argv) srunner_add_suite(sr, md5_suite()); srunner_add_suite(sr, irc_suite()); srunner_add_suite(sr, help_suite()); + srunner_add_suite(sr, user_suite()); if (no_fork) srunner_set_fork_status(sr, CK_NOFORK); srunner_run_all (sr, verbose?CK_VERBOSE:CK_NORMAL); diff --git a/tests/check_user.c b/tests/check_user.c new file mode 100644 index 00000000..79248049 --- /dev/null +++ b/tests/check_user.c @@ -0,0 +1,75 @@ +#include +#include +#include +#include +#include +#include "bitlbee.h" +#include "user.h" +#include "testsuite.h" + +START_TEST(test_user_add) + irc_t *irc = torture_irc(); + user_t *user; + user = user_add(irc, "foo"); + fail_if(user == NULL); + fail_if(strcmp(user->nick, "foo") != 0); + fail_unless(user_find(irc, "foo") == user); +END_TEST + +START_TEST(test_user_add_exists) + irc_t *irc = torture_irc(); + user_t *user; + user = user_add(irc, "foo"); + fail_if(user == NULL); + user = user_add(irc, "foo"); + fail_unless(user == NULL); +END_TEST + +START_TEST(test_user_add_invalid) + irc_t *irc = torture_irc(); + user_t *user; + user = user_add(irc, ":foo"); + fail_unless(user == NULL); +END_TEST + +START_TEST(test_user_del_invalid) + irc_t *irc = torture_irc(); + fail_unless(user_del(irc, ":foo") == 0); +END_TEST + +START_TEST(test_user_del) + irc_t *irc = torture_irc(); + user_t *user; + user = user_add(irc, "foo"); + fail_unless(user_del(irc, "foo") == 1); + fail_unless(user_find(irc, "foo") == NULL); +END_TEST + +START_TEST(test_user_del_nonexistant) + irc_t *irc = torture_irc(); + fail_unless(user_del(irc, "foo") == 0); +END_TEST + +START_TEST(test_user_rename) + irc_t *irc = torture_irc(); + user_t *user; + user = user_add(irc, "foo"); + user_rename(irc, "foo", "bar"); + fail_unless(user_find(irc, "foo") == NULL); + fail_if(user_find(irc, "bar") == NULL); +END_TEST + +Suite *user_suite (void) +{ + Suite *s = suite_create("User"); + TCase *tc_core = tcase_create("Core"); + suite_add_tcase (s, tc_core); + tcase_add_test (tc_core, test_user_add); + tcase_add_test (tc_core, test_user_add_invalid); + tcase_add_test (tc_core, test_user_add_exists); + tcase_add_test (tc_core, test_user_del_invalid); + tcase_add_test (tc_core, test_user_del_nonexistant); + tcase_add_test (tc_core, test_user_del); + tcase_add_test (tc_core, test_user_rename); + return s; +} diff --git a/tests/testsuite.h b/tests/testsuite.h index dacaf8a3..79227041 100644 --- a/tests/testsuite.h +++ b/tests/testsuite.h @@ -1,6 +1,7 @@ #ifndef __BITLBEE_CHECK_H__ #define __BITLBEE_CHECK_H__ +irc_t *torture_irc(void); gboolean g_io_channel_pair(GIOChannel **ch1, GIOChannel **ch2); #endif /* __BITLBEE_CHECK_H__ */ -- cgit v1.2.3 From 8c073a6e77edd56bc3d58d6b4af2a40f005aacad Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 21 Jan 2007 22:38:50 +0100 Subject: Add testsuite for crypting. --- tests/Makefile | 2 +- tests/check.c | 4 ++++ tests/check_crypting.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 tests/check_crypting.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index b9da83c9..7c959890 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -10,7 +10,7 @@ clean: main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o -test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o check_help.o check_user.o +test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o check_help.o check_user.o check_crypting.o check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../lib/lib.o @echo '*' Linking $@ diff --git a/tests/check.c b/tests/check.c index 9fee07e3..bf76a89d 100644 --- a/tests/check.c +++ b/tests/check.c @@ -56,6 +56,9 @@ Suite *help_suite(void); /* From check_user.c */ Suite *user_suite(void); +/* From check_crypting.c */ +Suite *crypting_suite(void); + int main (int argc, char **argv) { int nf; @@ -98,6 +101,7 @@ int main (int argc, char **argv) srunner_add_suite(sr, irc_suite()); srunner_add_suite(sr, help_suite()); srunner_add_suite(sr, user_suite()); + srunner_add_suite(sr, crypting_suite()); if (no_fork) srunner_set_fork_status(sr, CK_NOFORK); srunner_run_all (sr, verbose?CK_VERBOSE:CK_NORMAL); diff --git a/tests/check_crypting.c b/tests/check_crypting.c new file mode 100644 index 00000000..b8e5e1e0 --- /dev/null +++ b/tests/check_crypting.c @@ -0,0 +1,47 @@ +#include +#include +#include +#include +#include +#include "bitlbee.h" +#include "crypting.h" +#include "testsuite.h" + +START_TEST(test_check_pass_valid) + fail_unless (checkpass ("foo", "acbd18db4cc2f85cedef654fccc4a4d8") == 0); + fail_unless (checkpass ("invalidpass", "acbd18db4cc2f85cedef654fccc4a4d8") == -1); + +END_TEST + +START_TEST(test_hashpass) + fail_unless (strcmp(hashpass("foo"), "acbd18db4cc2f85cedef654fccc4a4d8") == 0); +END_TEST + +START_TEST(test_obfucrypt) + char *raw = obfucrypt("some line", "bla"); + fail_unless(strcmp(raw, "\xd5\xdb\xce\xc7\x8c\xcd\xcb\xda\xc6") == 0); +END_TEST + +START_TEST(test_deobfucrypt) + char *raw = deobfucrypt("\xd5\xdb\xce\xc7\x8c\xcd\xcb\xda\xc6", "bla"); + fail_unless(strcmp(raw, "some line") == 0); +END_TEST + +START_TEST(test_obfucrypt_bidirectional) + char *plain = g_strdup("this is a line"); + char *raw = obfucrypt(plain, "foo"); + fail_unless(strcmp(plain, deobfucrypt(raw, "foo")) == 0); +END_TEST + +Suite *crypting_suite (void) +{ + Suite *s = suite_create("Crypting"); + TCase *tc_core = tcase_create("Core"); + suite_add_tcase (s, tc_core); + tcase_add_test (tc_core, test_check_pass_valid); + tcase_add_test (tc_core, test_hashpass); + tcase_add_test (tc_core, test_obfucrypt); + tcase_add_test (tc_core, test_deobfucrypt); + tcase_add_test (tc_core, test_obfucrypt_bidirectional); + return s; +} -- cgit v1.2.3 From 7738014d6a9ad81806ddb4e06092791dbd10b616 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 21 Jan 2007 23:08:56 +0100 Subject: Add tests for set --- tests/Makefile | 2 +- tests/check.c | 4 ++ tests/check_set.c | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/testsuite.h | 2 + 4 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 tests/check_set.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 7c959890..2c45354d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -10,7 +10,7 @@ clean: main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o -test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o check_help.o check_user.o check_crypting.o +test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o check_help.o check_user.o check_crypting.o check_set.o check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../lib/lib.o @echo '*' Linking $@ diff --git a/tests/check.c b/tests/check.c index bf76a89d..488d9608 100644 --- a/tests/check.c +++ b/tests/check.c @@ -59,6 +59,9 @@ Suite *user_suite(void); /* From check_crypting.c */ Suite *crypting_suite(void); +/* From check_set.c */ +Suite *set_suite(void); + int main (int argc, char **argv) { int nf; @@ -102,6 +105,7 @@ int main (int argc, char **argv) srunner_add_suite(sr, help_suite()); srunner_add_suite(sr, user_suite()); srunner_add_suite(sr, crypting_suite()); + srunner_add_suite(sr, set_suite()); if (no_fork) srunner_set_fork_status(sr, CK_NOFORK); srunner_run_all (sr, verbose?CK_VERBOSE:CK_NORMAL); diff --git a/tests/check_set.c b/tests/check_set.c new file mode 100644 index 00000000..b1ea973d --- /dev/null +++ b/tests/check_set.c @@ -0,0 +1,130 @@ +#include +#include +#include +#include +#include +#include "set.h" +#include "testsuite.h" + +START_TEST(test_set_add) + void *data = "data"; + set_t *s = NULL, *t; + t = set_add(&s, "name", "default", NULL, data); + fail_unless(s == t); + fail_unless(t->data == data); + fail_unless(strcmp(t->def, "default") == 0); +END_TEST + +START_TEST(test_set_add_existing) + void *data = "data"; + set_t *s = NULL, *t; + t = set_add(&s, "name", "default", NULL, data); + t = set_add(&s, "name", "newdefault", NULL, data); + fail_unless(s == t); + fail_unless(strcmp(t->def, "newdefault") == 0); +END_TEST + +START_TEST(test_set_find_unknown) + set_t *s = NULL, *t; + fail_unless (set_find(&s, "foo") == NULL); +END_TEST + +START_TEST(test_set_find) + void *data = "data"; + set_t *s = NULL, *t; + t = set_add(&s, "name", "default", NULL, data); + fail_unless(s == t); + fail_unless(set_find(&s, "name") == t); +END_TEST + +START_TEST(test_set_get_str_default) + void *data = "data"; + set_t *s = NULL, *t; + t = set_add(&s, "name", "default", NULL, data); + fail_unless(s == t); + fail_unless(strcmp(set_getstr(&s, "name"), "default") == 0); +END_TEST + +START_TEST(test_set_get_bool_default) + void *data = "data"; + set_t *s = NULL, *t; + t = set_add(&s, "name", "true", NULL, data); + fail_unless(s == t); + fail_unless(set_getbool(&s, "name")); +END_TEST + +START_TEST(test_set_get_bool_integer) + void *data = "data"; + set_t *s = NULL, *t; + t = set_add(&s, "name", "3", NULL, data); + fail_unless(s == t); + fail_unless(set_getbool(&s, "name") == 3); +END_TEST + +START_TEST(test_set_get_bool_unknown) + set_t *s = NULL; + fail_unless(set_getbool(&s, "name") == 0); +END_TEST + +START_TEST(test_set_get_str_value) + void *data = "data"; + set_t *s = NULL, *t; + t = set_add(&s, "name", "default", NULL, data); + set_setstr(&s, "name", "foo"); + fail_unless(strcmp(set_getstr(&s, "name"), "foo") == 0); +END_TEST + +START_TEST(test_set_get_str_unknown) + set_t *s = NULL; + fail_unless(set_getstr(&s, "name") == NULL); +END_TEST + +START_TEST(test_setint) + void *data = "data"; + set_t *s = NULL, *t; + t = set_add(&s, "name", "10", NULL, data); + set_setint(&s, "name", 3); + fail_unless(set_getint(&s, "name") == 3); +END_TEST + +START_TEST(test_setstr) + void *data = "data"; + set_t *s = NULL, *t; + t = set_add(&s, "name", "foo", NULL, data); + set_setstr(&s, "name", "bloe"); + fail_unless(strcmp(set_getstr(&s, "name"), "bloe") == 0); +END_TEST + +START_TEST(test_setstr_implicit) + void *data = "data"; + set_t *s = NULL, *t; + set_setstr(&s, "name", "bloe"); + fail_unless(set_find(&s, "name") != NULL); +END_TEST + +START_TEST(test_set_get_int_unknown) + set_t *s = NULL; + fail_unless(set_getint(&s, "foo") == 0); +END_TEST + +Suite *set_suite (void) +{ + Suite *s = suite_create("Set"); + TCase *tc_core = tcase_create("Core"); + suite_add_tcase (s, tc_core); + tcase_add_test (tc_core, test_set_add); + tcase_add_test (tc_core, test_set_add_existing); + tcase_add_test (tc_core, test_set_find_unknown); + tcase_add_test (tc_core, test_set_find); + tcase_add_test (tc_core, test_set_get_str_default); + tcase_add_test (tc_core, test_set_get_str_value); + tcase_add_test (tc_core, test_set_get_str_unknown); + tcase_add_test (tc_core, test_set_get_bool_default); + tcase_add_test (tc_core, test_set_get_bool_integer); + tcase_add_test (tc_core, test_set_get_bool_unknown); + tcase_add_test (tc_core, test_set_get_int_unknown); + tcase_add_test (tc_core, test_setint); + tcase_add_test (tc_core, test_setstr); + tcase_add_test (tc_core, test_setstr_implicit); + return s; +} diff --git a/tests/testsuite.h b/tests/testsuite.h index 79227041..0b169198 100644 --- a/tests/testsuite.h +++ b/tests/testsuite.h @@ -1,6 +1,8 @@ #ifndef __BITLBEE_CHECK_H__ #define __BITLBEE_CHECK_H__ +#include "irc.h" + irc_t *torture_irc(void); gboolean g_io_channel_pair(GIOChannel **ch1, GIOChannel **ch2); -- cgit v1.2.3 From dcf0f3e77ffd38ce3cc5d3c1eedfc655ff75a8f9 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 18 Feb 2007 22:46:50 +0000 Subject: Fixed Makefiles (make distclean was completely broken). --- tests/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 9dd3df7c..588bae61 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,4 +1,4 @@ -include ../Makefile.settings +-include ../Makefile.settings LFLAGS +=-lcheck @@ -8,6 +8,8 @@ all: check clean: rm -f check *.o +distclean: clean + main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o -- cgit v1.2.3 From 2305488d0a81193648dec7304f5a6a768e0c926b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 7 Oct 2007 22:45:41 +0100 Subject: Adding test for arc.c so that I can now safely replace the RC4 code with a (compatible) ArcFour implementation. --- tests/Makefile | 2 +- tests/check.c | 4 +++ tests/check_arc.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 tests/check_arc.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 4d4ed8d3..5bc3fbde 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -12,7 +12,7 @@ distclean: clean main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o -test_objs = check.o check_util.o check_nick.o check_md5.o check_irc.o check_help.o check_user.o check_crypting.o check_set.o +test_objs = check.o check_util.o check_nick.o check_md5.o check_arc.o check_irc.o check_help.o check_user.o check_crypting.o check_set.o check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../lib/lib.o @echo '*' Linking $@ diff --git a/tests/check.c b/tests/check.c index 488d9608..043889d6 100644 --- a/tests/check.c +++ b/tests/check.c @@ -47,6 +47,9 @@ Suite *nick_suite(void); /* From check_md5.c */ Suite *md5_suite(void); +/* From check_arc.c */ +Suite *arc_suite(void); + /* From check_irc.c */ Suite *irc_suite(void); @@ -101,6 +104,7 @@ int main (int argc, char **argv) sr = srunner_create(util_suite()); srunner_add_suite(sr, nick_suite()); srunner_add_suite(sr, md5_suite()); + srunner_add_suite(sr, arc_suite()); srunner_add_suite(sr, irc_suite()); srunner_add_suite(sr, help_suite()); srunner_add_suite(sr, user_suite()); diff --git a/tests/check_arc.c b/tests/check_arc.c new file mode 100644 index 00000000..a9bc2770 --- /dev/null +++ b/tests/check_arc.c @@ -0,0 +1,95 @@ +#include +#include +#include +#include +#include +#include +#include "arc.h" + +char *password = "TotT"; + +char *clear_tests[] = +{ + "Wie dit leest is gek :-)", + "ItllBeBitlBee", + "One more boring password", + NULL +}; + +static void check_codec(int l) +{ + int i; + + for( i = 0; clear_tests[i]; i++ ) + { + tcase_fn_start (clear_tests[i], __FILE__, __LINE__); + unsigned char *crypted; + char *decrypted; + int len; + + len = arc_encode( clear_tests[i], 0, &crypted, password ); + len = arc_decode( crypted, len, &decrypted, password ); + + fail_if( strcmp( clear_tests[i], decrypted ) != 0, + "%s didn't decrypt back properly", clear_tests[i] ); + + g_free( crypted ); + g_free( decrypted ); + } +} + +struct +{ + const unsigned char crypted[24]; + int len; + char *decrypted; +} decrypt_tests[] = { + { + { + 0xc3, 0x0d, 0x43, 0xc3, 0xee, 0x80, 0xe2, 0x8c, 0x0b, 0x29, 0x32, 0x7e, + 0x38, 0x05, 0x82, 0x10, 0x21, 0x1c, 0x4a, 0x00, 0x2c + }, 21, "Debugging sucks" + }, + { + { + 0xb0, 0x00, 0x57, 0x0d, 0x0d, 0x0d, 0x70, 0xe1, 0xc0, 0x00, 0xa4, 0x25, + 0x7d, 0xbe, 0x03, 0xcc, 0x24, 0xd1, 0x0c + }, 19, "Testing rocks" + }, + { + { + 0xb6, 0x92, 0x59, 0xe4, 0xf9, 0xc1, 0x7a, 0xf6, 0xf3, 0x18, 0xea, 0x28, + 0x73, 0x6d, 0xb3, 0x0a, 0x6f, 0x0a, 0x2b, 0x43, 0x57, 0xe9, 0x3e, 0x63 + }, 24, "OSCAR is creepy..." + } +}; + +static void check_decod(int l) +{ + int i; + + for( i = 0; clear_tests[i]; i++ ) + { + tcase_fn_start (decrypt_tests[i].decrypted, __FILE__, __LINE__); + char *decrypted; + int len; + + len = arc_decode( decrypt_tests[i].crypted, decrypt_tests[i].len, + &decrypted, password ); + + fail_if( strcmp( decrypt_tests[i].decrypted, decrypted ) != 0, + "%s didn't decrypt properly", clear_tests[i] ); + + g_free( decrypted ); + } +} + +Suite *arc_suite (void) +{ + Suite *s = suite_create("ArcFour"); + TCase *tc_core = tcase_create("Core"); + suite_add_tcase (s, tc_core); + tcase_add_test (tc_core, check_codec); + tcase_add_test (tc_core, check_decod); + return s; +} -- cgit v1.2.3 From e2869bf14ee7aca93d29edd142d60a7184b4d449 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 7 Oct 2007 23:07:25 +0100 Subject: "Changed" the ArcFour implementation. I'm afraid this was a waste of time, but at least I added a neat unittest... --- tests/check_arc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/check_arc.c b/tests/check_arc.c index a9bc2770..989a0a66 100644 --- a/tests/check_arc.c +++ b/tests/check_arc.c @@ -40,7 +40,7 @@ static void check_codec(int l) struct { - const unsigned char crypted[24]; + unsigned char crypted[24]; int len; char *decrypted; } decrypt_tests[] = { -- cgit v1.2.3 From d444c09e6c7ac6fc3c1686af0e63c09805d8cd00 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 12 Oct 2007 01:06:50 +0100 Subject: Added word_wrap() function to misc.c and using it at the right places so that long messages in groupchats also get wrapped properly (instead of truncated). --- tests/check_util.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'tests') diff --git a/tests/check_util.c b/tests/check_util.c index 284ddba3..b00d645b 100644 --- a/tests/check_util.c +++ b/tests/check_util.c @@ -103,6 +103,63 @@ START_TEST(test_set_url_username_pwd) fail_unless (url.port == 1080); END_TEST +struct +{ + char *orig; + int line_len; + char *wrapped; +} word_wrap_tests[] = { + { + "Line-wrapping is not as easy as it seems?", + 16, + "Line-wrapping is\nnot as easy as\nit seems?" + }, + { + "Line-wrapping is not as easy as it seems?", + 8, + "Line-\nwrapping\nis not\nas easy\nas it\nseems?" + }, + { + "Line-wrapping is\nnot as easy as it seems?", + 8, + "Line-\nwrapping\nis\nnot as\neasy as\nit\nseems?" + }, + { + "a aa aaa aaaa aaaaa aaaaaa aaaaaaa aaaaaaaa", + 5, + "a aa\naaa\naaaa\naaaaa\naaaaa\na\naaaaa\naa\naaaaa\naaa", + }, + { + "aaaaaaaa aaaaaaa aaaaaa aaaaa aaaa aaa aa a", + 5, + "aaaaa\naaa\naaaaa\naa\naaaaa\na\naaaaa\naaaa\naaa\naa a", + }, + { + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + 5, + "aaaaa\naaaaa\naaaaa\naaaaa\naaaaa\naaaaa\naaaaa\na", + }, + { + NULL + } +}; + +START_TEST(test_word_wrap) + int i; + + for( i = 0; word_wrap_tests[i].orig && *word_wrap_tests[i].orig; i ++ ) + { + char *wrapped = word_wrap( word_wrap_tests[i].orig, word_wrap_tests[i].line_len ); + + fail_unless( strcmp( word_wrap_tests[i].wrapped, wrapped ) == 0, + "%s (line_len = %d) should wrap to `%s', not to `%s'", + word_wrap_tests[i].orig, word_wrap_tests[i].line_len, + word_wrap_tests[i].wrapped, wrapped ); + + g_free( wrapped ); + } +END_TEST + Suite *util_suite (void) { Suite *s = suite_create("Util"); @@ -115,5 +172,6 @@ Suite *util_suite (void) tcase_add_test (tc_core, test_set_url_port); tcase_add_test (tc_core, test_set_url_username); tcase_add_test (tc_core, test_set_url_username_pwd); + tcase_add_test (tc_core, test_word_wrap); return s; } -- cgit v1.2.3 From 0f47613a39ad1b5d22d187e63c80c2f70702c217 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 10 Dec 2007 22:57:13 +0000 Subject: Don't allow nicks that start with a number. --- tests/check_nick.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/check_nick.c b/tests/check_nick.c index 714c4fdc..6c4267cd 100644 --- a/tests/check_nick.c +++ b/tests/check_nick.c @@ -14,11 +14,17 @@ START_TEST(test_nick_strip) "thisisaveryveryveryverylongnick", "thisisave:ryveryveryverylongnick", "t::::est", + "test123", + "123test", + "123", NULL }; const char *expected[] = { "test", "test", "test", "thisisaveryveryveryveryl", "thisisaveryveryveryveryl", "test", + "test123", + "_123test", + "_123", NULL }; for (i = 0; get[i]; i++) { @@ -34,8 +40,8 @@ END_TEST START_TEST(test_nick_ok_ok) { - const char *nicks[] = { "foo", "bar", "bla[", "blie]", - "BreEZaH", "\\od^~", NULL }; + const char *nicks[] = { "foo", "bar123", "bla[", "blie]", "BreEZaH", + "\\od^~", "_123", "_123test", NULL }; int i; for (i = 0; nicks[i]; i++) { @@ -48,7 +54,7 @@ END_TEST START_TEST(test_nick_ok_notok) { const char *nicks[] = { "thisisaveryveryveryveryveryveryverylongnick", - "\nillegalchar", "", "nick%", NULL }; + "\nillegalchar", "", "nick%", "123test", NULL }; int i; for (i = 0; nicks[i]; i++) { -- cgit v1.2.3 From 2799ff94059f496b59420d04ec4f41f67aab2b9d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 16 Feb 2008 12:20:03 +0000 Subject: Fixed broken check in check_arc.c --- tests/check_arc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/check_arc.c b/tests/check_arc.c index 989a0a66..a430f899 100644 --- a/tests/check_arc.c +++ b/tests/check_arc.c @@ -61,14 +61,15 @@ struct 0xb6, 0x92, 0x59, 0xe4, 0xf9, 0xc1, 0x7a, 0xf6, 0xf3, 0x18, 0xea, 0x28, 0x73, 0x6d, 0xb3, 0x0a, 0x6f, 0x0a, 0x2b, 0x43, 0x57, 0xe9, 0x3e, 0x63 }, 24, "OSCAR is creepy..." - } + }, + { "", 0, NULL } }; static void check_decod(int l) { int i; - for( i = 0; clear_tests[i]; i++ ) + for( i = 0; decrypt_tests[i].len; i++ ) { tcase_fn_start (decrypt_tests[i].decrypted, __FILE__, __LINE__); char *decrypted; -- cgit v1.2.3 From af97b234ad86fb9d69aa744af426591e4b1eaf97 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 16 Feb 2008 13:17:52 +0000 Subject: Improved sasl_get_part() to deal with whitespace in challenge strings, as described in RFC 2831 secion 7.1 (the #rule description). Closes bug #362. --- tests/Makefile | 4 +- tests/check.c | 4 ++ tests/check_jabber_sasl.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 tests/check_jabber_sasl.c (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 5bc3fbde..ae76fef5 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -10,9 +10,9 @@ clean: distclean: clean -main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o +main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o -test_objs = check.o check_util.o check_nick.o check_md5.o check_arc.o check_irc.o check_help.o check_user.o check_crypting.o check_set.o +test_objs = check.o check_util.o check_nick.o check_md5.o check_arc.o check_irc.o check_help.o check_user.o check_crypting.o check_set.o check_jabber_sasl.o check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../lib/lib.o @echo '*' Linking $@ diff --git a/tests/check.c b/tests/check.c index 043889d6..b3ffb957 100644 --- a/tests/check.c +++ b/tests/check.c @@ -65,6 +65,9 @@ Suite *crypting_suite(void); /* From check_set.c */ Suite *set_suite(void); +/* From check_jabber_sasl.c */ +Suite *jabber_sasl_suite(void); + int main (int argc, char **argv) { int nf; @@ -110,6 +113,7 @@ int main (int argc, char **argv) srunner_add_suite(sr, user_suite()); srunner_add_suite(sr, crypting_suite()); srunner_add_suite(sr, set_suite()); + srunner_add_suite(sr, jabber_sasl_suite()); if (no_fork) srunner_set_fork_status(sr, CK_NOFORK); srunner_run_all (sr, verbose?CK_VERBOSE:CK_NORMAL); diff --git a/tests/check_jabber_sasl.c b/tests/check_jabber_sasl.c new file mode 100644 index 00000000..96c05837 --- /dev/null +++ b/tests/check_jabber_sasl.c @@ -0,0 +1,117 @@ +#include +#include +#include +#include +#include +#include +#include "arc.h" + +char *sasl_get_part( char *data, char *field ); + +#define challenge1 "nonce=\"1669585310\",qop=\"auth\",charset=utf-8,algorithm=md5-sess," \ + "something=\"Not \\\"standardized\\\"\"" +#define challenge2 "realm=\"quadpoint.org\", nonce=\"NPotlQpQf9RNYodOwierkQ==\", " \ + "qop=\"auth, auth-int\", charset=utf-8, algorithm=md5-sess" +#define challenge3 ", realm=\"localhost\", nonce=\"LlBV2txnO8RbB5hgs3KgiQ==\", " \ + "qop=\"auth, auth-int, \", ,\n, charset=utf-8, algorithm=md5-sess," + +struct +{ + const char *challenge; + char *key; + char *value; +} get_part_tests[] = { + { + challenge1, + "nonce", + "1669585310" + }, + { + challenge1, + "charset", + "utf-8" + }, + { + challenge1, + "harset", + NULL + }, + { + challenge1, + "something", + "Not \"standardized\"" + }, + { + challenge1, + "something_else", + NULL + }, + { + challenge2, + "realm", + "quadpoint.org", + }, + { + challenge2, + "real", + NULL + }, + { + challenge2, + "qop", + "auth, auth-int" + }, + { + challenge3, + "realm", + "localhost" + }, + { + challenge3, + "qop", + "auth, auth-int, " + }, + { + challenge3, + "charset", + "utf-8" + }, + { NULL, NULL, NULL } +}; + +static void check_get_part(int l) +{ + int i; + + for( i = 0; get_part_tests[i].key; i++ ) + { + tcase_fn_start( get_part_tests[i].key, __FILE__, i ); + char *res; + int len; + + res = sasl_get_part( get_part_tests[i].challenge, + get_part_tests[i].key ); + + if( get_part_tests[i].value == NULL ) + fail_if( res != NULL, "Found key %s in %s while it shouldn't be there!", + get_part_tests[i].key, get_part_tests[i].challenge ); + else if( res ) + fail_unless( strcmp( res, get_part_tests[i].value ) == 0, + "Incorrect value for key %s in %s: %s", + get_part_tests[i].key, get_part_tests[i].challenge, res ); + else + fail( "Could not find key %s in %s", + get_part_tests[i].key, get_part_tests[i].challenge ); + + g_free( res ); + } +} + +Suite *jabber_sasl_suite (void) +{ + Suite *s = suite_create("jabber/sasl"); + TCase *tc_core = tcase_create("Core"); + suite_add_tcase (s, tc_core); + tcase_add_test (tc_core, check_get_part); + return s; +} -- cgit v1.2.3 From 2d88d25aeb62d90e4288f8b83979baaff96cb7f2 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 16 Feb 2008 19:38:17 +0000 Subject: Added help_free() test, and fixed compiler warning in SASL test. --- tests/check_help.c | 7 +++++-- tests/check_jabber_sasl.c | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/check_help.c b/tests/check_help.c index 7e5283e3..5a2f28d9 100644 --- a/tests/check_help.c +++ b/tests/check_help.c @@ -6,11 +6,14 @@ #include #include "help.h" -START_TEST(test_help_none) +START_TEST(test_help_initfree) help_t *h, *r; r = help_init(&h, "/dev/null"); fail_if(r == NULL); fail_if(r != h); + + help_free(&h); + fail_if(h != NULL); END_TEST START_TEST(test_help_nonexistent) @@ -24,7 +27,7 @@ Suite *help_suite (void) Suite *s = suite_create("Help"); TCase *tc_core = tcase_create("Core"); suite_add_tcase (s, tc_core); - tcase_add_test (tc_core, test_help_none); + tcase_add_test (tc_core, test_help_initfree); tcase_add_test (tc_core, test_help_nonexistent); return s; } diff --git a/tests/check_jabber_sasl.c b/tests/check_jabber_sasl.c index 96c05837..6bceeb88 100644 --- a/tests/check_jabber_sasl.c +++ b/tests/check_jabber_sasl.c @@ -17,7 +17,7 @@ char *sasl_get_part( char *data, char *field ); struct { - const char *challenge; + char *challenge; char *key; char *value; } get_part_tests[] = { -- cgit v1.2.3 From ddcf491fa460fea612c240589c50da864dad6668 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 16 Mar 2008 14:18:22 +0000 Subject: Adding padding to encrypted IM-passwords so the exact password length can't be guessed from the encrypted data anymore. --- tests/check_arc.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/check_arc.c b/tests/check_arc.c index a430f899..9d913dcd 100644 --- a/tests/check_arc.c +++ b/tests/check_arc.c @@ -6,13 +6,14 @@ #include #include "arc.h" -char *password = "TotT"; +char *password = "ArcVier"; char *clear_tests[] = { "Wie dit leest is gek :-)", "ItllBeBitlBee", "One more boring password", + "Hoi hoi", NULL }; @@ -27,7 +28,7 @@ static void check_codec(int l) char *decrypted; int len; - len = arc_encode( clear_tests[i], 0, &crypted, password ); + len = arc_encode( clear_tests[i], 0, &crypted, password, 12 ); len = arc_decode( crypted, len, &decrypted, password ); fail_if( strcmp( clear_tests[i], decrypted ) != 0, @@ -40,27 +41,35 @@ static void check_codec(int l) struct { - unsigned char crypted[24]; + unsigned char crypted[30]; int len; char *decrypted; } decrypt_tests[] = { + /* One block with padding. */ { { - 0xc3, 0x0d, 0x43, 0xc3, 0xee, 0x80, 0xe2, 0x8c, 0x0b, 0x29, 0x32, 0x7e, - 0x38, 0x05, 0x82, 0x10, 0x21, 0x1c, 0x4a, 0x00, 0x2c - }, 21, "Debugging sucks" + 0x3f, 0x79, 0xb0, 0xf5, 0x91, 0x56, 0xd2, 0x1b, 0xd1, 0x4b, 0x67, 0xac, + 0xb1, 0x31, 0xc9, 0xdb, 0xf9, 0xaa + }, 18, "short pass" }, + + /* Two blocks with padding. */ { { - 0xb0, 0x00, 0x57, 0x0d, 0x0d, 0x0d, 0x70, 0xe1, 0xc0, 0x00, 0xa4, 0x25, - 0x7d, 0xbe, 0x03, 0xcc, 0x24, 0xd1, 0x0c - }, 19, "Testing rocks" + 0xf9, 0xa6, 0xec, 0x5d, 0xc7, 0x06, 0xb8, 0x6b, 0x63, 0x9f, 0x2d, 0xb5, + 0x7d, 0xaa, 0x32, 0xbb, 0xd8, 0x08, 0xfd, 0x81, 0x2e, 0xca, 0xb4, 0xd7, + 0x2f, 0x36, 0x9c, 0xac, 0xa0, 0xbc + }, 30, "longer password" }, + + /* This string is exactly two "blocks" long, to make sure unpadded strings also decrypt + properly. */ { { - 0xb6, 0x92, 0x59, 0xe4, 0xf9, 0xc1, 0x7a, 0xf6, 0xf3, 0x18, 0xea, 0x28, - 0x73, 0x6d, 0xb3, 0x0a, 0x6f, 0x0a, 0x2b, 0x43, 0x57, 0xe9, 0x3e, 0x63 - }, 24, "OSCAR is creepy..." + 0x95, 0x4d, 0xcf, 0x4d, 0x5e, 0x6c, 0xcf, 0xef, 0xb9, 0x80, 0x00, 0xef, + 0x25, 0xe9, 0x17, 0xf6, 0x29, 0x6a, 0x82, 0x79, 0x1c, 0xca, 0x68, 0xb5, + 0x4e, 0xd0, 0xc1, 0x41, 0x8e, 0xe6 + }, 30, "OSCAR is really creepy.." }, { "", 0, NULL } }; @@ -79,7 +88,7 @@ static void check_decod(int l) &decrypted, password ); fail_if( strcmp( decrypt_tests[i].decrypted, decrypted ) != 0, - "%s didn't decrypt properly", clear_tests[i] ); + "`%s' didn't decrypt properly", decrypt_tests[i].decrypted ); g_free( decrypted ); } -- cgit v1.2.3 From 18ff38fad0d6d47853fb43ec5a99b29ba031a8ca Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 29 Mar 2008 23:15:04 +0000 Subject: Be more liberal with accepted line endings. ERC on Windows likes to use "\r\r\n", for example, and until now BitlBee only chopped off the \r\n, leaving the first \r as part of the command, which means it couldn't log in to BitlBee at all. (Bad character in nickname.) --- tests/check_irc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/check_irc.c b/tests/check_irc.c index c1cf05a5..66fe0021 100644 --- a/tests/check_irc.c +++ b/tests/check_irc.c @@ -36,8 +36,8 @@ START_TEST(test_login) irc = irc_new(g_io_channel_unix_get_fd(ch1)); - fail_unless(g_io_channel_write_chars(ch2, "NICK bla\r\n" - "USER a a a a\r\n", -1, NULL, NULL) == G_IO_STATUS_NORMAL); + fail_unless(g_io_channel_write_chars(ch2, "NICK bla\r\r\n" + "USER a a a a\n", -1, NULL, NULL) == G_IO_STATUS_NORMAL); fail_unless(g_io_channel_flush(ch2, NULL) == G_IO_STATUS_NORMAL); g_main_iteration(FALSE); -- cgit v1.2.3