Mercurial > pidgin.yaz
annotate libpurple/tests/check_libpurple.c @ 18417:579ba9866882
merge of '2c61c0960a48cb258fd0a3c93727265ec78e7809'
and 'efa0e31922a07bb598a6fc8951462e1fa96a886e'
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 02 Jul 2007 22:59:10 +0000 |
parents | 743ff8e14b17 |
children | fb73a6ed8197 |
rev | line source |
---|---|
15806
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
1 #include <glib.h> |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
2 #include <stdlib.h> |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
3 |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
4 #include "../core.h" |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
5 #include "../eventloop.h" |
15889
6577b292e7b4
Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
6 #include "../util.h" |
15806
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
7 |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
8 #include "tests.h" |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
9 |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
10 /****************************************************************************** |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
11 * libpurple goodies |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
12 *****************************************************************************/ |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
13 static guint |
15823 | 14 purple_check_input_add(gint fd, PurpleInputCondition condition, |
15 PurpleInputFunction function, gpointer data) | |
15806
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
16 { |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
17 /* this is a no-op for now, feel free to implement it */ |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
18 return 0; |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
19 } |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
20 |
15823 | 21 static PurpleEventLoopUiOps eventloop_ui_ops = { |
15806
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
22 g_timeout_add, |
18368
743ff8e14b17
Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents:
16534
diff
changeset
|
23 g_source_remove, |
15823 | 24 purple_check_input_add, |
18368
743ff8e14b17
Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents:
16534
diff
changeset
|
25 g_source_remove, |
743ff8e14b17
Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents:
16534
diff
changeset
|
26 NULL, /* input_get_error */ |
743ff8e14b17
Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents:
16534
diff
changeset
|
27 #if GLIB_CHECK_VERSION(2,14,0) |
743ff8e14b17
Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents:
16534
diff
changeset
|
28 g_timeout_add_seconds, |
743ff8e14b17
Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents:
16534
diff
changeset
|
29 #else |
743ff8e14b17
Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents:
16534
diff
changeset
|
30 NULL, |
743ff8e14b17
Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents:
16534
diff
changeset
|
31 #endif |
743ff8e14b17
Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents:
16534
diff
changeset
|
32 NULL, |
743ff8e14b17
Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents:
16534
diff
changeset
|
33 NULL, |
15889
6577b292e7b4
Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
34 NULL |
15806
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
35 }; |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
36 |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
37 static void |
15823 | 38 purple_check_init(void) { |
15806
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
39 gchar *home_dir; |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
40 |
15823 | 41 purple_eventloop_set_ui_ops(&eventloop_ui_ops); |
15806
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
42 |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
43 /* build our fake home directory */ |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
44 home_dir = g_build_path(BUILDDIR, "libpurple", "tests", "home", NULL); |
15823 | 45 purple_util_set_user_dir(home_dir); |
15806
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
46 g_free(home_dir); |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
47 |
15823 | 48 purple_core_init("check"); |
15806
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
49 } |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
50 |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
51 /****************************************************************************** |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
52 * Check meat and potatoes |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
53 *****************************************************************************/ |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
54 Suite* |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
55 master_suite(void) |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
56 { |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
57 Suite *s = suite_create("Master Suite"); |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
58 |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
59 return s; |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
60 } |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
61 |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
62 int main(void) |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
63 { |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
64 int number_failed; |
16534
32188b6d2db8
Use fatal asserts unconditionally in the test code. Perhaps this could be better integrated in some way, but this works.
Richard Laager <rlaager@wiktel.com>
parents:
15889
diff
changeset
|
65 SRunner *sr; |
32188b6d2db8
Use fatal asserts unconditionally in the test code. Perhaps this could be better integrated in some way, but this works.
Richard Laager <rlaager@wiktel.com>
parents:
15889
diff
changeset
|
66 |
32188b6d2db8
Use fatal asserts unconditionally in the test code. Perhaps this could be better integrated in some way, but this works.
Richard Laager <rlaager@wiktel.com>
parents:
15889
diff
changeset
|
67 /* Make g_return_... functions fatal, ALWAYS. |
32188b6d2db8
Use fatal asserts unconditionally in the test code. Perhaps this could be better integrated in some way, but this works.
Richard Laager <rlaager@wiktel.com>
parents:
15889
diff
changeset
|
68 * As this is the test code, this is NOT controlled |
32188b6d2db8
Use fatal asserts unconditionally in the test code. Perhaps this could be better integrated in some way, but this works.
Richard Laager <rlaager@wiktel.com>
parents:
15889
diff
changeset
|
69 * by PURPLE_FATAL_ASSERTS. */ |
32188b6d2db8
Use fatal asserts unconditionally in the test code. Perhaps this could be better integrated in some way, but this works.
Richard Laager <rlaager@wiktel.com>
parents:
15889
diff
changeset
|
70 g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL); |
32188b6d2db8
Use fatal asserts unconditionally in the test code. Perhaps this could be better integrated in some way, but this works.
Richard Laager <rlaager@wiktel.com>
parents:
15889
diff
changeset
|
71 |
32188b6d2db8
Use fatal asserts unconditionally in the test code. Perhaps this could be better integrated in some way, but this works.
Richard Laager <rlaager@wiktel.com>
parents:
15889
diff
changeset
|
72 sr = srunner_create (master_suite()); |
15806
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
73 |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
74 srunner_add_suite(sr, cipher_suite()); |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
75 srunner_add_suite(sr, jabber_jutil_suite()); |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
76 srunner_add_suite(sr, util_suite()); |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
77 |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
78 /* make this a libpurple "ui" */ |
15823 | 79 purple_check_init(); |
15806
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
80 |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
81 srunner_run_all (sr, CK_NORMAL); |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
82 number_failed = srunner_ntests_failed (sr); |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
83 srunner_free (sr); |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
84 |
15823 | 85 purple_core_quit(); |
15806
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
86 |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
87 return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; |
a0a5e323a6ac
libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
88 } |