nwrap_files_getaddrinfo: avoid crash on empty name
[nss_wrapper.git] / tests / test_getpwuid_module.c
1 #include "config.h"
2
3 #include <stdarg.h>
4 #include <stddef.h>
5 #include <setjmp.h>
6 #include <cmocka.h>
7
8 #include <pwd.h>
9
10 static void test_nwrap_passwd(void **state)
11 {
12         struct passwd *pwd;
13         uid_t id = 424242;
14
15         (void) state; /* unused */
16
17         pwd = getpwuid(id);
18         assert_non_null(pwd);
19
20         assert_string_equal(pwd->pw_name, "hanswurst");
21         assert_int_equal(pwd->pw_uid, id);
22         assert_int_equal(pwd->pw_gid, id);
23 }
24
25 int main(void)
26 {
27         int rc;
28
29         const struct CMUnitTest tests[] = {
30                 cmocka_unit_test(test_nwrap_passwd),
31         };
32
33         rc = cmocka_run_group_tests(tests, NULL, NULL);
34
35         return rc;
36 }