22 #include <sys/types.h> 23 #include <sys/utsname.h> 76 check_expected(nmemb);
101 check_expected_ptr(
name);
102 return mock_ptr_type(
char *);
128 check_expected_ptr(
name);
129 check_expected_ptr(value);
130 check_expected(overwrite);
131 errno = mock_type(
int);
132 return (errno == 0)? 0 : -1;
156 check_expected_ptr(
name);
157 errno = mock_type(
int);
158 return (errno == 0)? 0 : -1;
192 static int group_idx = 0;
195 static const char* grp0_members[] = {
196 "user0",
"user1", NULL
199 static const char* grp1_members[] = {
203 static const char* grp2_members[] = {
204 "user2",
"user1", NULL
216 static const int NUM_GROUPS = 3;
217 static struct group groups[] = {
218 {(
char*)
"grp0", (
char*)
"", 0, (
char**)grp0_members},
219 {(
char*)
"grp1", (
char*)
"", 1, (
char**)grp1_members},
220 {(
char*)
"grp2", (
char*)
"", 2, (
char**)grp2_members},
240 if (group_idx >= NUM_GROUPS) {
243 return &groups[group_idx++];
277 check_expected_ptr(pathname);
278 check_expected_ptr(mode);
279 errno = mock_type(
int);
294 __wrap_fopen64(
const char *pathname,
const char *mode)
297 check_expected_ptr(pathname);
298 check_expected_ptr(mode);
299 errno = mock_type(
int);
304 return __real_fopen64(pathname, mode);
308 return __real_fopen64(pathname, mode);
333 size_t buflen,
struct passwd **
result)
336 int retval = mock_type(
int);
338 check_expected_ptr(
name);
339 check_expected_ptr(pwd);
340 check_expected_ptr(buf);
341 check_expected(buflen);
342 check_expected_ptr(
result);
343 *
result = mock_ptr_type(
struct passwd *);
373 const char *contents = NULL;
375 check_expected_ptr(
path);
376 check_expected_ptr(buf);
377 check_expected(bufsize);
378 errno = mock_type(
int);
379 contents = mock_ptr_type(
const char *);
382 strncpy(buf, contents, bufsize - 1);
383 return strlen(contents);
411 check_expected_ptr(s);
437 check_expected_ptr(buf);
438 retval = mock_type(
int);
439 result = mock_ptr_type(
char *);
442 strcpy(buf->nodename,
result);
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)
int __real_unsetenv(const char *name)
int __real_uname(struct utsname *buf)
void __real_setgrent(void)
void * __real_calloc(size_t nmemb, size_t size)
pcmk__action_result_t result
struct group * __wrap_getgrent(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)
int __wrap_uname(struct utsname *buf)
char * __wrap_getenv(const char *name)
int __wrap_unsetenv(const char *name)