pacemaker
2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
lib
pengine
tests
status
pe_new_working_set_test.c
Go to the documentation of this file.
1
/*
2
* Copyright 2022-2023 the Pacemaker project contributors
3
*
4
* The version control history for this file may have further details.
5
*
6
* This source code is licensed under the GNU General Public License version 2
7
* or later (GPLv2+) WITHOUT ANY WARRANTY.
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
;
// calloc() will return NULL
20
21
expect_value(
__wrap_calloc
, nmemb, 1);
22
expect_value(
__wrap_calloc
,
size
,
sizeof
(
pcmk_scheduler_t
));
23
assert_null(
pe_new_working_set
());
24
25
pcmk__mock_calloc
=
false
;
// Use real calloc()
26
}
27
28
static
void
29
calloc_succeeds(
void
**state) {
30
pcmk_scheduler_t
*
scheduler
=
pe_new_working_set
();
31
32
/* Nothing else to test about this function, as all it does is call
33
* set_working_set_defaults which is also a public function and should
34
* get its own unit test.
35
*/
36
assert_non_null(
scheduler
);
37
38
/* Avoid calling pe_free_working_set here so we don't artificially
39
* inflate the coverage numbers.
40
*/
41
free(
scheduler
);
42
}
43
44
PCMK__UNIT_TEST
(NULL, NULL,
45
cmocka_unit_test(calloc_fails),
46
cmocka_unit_test(calloc_succeeds))
size
uint32_t size
Definition:
cpg.c:49
mock_private.h
internal.h
PCMK__UNIT_TEST
PCMK__UNIT_TEST(NULL, NULL, cmocka_unit_test(bad_input), cmocka_unit_test(not_found), cmocka_unit_test(find_attrB), cmocka_unit_test(find_attrA_matching))
pe_working_set_s
Implementation of pcmk_scheduler_t.
Definition:
scheduler.h:172
crm_internal.h
pe_new_working_set
pcmk_scheduler_t * pe_new_working_set(void)
Create a new object to hold scheduler data.
Definition:
status.c:34
scheduler
pcmk_scheduler_t * scheduler
Definition:
native_find_rsc_test.c:19
pcmk__mock_calloc
bool pcmk__mock_calloc
Definition:
mock.c:68
unittest_internal.h
__wrap_calloc
void * __wrap_calloc(size_t nmemb, size_t size)
Definition:
mock.c:71
Generated on Tue Dec 19 2023 17:32:57 for pacemaker by
1.8.14