22 #include <sys/types.h> 23 #include <sys/utsname.h> 73 #if (PCMK__WITH_COVERAGE == 1) 98 check_expected(nmemb);
123 check_expected_ptr(
name);
124 return mock_ptr_type(
char *);
147 check_expected_ptr(ptr);
148 check_expected(
size);
175 check_expected_ptr(
name);
176 check_expected_ptr(value);
177 check_expected(overwrite);
178 errno = mock_type(
int);
179 return (errno == 0)? 0 : -1;
203 check_expected_ptr(
name);
204 errno = mock_type(
int);
205 return (errno == 0)? 0 : -1;
239 static int group_idx = 0;
242 static const char* grp0_members[] = {
243 "user0",
"user1", NULL
246 static const char* grp1_members[] = {
250 static const char* grp2_members[] = {
251 "user2",
"user1", NULL
263 static const int NUM_GROUPS = 3;
264 static struct group groups[] = {
265 {(
char*)
"grp0", (
char*)
"", 0, (
char**)grp0_members},
266 {(
char*)
"grp1", (
char*)
"", 1, (
char**)grp1_members},
267 {(
char*)
"grp2", (
char*)
"", 2, (
char**)grp2_members},
287 if (group_idx >= NUM_GROUPS) {
290 return &groups[group_idx++];
324 check_expected_ptr(pathname);
325 check_expected_ptr(mode);
326 errno = mock_type(
int);
341 __wrap_fopen64(
const char *pathname,
const char *mode)
344 check_expected_ptr(pathname);
345 check_expected_ptr(mode);
346 errno = mock_type(
int);
351 return __real_fopen64(pathname, mode);
355 return __real_fopen64(pathname, mode);
380 size_t buflen,
struct passwd **
result)
383 int retval = mock_type(
int);
385 check_expected_ptr(
name);
386 check_expected_ptr(pwd);
387 check_expected_ptr(buf);
388 check_expected(buflen);
389 check_expected_ptr(
result);
390 *
result = mock_ptr_type(
struct passwd *);
420 const char *contents = NULL;
422 check_expected_ptr(
path);
423 check_expected_ptr(buf);
424 check_expected(bufsize);
425 errno = mock_type(
int);
426 contents = mock_ptr_type(
const char *);
429 strncpy(buf, contents, bufsize - 1);
430 return strlen(contents);
458 check_expected_ptr(s);
bool pcmk__mock_getpwnam_r
char * __real_getenv(const char *name)
pid_t __wrap_getpid(void)
int __wrap_getpwnam_r(const char *name, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result)
int __real_setenv(const char *name, const char *value, int overwrite)
pid_t __real_getpid(void)
void __wrap_setgrent(void)
void * __wrap_realloc(void *ptr, size_t size)
int __real_unsetenv(const char *name)
void __real_setgrent(void)
void * __real_realloc(void *ptr, size_t size)
_Noreturn void __real_abort(void)
void * __real_calloc(size_t nmemb, size_t size)
pcmk__action_result_t result
struct group * __wrap_getgrent(void)
_Noreturn void __wrap_abort(void)
struct group * __real_getgrent(void)
FILE * __wrap_fopen(const char *pathname, const char *mode)
void __real_endgrent(void)
ssize_t __real_readlink(const char *restrict path, char *restrict buf, size_t bufsize)
char * __real_strdup(const char *s)
ssize_t __wrap_readlink(const char *restrict path, char *restrict buf, size_t bufsize)
FILE * __real_fopen(const char *pathname, const char *mode)
void __wrap_endgrent(void)
int __real_getpwnam_r(const char *name, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result)
int __wrap_setenv(const char *name, const char *value, int overwrite)
void * __wrap_calloc(size_t nmemb, size_t size)
char * __wrap_strdup(const char *s)
char * __wrap_getenv(const char *name)
int __wrap_unsetenv(const char *name)