nss: Unnest nested function add_key
[platform/upstream/glibc.git] / nss / tst-nss-getpwent.c
index f2e8abc..58ff744 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015 Free Software Foundation, Inc.
+/* Copyright (C) 2015-2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
+#include <nss.h>
 #include <pwd.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+#include <support/support.h>
+
 int
 do_test (void)
 {
+  __nss_configure_lookup ("passwd", "files");
+
   /* Count the number of entries in the password database, and fetch
      data from the first and last entries.  */
   size_t count = 0;
@@ -37,22 +42,12 @@ do_test (void)
     {
       if (first_name == NULL)
        {
-         first_name = strdup (pw->pw_name);
-         if (first_name == NULL)
-           {
-             printf ("strdup: %m\n");
-             return 1;
-           }
+         first_name = xstrdup (pw->pw_name);
          first_uid = pw->pw_uid;
        }
 
       free (last_name);
-      last_name = strdup (pw->pw_name);
-      if (last_name == NULL)
-       {
-         printf ("strdup: %m\n");
-         return 1;
-       }
+      last_name = xstrdup (pw->pw_name);
       last_uid = pw->pw_uid;
       ++count;
     }
@@ -114,5 +109,5 @@ do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#define TIMEOUT 300
+#include <support/test-driver.c>