20 #include <sys/types.h> 21 #include <sys/utsname.h> 74 check_expected(nmemb);
99 check_expected_ptr(
name);
100 return mock_ptr_type(
char *);
126 check_expected_ptr(
name);
127 check_expected_ptr(value);
128 check_expected(overwrite);
129 errno = mock_type(
int);
130 return (errno == 0)? 0 : -1;
154 check_expected_ptr(
name);
155 errno = mock_type(
int);
156 return (errno == 0)? 0 : -1;
190 static int group_idx = 0;
193 static const char* grp0_members[] = {
194 "user0",
"user1", NULL
197 static const char* grp1_members[] = {
201 static const char* grp2_members[] = {
202 "user2",
"user1", NULL
214 static const int NUM_GROUPS = 3;
215 static struct group groups[] = {
216 {(
char*)
"grp0", (
char*)
"", 0, (
char**)grp0_members},
217 {(
char*)
"grp1", (
char*)
"", 1, (
char**)grp1_members},
218 {(
char*)
"grp2", (
char*)
"", 2, (
char**)grp2_members},
238 if (group_idx >= NUM_GROUPS) {
241 return &groups[group_idx++];
273 check_expected_ptr(pathname);
274 check_expected_ptr(mode);
275 errno = mock_type(
int);
309 size_t buflen,
struct passwd **
result)
312 int retval = mock_type(
int);
314 check_expected_ptr(
name);
315 check_expected_ptr(pwd);
316 check_expected_ptr(buf);
317 check_expected(buflen);
318 check_expected_ptr(
result);
319 *
result = mock_ptr_type(
struct passwd *);
349 const char *contents = NULL;
351 check_expected_ptr(
path);
352 check_expected_ptr(buf);
353 check_expected(bufsize);
354 errno = mock_type(
int);
355 contents = mock_ptr_type(
const char *);
358 strncpy(buf, contents, bufsize - 1);
359 return strlen(contents);
387 check_expected_ptr(s);
413 check_expected_ptr(buf);
414 retval = mock_type(
int);
415 result = mock_ptr_type(
char *);
418 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)