x86_64: Fix svml_s_log10f8_core_avx2.S code formatting
[glibc.git] / nss / tst-nss-test5.c
blobde3967e517975e6c227cc8f8387f5cae1b9f5c4e
1 /* Test error checking for passwd entries.
2 Copyright (C) 2017-2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #include <nss.h>
20 #include <pwd.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
25 #include <support/support.h>
27 #include "nss_test.h"
29 /* The specific values and names used here are arbitrary, other than
30 correspondence (with suitable differences according to the tests as
31 commented) between the given and expected entries. */
33 static struct passwd pwd_table[] = {
34 PWD (100), /* baseline, matches */
35 PWD (300), /* wrong name and uid */
36 PWD_N (200, NULL), /* missing name */
37 PWD (60), /* unexpected name */
38 { .pw_name = (char *)"name20000", .pw_passwd = (char *) "*", .pw_uid = 20000, \
39 .pw_gid = 200, .pw_gecos = (char *) "*", .pw_dir = (char *) "*", \
40 .pw_shell = (char *) "*" }, /* wrong gid */
41 { .pw_name = (char *)"name2", .pw_passwd = (char *) "x", .pw_uid = 2, \
42 .pw_gid = 2, .pw_gecos = (char *) "y", .pw_dir = (char *) "z", \
43 .pw_shell = (char *) "*" }, /* spot check other text fields */
44 PWD_LAST ()
47 static struct passwd exp_table[] = {
48 PWD (100),
49 PWD (30),
50 PWD (200),
51 PWD_N (60, NULL),
52 PWD (20000),
53 PWD (2),
54 PWD_LAST ()
57 void
58 _nss_test1_init_hook(test_tables *t)
60 t->pwd_table = pwd_table;
63 static int
64 do_test (void)
66 int retval = 0;
67 int i;
68 struct passwd *p;
70 __nss_configure_lookup ("passwd", "test1");
72 setpwent ();
74 i = 0;
75 for (p = getpwent ();
76 p != NULL && ! PWD_ISLAST (& exp_table[i]);
77 ++i, p = getpwent ())
78 retval += compare_passwds (i, p, & exp_table[i]);
80 endpwent ();
83 if (p)
85 printf ("FAIL: [?] passwd entry %u.%s unexpected\n", p->pw_uid, p->pw_name);
86 ++retval;
88 if (! PWD_ISLAST (& exp_table[i]))
90 printf ("FAIL: [%d] passwd entry %u.%s missing\n", i,
91 exp_table[i].pw_uid, exp_table[i].pw_name);
92 ++retval;
95 #define EXPECTED 9
96 if (retval == EXPECTED)
98 if (retval > 0)
99 printf ("PASS: Found %d expected errors\n", retval);
100 return 0;
102 else
104 printf ("FAIL: Found %d errors, expected %d\n", retval, EXPECTED);
105 return 1;
109 #include <support/test-driver.c>