Fix abday strings for ks_IN@devanagari to match the day strings
[glibc.git] / nss / tst-nss-test1.c
blobc5750e0956ea94502a4999207e0aca4611a28898
1 #include <nss.h>
2 #include <pwd.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
8 static int
9 do_test (void)
11 int retval = 0;
13 __nss_configure_lookup ("passwd", "test1");
15 static const unsigned int pwdids[] = { 100, 30, 200, 60, 20000 };
16 #define npwdids (sizeof (pwdids) / sizeof (pwdids[0]))
17 setpwent ();
19 const unsigned int *np = pwdids;
20 for (struct passwd *p = getpwent (); p != NULL; ++np, p = getpwent ())
21 if (p->pw_uid != *np || strncmp (p->pw_name, "name", 4) != 0
22 || atol (p->pw_name + 4) != *np)
24 printf ("passwd entry %td wrong (%s, %u)\n",
25 np - pwdids, p->pw_name, p->pw_uid);
26 retval = 1;
27 break;
30 endpwent ();
32 for (int i = npwdids - 1; i >= 0; --i)
34 char buf[30];
35 snprintf (buf, sizeof (buf), "name%u", pwdids[i]);
37 struct passwd *p = getpwnam (buf);
38 if (p == NULL || p->pw_uid != pwdids[i] || strcmp (buf, p->pw_name) != 0)
40 printf ("passwd entry \"%s\" wrong\n", buf);
41 retval = 1;
44 p = getpwuid (pwdids[i]);
45 if (p == NULL || p->pw_uid != pwdids[i] || strcmp (buf, p->pw_name) != 0)
47 printf ("passwd entry %u wrong\n", pwdids[i]);
48 retval = 1;
51 snprintf (buf, sizeof (buf), "name%u", pwdids[i] + 1);
53 p = getpwnam (buf);
54 if (p != NULL)
56 printf ("passwd entry \"%s\" wrong\n", buf);
57 retval = 1;
60 p = getpwuid (pwdids[i] + 1);
61 if (p != NULL)
63 printf ("passwd entry %u wrong\n", pwdids[i] + 1);
64 retval = 1;
68 return retval;
71 #define TEST_FUNCTION do_test ()
72 #include "../test-skeleton.c"