pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
mock_private.h
Go to the documentation of this file.
1/*
2 * Copyright 2021-2024 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 Lesser General Public License
7 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8 */
9
10#ifndef PCMK__COMMON_MOCK_PRIVATE__H
11#define PCMK__COMMON_MOCK_PRIVATE__H
12
13#include <pwd.h> // struct passwd
14#include <stdbool.h> // bool
15#include <stdio.h> // FILE
16#include <stdlib.h>
17#include <string.h>
18#include <sys/types.h> // pid_t, size_t
19#include <sys/utsname.h>
20#include <unistd.h>
21#include <grp.h> // struct group
22
23#include <crm/common/results.h> // _Noreturn
24
25#ifdef __cplusplus
26extern "C" {
27
28// C++ doesn't support the restrict keyword
29#define restrict
30#endif
31
32/* This header is for the sole use of libcrmcommon_test and unit tests */
33
35_Noreturn void __wrap_abort(void);
36
37extern bool pcmk__mock_calloc;
38void *__real_calloc(size_t nmemb, size_t size);
39void *__wrap_calloc(size_t nmemb, size_t size);
40
41extern bool pcmk__mock_fopen;
42FILE *__real_fopen(const char *pathname, const char *mode);
43FILE *__wrap_fopen(const char *pathname, const char *mode);
44#ifdef HAVE_FOPEN64
45FILE *__real_fopen64(const char *pathname, const char *mode);
46FILE *__wrap_fopen64(const char *pathname, const char *mode);
47#endif
48
49extern bool pcmk__mock_getenv;
50char *__real_getenv(const char *name);
51char *__wrap_getenv(const char *name);
52
53extern bool pcmk__mock_realloc;
54void *__real_realloc(void *ptr, size_t size);
55void *__wrap_realloc(void *ptr, size_t size);
56
57extern bool pcmk__mock_setenv;
58int __real_setenv(const char *name, const char *value, int overwrite);
59int __wrap_setenv(const char *name, const char *value, int overwrite);
60
61extern bool pcmk__mock_unsetenv;
62int __real_unsetenv(const char *name);
63int __wrap_unsetenv(const char *name);
64
65extern bool pcmk__mock_getpid;
66pid_t __real_getpid(void);
67pid_t __wrap_getpid(void);
68
69extern bool pcmk__mock_grent;
70void __real_setgrent(void);
71void __wrap_setgrent(void);
72struct group * __wrap_getgrent(void);
73struct group * __real_getgrent(void);
74void __wrap_endgrent(void);
75void __real_endgrent(void);
76
77extern bool pcmk__mock_getpwnam_r;
78int __real_getpwnam_r(const char *name, struct passwd *pwd,
79 char *buf, size_t buflen, struct passwd **result);
80int __wrap_getpwnam_r(const char *name, struct passwd *pwd,
81 char *buf, size_t buflen, struct passwd **result);
82
83extern bool pcmk__mock_readlink;
84ssize_t __real_readlink(const char *restrict path, char *restrict buf,
85 size_t bufsize);
86ssize_t __wrap_readlink(const char *restrict path, char *restrict buf,
87 size_t bufsize);
88
89extern bool pcmk__mock_strdup;
90char *__real_strdup(const char *s);
91char *__wrap_strdup(const char *s);
92
93#ifdef __cplusplus
94}
95#endif
96
97#endif // PCMK__COMMON_MOCK_PRIVATE__H
const char * path
Definition cib.c:28
const char * name
Definition cib.c:26
uint32_t size
Definition cpg.c:4
int __wrap_setenv(const char *name, const char *value, int overwrite)
Definition mock.c:169
ssize_t __real_readlink(const char *restrict path, char *restrict buf, size_t bufsize)
void __real_endgrent(void)
void __real_setgrent(void)
bool pcmk__mock_realloc
Definition mock.c:138
char * __wrap_strdup(const char *s)
Definition mock.c:452
_Noreturn void __real_abort(void)
bool pcmk__mock_getpid
Definition mock.c:216
pid_t __wrap_getpid(void)
Definition mock.c:219
pid_t __real_getpid(void)
void * __real_realloc(void *ptr, size_t size)
bool pcmk__mock_getenv
Definition mock.c:114
bool pcmk__mock_calloc
Definition mock.c:89
bool pcmk__mock_getpwnam_r
Definition mock.c:375
FILE * __real_fopen(const char *pathname, const char *mode)
bool pcmk__mock_fopen
Definition mock.c:317
bool pcmk__mock_unsetenv
Definition mock.c:194
char * __wrap_getenv(const char *name)
Definition mock.c:117
void __wrap_endgrent(void)
Definition mock.c:296
bool pcmk__mock_setenv
Definition mock.c:166
char * __real_getenv(const char *name)
int __wrap_unsetenv(const char *name)
Definition mock.c:197
bool pcmk__mock_strdup
Definition mock.c:449
bool pcmk__mock_readlink
Definition mock.c:412
void * __wrap_calloc(size_t nmemb, size_t size)
Definition mock.c:92
bool pcmk__mock_grent
Definition mock.c:235
int __real_getpwnam_r(const char *name, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result)
void __wrap_setgrent(void)
Definition mock.c:271
void * __wrap_realloc(void *ptr, size_t size)
Definition mock.c:141
int __wrap_getpwnam_r(const char *name, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result)
Definition mock.c:378
char * __real_strdup(const char *s)
int __real_unsetenv(const char *name)
struct group * __wrap_getgrent(void)
Definition mock.c:284
int __real_setenv(const char *name, const char *value, int overwrite)
void * __real_calloc(size_t nmemb, size_t size)
struct group * __real_getgrent(void)
ssize_t __wrap_readlink(const char *restrict path, char *restrict buf, size_t bufsize)
Definition mock.c:415
_Noreturn void __wrap_abort(void)
Definition mock.c:70
FILE * __wrap_fopen(const char *pathname, const char *mode)
Definition mock.c:320
pcmk__action_result_t result
Definition pcmk_fence.c:37
Function and executable result codes.
#define _Noreturn
Definition results.h:40