annotate libpurple/tests/check_libpurple.c @ 22615:0f8fe131008a

Make ./configure fail immediately if requirements for enabled options are not met. This should provide more reproducible feature sets for users instead of picking up what development packages happen to be installed when they compile. Options can of course be disabled with the --disable-XXX arguments. Some of the cases that this will now fail on by default may not be considered essential, if people feel that about any of them then we should switch the features to disabled by default.
author Stu Tomlinson <stu@nosnilmot.com>
date Wed, 02 Apr 2008 16:45:07 +0000
parents fb73a6ed8197
children 6c015d2764d3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15805
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
21804
fb73a6ed8197 A couple compile fixes to the tests from Elliott Sales de Andrade. Fixes #4313.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18368
diff changeset
4 #include "tests.h"
fb73a6ed8197 A couple compile fixes to the tests from Elliott Sales de Andrade. Fixes #4313.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18368
diff changeset
5
15805
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
6 #include "../core.h"
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
7 #include "../eventloop.h"
15888
6577b292e7b4 Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
8 #include "../util.h"
15805
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 /******************************************************************************
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
12 * libpurple goodies
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
13 *****************************************************************************/
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
14 static guint
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15805
diff changeset
15 purple_check_input_add(gint fd, PurpleInputCondition condition,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15805
diff changeset
16 PurpleInputFunction function, gpointer data)
15805
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
17 {
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
18 /* 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
19 return 0;
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
20 }
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
21
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15805
diff changeset
22 static PurpleEventLoopUiOps eventloop_ui_ops = {
15805
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
23 g_timeout_add,
18368
743ff8e14b17 Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents: 16526
diff changeset
24 g_source_remove,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15805
diff changeset
25 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: 16526
diff changeset
26 g_source_remove,
743ff8e14b17 Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents: 16526
diff changeset
27 NULL, /* input_get_error */
743ff8e14b17 Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents: 16526
diff changeset
28 #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: 16526
diff changeset
29 g_timeout_add_seconds,
743ff8e14b17 Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents: 16526
diff changeset
30 #else
743ff8e14b17 Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents: 16526
diff changeset
31 NULL,
743ff8e14b17 Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents: 16526
diff changeset
32 #endif
743ff8e14b17 Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents: 16526
diff changeset
33 NULL,
743ff8e14b17 Fix warnings and add a call to g_timeout_add_seconds() just because.
Richard Laager <rlaager@wiktel.com>
parents: 16526
diff changeset
34 NULL,
15888
6577b292e7b4 Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
35 NULL
15805
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
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
38 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15805
diff changeset
39 purple_check_init(void) {
15805
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
40 gchar *home_dir;
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
41
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15805
diff changeset
42 purple_eventloop_set_ui_ops(&eventloop_ui_ops);
15805
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
43
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
44 /* build our fake home directory */
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
45 home_dir = g_build_path(BUILDDIR, "libpurple", "tests", "home", NULL);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15805
diff changeset
46 purple_util_set_user_dir(home_dir);
15805
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
47 g_free(home_dir);
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
48
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15805
diff changeset
49 purple_core_init("check");
15805
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 /******************************************************************************
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
53 * Check meat and potatoes
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
54 *****************************************************************************/
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
55 Suite*
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
56 master_suite(void)
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
57 {
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
58 Suite *s = suite_create("Master Suite");
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
59
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
60 return s;
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
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
63 int main(void)
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
64 {
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
65 int number_failed;
16526
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: 15888
diff changeset
66 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: 15888
diff changeset
67
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: 15888
diff changeset
68 /* 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: 15888
diff changeset
69 * 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: 15888
diff changeset
70 * 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: 15888
diff changeset
71 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: 15888
diff changeset
72
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: 15888
diff changeset
73 sr = srunner_create (master_suite());
15805
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
74
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
75 srunner_add_suite(sr, cipher_suite());
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
76 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
77 srunner_add_suite(sr, util_suite());
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
78
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
79 /* make this a libpurple "ui" */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15805
diff changeset
80 purple_check_init();
15805
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
81
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
82 srunner_run_all (sr, CK_NORMAL);
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
83 number_failed = srunner_ntests_failed (sr);
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
84 srunner_free (sr);
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
85
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15805
diff changeset
86 purple_core_quit();
15805
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
87
a0a5e323a6ac libpurplify the 'make check' tests so they work again
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
88 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
89 }