This source file includes following definitions.
- calloc_fails
- calloc_succeeds
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <crm/common/unittest_internal.h>
13 #include <crm/pengine/internal.h>
14
15 #include "mock_private.h"
16
17 static void
18 calloc_fails(void **state) {
19 pcmk__mock_calloc = true;
20
21 expect_value(__wrap_calloc, nmemb, 1);
22 expect_value(__wrap_calloc, size, sizeof(pe_working_set_t));
23 assert_null(pe_new_working_set());
24
25 pcmk__mock_calloc = false;
26 }
27
28 static void
29 calloc_succeeds(void **state) {
30 pe_working_set_t *data_set = pe_new_working_set();
31
32
33
34
35
36 assert_non_null(data_set);
37
38
39
40
41 free(data_set);
42 }
43
44 PCMK__UNIT_TEST(NULL, NULL,
45 cmocka_unit_test(calloc_fails),
46 cmocka_unit_test(calloc_succeeds))