pacemaker
2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
lib
common
tests
procfs
pcmk__procfs_has_pids_false_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 <unistd.h>
17
#include <string.h>
18
#include <errno.h>
19
20
21
static
void
22
no_pids(
void
**state)
23
{
24
char
path
[PATH_MAX];
25
26
snprintf(
path
, PATH_MAX,
"/proc/%u/exe"
, getpid());
27
28
// Set readlink() errno and link contents (for /proc/PID/exe)
29
pcmk__mock_readlink
=
true
;
30
31
expect_string(
__wrap_readlink
,
path
,
path
);
32
expect_any(
__wrap_readlink
, buf);
33
expect_value(
__wrap_readlink
, bufsize, PATH_MAX - 1);
34
will_return(
__wrap_readlink
, ENOENT);
35
will_return(
__wrap_readlink
, NULL);
36
37
assert_false(
pcmk__procfs_has_pids
());
38
39
pcmk__mock_readlink
=
false
;
40
}
41
42
PCMK__UNIT_TEST
(NULL, NULL, cmocka_unit_test(no_pids))
mock_private.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))
pcmk__mock_readlink
bool pcmk__mock_readlink
Definition:
mock.c:366
pcmk__procfs_has_pids
bool pcmk__procfs_has_pids(void)
Definition:
procfs.c:211
crm_internal.h
path
const char * path
Definition:
cib.c:28
unittest_internal.h
__wrap_readlink
ssize_t __wrap_readlink(const char *restrict path, char *restrict buf, size_t bufsize)
Definition:
mock.c:369
Generated on Tue Dec 19 2023 17:32:56 for pacemaker by
1.8.14