pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
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
13
14#include "mock_private.h"
15
16#include <sys/types.h>
17#include <unistd.h>
18
19static void
20pcmk__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
37PCMK__UNIT_TEST(NULL, NULL,
38 cmocka_unit_test(pcmk__getpid_s_test))
bool pcmk__mock_getpid
Definition mock.c:216
pid_t __wrap_getpid(void)
Definition mock.c:219
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)