pacemaker  2.1.9-49aab99839
Scalable High-Availability cluster resource manager
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 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 _Noreturn void __real_abort(void);
26 _Noreturn void __wrap_abort(void);
27 
28 extern bool pcmk__mock_calloc;
29 void *__real_calloc(size_t nmemb, size_t size);
30 void *__wrap_calloc(size_t nmemb, size_t size);
31 
32 extern bool pcmk__mock_fopen;
33 FILE *__real_fopen(const char *pathname, const char *mode);
34 FILE *__wrap_fopen(const char *pathname, const char *mode);
35 #ifdef HAVE_FOPEN64
36 FILE *__real_fopen64(const char *pathname, const char *mode);
37 FILE *__wrap_fopen64(const char *pathname, const char *mode);
38 #endif
39 
40 extern bool pcmk__mock_getenv;
41 char *__real_getenv(const char *name);
42 char *__wrap_getenv(const char *name);
43 
44 extern bool pcmk__mock_realloc;
45 void *__real_realloc(void *ptr, size_t size);
46 void *__wrap_realloc(void *ptr, size_t size);
47 
48 extern bool pcmk__mock_setenv;
49 int __real_setenv(const char *name, const char *value, int overwrite);
50 int __wrap_setenv(const char *name, const char *value, int overwrite);
51 
52 extern bool pcmk__mock_unsetenv;
53 int __real_unsetenv(const char *name);
54 int __wrap_unsetenv(const char *name);
55 
56 extern bool pcmk__mock_getpid;
57 pid_t __real_getpid(void);
58 pid_t __wrap_getpid(void);
59 
60 extern bool pcmk__mock_grent;
61 void __real_setgrent(void);
62 void __wrap_setgrent(void);
63 struct group * __wrap_getgrent(void);
64 struct group * __real_getgrent(void);
65 void __wrap_endgrent(void);
66 void __real_endgrent(void);
67 
68 extern bool pcmk__mock_getpwnam_r;
69 int __real_getpwnam_r(const char *name, struct passwd *pwd,
70  char *buf, size_t buflen, struct passwd **result);
71 int __wrap_getpwnam_r(const char *name, struct passwd *pwd,
72  char *buf, size_t buflen, struct passwd **result);
73 
74 extern bool pcmk__mock_readlink;
75 ssize_t __real_readlink(const char *restrict path, char *restrict buf,
76  size_t bufsize);
77 ssize_t __wrap_readlink(const char *restrict path, char *restrict buf,
78  size_t bufsize);
79 
80 extern bool pcmk__mock_strdup;
81 char *__real_strdup(const char *s);
82 char *__wrap_strdup(const char *s);
83 
84 #endif // MOCK_PRIVATE__H
bool pcmk__mock_realloc
Definition: mock.c:139
uint32_t size
Definition: cpg.c:52
char * __wrap_strdup(const char *s)
Definition: mock.c:453
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:379
bool pcmk__mock_setenv
Definition: mock.c:167
ssize_t __wrap_readlink(const char *restrict path, char *restrict buf, size_t bufsize)
Definition: mock.c:416
char * __real_getenv(const char *name)
bool pcmk__mock_grent
Definition: mock.c:236
void * __wrap_calloc(size_t nmemb, size_t size)
Definition: mock.c:93
bool pcmk__mock_getpid
Definition: mock.c:217
bool pcmk__mock_calloc
Definition: mock.c:90
int __real_setenv(const char *name, const char *value, int overwrite)
pid_t __real_getpid(void)
#define _Noreturn
Definition: config.h:667
void * __wrap_realloc(void *ptr, size_t size)
Definition: mock.c:142
void __wrap_endgrent(void)
Definition: mock.c:297
void __wrap_setgrent(void)
Definition: mock.c:272
int __real_unsetenv(const char *name)
bool pcmk__mock_unsetenv
Definition: mock.c:195
void __real_setgrent(void)
FILE * __wrap_fopen(const char *pathname, const char *mode)
Definition: mock.c:321
void * __real_realloc(void *ptr, size_t size)
char * __wrap_getenv(const char *name)
Definition: mock.c:118
pid_t __wrap_getpid(void)
Definition: mock.c:220
_Noreturn void __real_abort(void)
bool pcmk__mock_getenv
Definition: mock.c:115
void * __real_calloc(size_t nmemb, size_t size)
bool pcmk__mock_fopen
Definition: mock.c:318
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:376
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:285
int __wrap_unsetenv(const char *name)
Definition: mock.c:198
#define restrict
Definition: config.h:1048
bool pcmk__mock_strdup
Definition: mock.c:450
bool pcmk__mock_readlink
Definition: mock.c:413
_Noreturn void __wrap_abort(void)
Definition: mock.c:71
int __wrap_setenv(const char *name, const char *value, int overwrite)
Definition: mock.c:170