pacemaker
2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
lib
common
tests
utils
pcmk__getpid_s_test.c
Go to the documentation of this file.
1
/*
2
* Copyright 2022 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
14
#include "
mock_private.h
"
15
16
#include <sys/types.h>
17
#include <unistd.h>
18
19
static
void
20
pcmk__getpid_s_test(
void
**state)
21
{
22
char
*retval;
23
24
// Set getpid() return value
25
pcmk__mock_getpid
=
true
;
26
will_return(
__wrap_getpid
, 1234);
27
28
retval = pcmk__getpid_s();
29
assert_non_null(retval);
30
assert_string_equal(
"1234"
, retval);
31
32
free(retval);
33
34
pcmk__mock_getpid
=
false
;
35
}
36
37
PCMK__UNIT_TEST
(NULL, NULL,
38
cmocka_unit_test(pcmk__getpid_s_test))
mock_private.h
__wrap_getpid
pid_t __wrap_getpid(void)
Definition:
mock.c:173
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))
crm_internal.h
pcmk__mock_getpid
bool pcmk__mock_getpid
Definition:
mock.c:170
unittest_internal.h
Generated on Tue Dec 19 2023 17:32:56 for pacemaker by
1.8.14