This source file includes following definitions.
- test_for_pcmk_rc_name
- test_for_pcmk_rc_str
- test_for_crm_exit_name
- test_for_crm_exit_str
- test_for_pcmk_rc2exitc
- test_for_bz2_strerror
- main
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <stdarg.h>
13 #include <stddef.h>
14 #include <stdint.h>
15 #include <setjmp.h>
16 #include <cmocka.h>
17
18 #include <glib.h>
19 #include <bzlib.h>
20
21 static void
22 test_for_pcmk_rc_name(void **state) {
23 assert_string_equal(pcmk_rc_name(pcmk_rc_error-1), "pcmk_rc_unknown_format");
24 assert_string_equal(pcmk_rc_name(pcmk_rc_ok), "pcmk_rc_ok");
25 assert_string_equal(pcmk_rc_name(pcmk_rc_ok), "pcmk_rc_ok");
26 assert_string_equal(pcmk_rc_name(-7777777), "Unknown");
27 }
28
29 static void
30 test_for_pcmk_rc_str(void **state) {
31 assert_string_equal(pcmk_rc_str(pcmk_rc_error-1), "Unknown output format");
32 assert_string_equal(pcmk_rc_str(pcmk_rc_ok), "OK");
33 assert_string_equal(pcmk_rc_str(-1), "Error");
34 }
35
36 static void
37 test_for_crm_exit_name(void **state) {
38 assert_string_equal(crm_exit_name(CRM_EX_OK), "CRM_EX_OK");
39 }
40
41 static void
42 test_for_crm_exit_str(void **state) {
43 assert_string_equal(crm_exit_str(CRM_EX_OK), "OK");
44 assert_string_equal(crm_exit_str(129), "Interrupted by signal");
45 assert_string_equal(crm_exit_str(-7777777), "Unknown exit status");
46 }
47
48 static void
49 test_for_pcmk_rc2exitc(void **state) {
50 assert_int_equal(pcmk_rc2exitc(pcmk_rc_ok), CRM_EX_OK);
51 assert_int_equal(pcmk_rc2exitc(-7777777), CRM_EX_ERROR);
52 }
53
54 static void
55 test_for_bz2_strerror(void **state) {
56 assert_string_equal(bz2_strerror(BZ_STREAM_END), "Ok");
57 }
58
59 int main(int argc, char **argv) {
60 const struct CMUnitTest tests[] = {
61 cmocka_unit_test(test_for_pcmk_rc_name),
62 cmocka_unit_test(test_for_pcmk_rc_str),
63 cmocka_unit_test(test_for_crm_exit_name),
64 cmocka_unit_test(test_for_crm_exit_str),
65 cmocka_unit_test(test_for_pcmk_rc2exitc),
66 cmocka_unit_test(test_for_bz2_strerror),
67 };
68
69 cmocka_set_message_output(CM_OUTPUT_TAP);
70 return cmocka_run_group_tests(tests, NULL, NULL);
71 }