This source file includes following definitions.
- simple_compress
- max_too_small
- 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 #define SIMPLE_DATA "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
19
20 const char *SIMPLE_COMPRESSED = "BZh41AY&SYO\x1ai";
21
22 static void
23 simple_compress(void **state)
24 {
25 char *result = calloc(1024, sizeof(char));
26 unsigned int len;
27
28 assert_int_equal(pcmk__compress(SIMPLE_DATA, 40, 0, &result, &len), pcmk_rc_ok);
29 assert_memory_equal(result, SIMPLE_COMPRESSED, 13);
30 }
31
32 static void
33 max_too_small(void **state)
34 {
35 char *result = calloc(1024, sizeof(char));
36 unsigned int len;
37
38 assert_int_equal(pcmk__compress(SIMPLE_DATA, 40, 10, &result, &len), pcmk_rc_error);
39 }
40
41 int
42 main(int argc, char **argv)
43 {
44 const struct CMUnitTest tests[] = {
45 cmocka_unit_test(simple_compress),
46 cmocka_unit_test(max_too_small),
47 };
48
49 cmocka_set_message_output(CM_OUTPUT_TAP);
50 return cmocka_run_group_tests(tests, NULL, NULL);
51 }