pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
mock_private.h
Go to the documentation of this file.
1 /*
2  * Copyright 2021-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 Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8  */
9 
10 #ifndef MOCK_PRIVATE__H
11 # define MOCK_PRIVATE__H
12 
13 #include <pwd.h>
14 #include <stdbool.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <sys/types.h>
19 #include <sys/utsname.h>
20 #include <unistd.h>
21 #include <grp.h>
22 
23 /* This header is for the sole use of libcrmcommon_test and unit tests */
24 
25 extern bool pcmk__mock_calloc;
26 void *__real_calloc(size_t nmemb, size_t size);
27 void *__wrap_calloc(size_t nmemb, size_t size);
28 
29 extern bool pcmk__mock_fopen;
30 FILE *__real_fopen(const char *pathname, const char *mode);
31 FILE *__wrap_fopen(const char *pathname, const char *mode);
32 #ifdef HAVE_FOPEN64
33 FILE *__real_fopen64(const char *pathname, const char *mode);
34 FILE *__wrap_fopen64(const char *pathname, const char *mode);
35 #endif
36 
37 extern bool pcmk__mock_getenv;
38 char *__real_getenv(const char *name);
39 char *__wrap_getenv(const char *name);
40 
41 extern bool pcmk__mock_setenv;
42 int __real_setenv(const char *name, const char *value, int overwrite);
43 int __wrap_setenv(const char *name, const char *value, int overwrite);
44 
45 extern bool pcmk__mock_unsetenv;
46 int __real_unsetenv(const char *name);
47 int __wrap_unsetenv(const char *name);
48 
49 extern bool pcmk__mock_getpid;
50 pid_t __real_getpid(void);
51 pid_t __wrap_getpid(void);
52 
53 extern bool pcmk__mock_grent;
54 void __real_setgrent(void);
55 void __wrap_setgrent(void);
56 struct group * __wrap_getgrent(void);
57 struct group * __real_getgrent(void);
58 void __wrap_endgrent(void);
59 void __real_endgrent(void);
60 
61 extern bool pcmk__mock_getpwnam_r;
62 int __real_getpwnam_r(const char *name, struct passwd *pwd,
63  char *buf, size_t buflen, struct passwd **result);
64 int __wrap_getpwnam_r(const char *name, struct passwd *pwd,
65  char *buf, size_t buflen, struct passwd **result);
66 
67 extern bool pcmk__mock_readlink;
68 ssize_t __real_readlink(const char *restrict path, char *restrict buf,
69  size_t bufsize);
70 ssize_t __wrap_readlink(const char *restrict path, char *restrict buf,
71  size_t bufsize);
72 
73 extern bool pcmk__mock_strdup;
74 char *__real_strdup(const char *s);
75 char *__wrap_strdup(const char *s);
76 
77 extern bool pcmk__mock_uname;
78 int __real_uname(struct utsname *buf);
79 int __wrap_uname(struct utsname *buf);
80 
81 #endif // MOCK_PRIVATE__H
uint32_t size
Definition: cpg.c:49
int __wrap_uname(struct utsname *buf)
Definition: mock.c:431
char * __wrap_strdup(const char *s)
Definition: mock.c:406
const char * name
Definition: cib.c:26
int __wrap_getpwnam_r(const char *name, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result)
Definition: mock.c:332
bool pcmk__mock_uname
Definition: mock.c:428
bool pcmk__mock_setenv
Definition: mock.c:120
ssize_t __wrap_readlink(const char *restrict path, char *restrict buf, size_t bufsize)
Definition: mock.c:369
char * __real_getenv(const char *name)
bool pcmk__mock_grent
Definition: mock.c:189
void * __wrap_calloc(size_t nmemb, size_t size)
Definition: mock.c:71
bool pcmk__mock_getpid
Definition: mock.c:170
bool pcmk__mock_calloc
Definition: mock.c:68
int __real_setenv(const char *name, const char *value, int overwrite)
pid_t __real_getpid(void)
void __wrap_endgrent(void)
Definition: mock.c:250
void __wrap_setgrent(void)
Definition: mock.c:225
int __real_unsetenv(const char *name)
bool pcmk__mock_unsetenv
Definition: mock.c:148
int __real_uname(struct utsname *buf)
void __real_setgrent(void)
FILE * __wrap_fopen(const char *pathname, const char *mode)
Definition: mock.c:274
char * __wrap_getenv(const char *name)
Definition: mock.c:96
pid_t __wrap_getpid(void)
Definition: mock.c:173
bool pcmk__mock_getenv
Definition: mock.c:93
void * __real_calloc(size_t nmemb, size_t size)
bool pcmk__mock_fopen
Definition: mock.c:271
pcmk__action_result_t result
Definition: pcmk_fence.c:35
const char * path
Definition: cib.c:28
bool pcmk__mock_getpwnam_r
Definition: mock.c:329
struct group * __real_getgrent(void)
void __real_endgrent(void)
ssize_t __real_readlink(const char *restrict path, char *restrict buf, size_t bufsize)
char * __real_strdup(const char *s)
FILE * __real_fopen(const char *pathname, const char *mode)
int __real_getpwnam_r(const char *name, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result)
struct group * __wrap_getgrent(void)
Definition: mock.c:238
int __wrap_unsetenv(const char *name)
Definition: mock.c:151
#define restrict
Definition: config.h:1036
bool pcmk__mock_strdup
Definition: mock.c:403
bool pcmk__mock_readlink
Definition: mock.c:366
int __wrap_setenv(const char *name, const char *value, int overwrite)
Definition: mock.c:123