19 #include <sys/types.h> 24 int fail = mock_type(
int);
27 return mock_ptr_type(
void *);
37 int retval = mock_type(
int);
39 *
result = mock_ptr_type(
struct passwd *);
45 calloc_fails(
void **state)
59 getpwnam_r_fails(
void **state)
73 no_matching_pwent(
void **state)
87 entry_found(
void **state)
95 struct passwd returned_ent = { .pw_uid = 1000, .pw_gid = 1000 };
112 assert_int_equal(uid, 1000);
113 assert_int_equal(gid, 1000);
116 int main(
int argc,
char **argv)
118 const struct CMUnitTest tests[] = {
119 cmocka_unit_test(calloc_fails),
120 cmocka_unit_test(getpwnam_r_fails),
121 cmocka_unit_test(no_matching_pwent),
122 cmocka_unit_test(entry_found),
125 cmocka_set_message_output(CM_OUTPUT_TAP);
126 return cmocka_run_group_tests(tests, NULL, NULL);
int crm_user_lookup(const char *name, uid_t *uid, gid_t *gid)
int __wrap_getpwnam_r(const char *name, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result)
void * __real_calloc(size_t nmemb, size_t size)
pcmk__action_result_t result
void * __wrap_calloc(size_t nmemb, size_t size)
int main(int argc, char **argv)