Remove useless comparison
[pidgin-git.git] / libpurple / tests / check_libpurple.c
blobace7d1eb9d7b9746c6ac6c16055b975142116858
1 #include <glib.h>
2 #include <stdlib.h>
4 #include "tests.h"
6 #include "../core.h"
7 #include "../eventloop.h"
8 #include "../util.h"
11 /******************************************************************************
12 * libpurple goodies
13 *****************************************************************************/
14 static guint
15 purple_check_input_add(gint fd, PurpleInputCondition condition,
16 PurpleInputFunction function, gpointer data)
18 /* this is a no-op for now, feel free to implement it */
19 return 0;
22 static PurpleEventLoopUiOps eventloop_ui_ops = {
23 g_timeout_add,
24 g_source_remove,
25 purple_check_input_add,
26 g_source_remove,
27 NULL, /* input_get_error */
28 #if GLIB_CHECK_VERSION(2,14,0)
29 g_timeout_add_seconds,
30 #else
31 NULL,
32 #endif
33 NULL,
34 NULL,
35 NULL
38 static void
39 purple_check_init(void) {
40 #if !GLIB_CHECK_VERSION(2, 36, 0)
41 /* GLib type system is automaticaly initialized since 2.36. */
42 g_type_init();
43 #endif
45 purple_eventloop_set_ui_ops(&eventloop_ui_ops);
47 #if 0
48 /* build our fake home directory */
50 gchar *home_dir;
52 home_dir = g_build_path(G_DIR_SEPARATOR_S, BUILDDIR, "libpurple", "tests", "home", NULL);
53 purple_util_set_user_dir(home_dir);
54 g_free(home_dir);
56 #else
57 purple_util_set_user_dir("/dev/null");
58 #endif
60 purple_core_init("check");
63 /******************************************************************************
64 * Check meat and potatoes
65 *****************************************************************************/
66 Suite*
67 master_suite(void)
69 Suite *s = suite_create("Master Suite");
71 return s;
74 int main(void)
76 int number_failed;
77 SRunner *sr;
79 if (g_getenv("PURPLE_CHECK_DEBUG"))
80 purple_debug_set_enabled(TRUE);
82 /* Make g_return_... functions fatal, ALWAYS.
83 * As this is the test code, this is NOT controlled
84 * by PURPLE_FATAL_ASSERTS. */
85 g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
87 sr = srunner_create (master_suite());
89 srunner_add_suite(sr, cipher_suite());
90 srunner_add_suite(sr, jabber_caps_suite());
91 srunner_add_suite(sr, jabber_digest_md5_suite());
92 srunner_add_suite(sr, jabber_jutil_suite());
93 srunner_add_suite(sr, jabber_scram_suite());
94 srunner_add_suite(sr, oscar_util_suite());
95 srunner_add_suite(sr, util_suite());
96 srunner_add_suite(sr, xmlnode_suite());
98 /* make this a libpurple "ui" */
99 purple_check_init();
101 srunner_run_all (sr, CK_NORMAL);
102 number_failed = srunner_ntests_failed (sr);
103 srunner_free (sr);
105 purple_core_quit();
107 return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;