]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update nss tests to new skeleton
authorDJ Delorie <dj@redhat.com>
Thu, 17 Aug 2017 21:58:25 +0000 (17:58 -0400)
committerDJ Delorie <dj@redhat.com>
Thu, 17 Aug 2017 22:00:51 +0000 (18:00 -0400)
* bug17079.c: Update to new test harness.
* test-digits-dots.c: Likewise.
* test-netdb.c: Likewise.
* tst-field.c: Likewise.
* tst-nss-getpwent.c: Likewise.
* tst-nss-static.c: Likewise.
* tst-nss-test1.c: Likewise.
* tst-nss-test2.c: Likewise.
* tst-nss-test3.c: Likewise.
* tst-nss-test4.c: Likewise.
* tst-nss-test5.c: Likewise.

12 files changed:
ChangeLog
nss/bug17079.c
nss/test-digits-dots.c
nss/test-netdb.c
nss/tst-field.c
nss/tst-nss-getpwent.c
nss/tst-nss-static.c
nss/tst-nss-test1.c
nss/tst-nss-test2.c
nss/tst-nss-test3.c
nss/tst-nss-test4.c
nss/tst-nss-test5.c

index 0c8183ca215c6f7b24ec73b0d2ce10c68f806732..9ffc40cb503fcf6e56b5e00112a6739f92228127 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2017-08-17  DJ Delorie  <dj@redhat.com>
+
+       * bug17079.c: Update to new test harness.
+       * test-digits-dots.c: Likewise.
+       * test-netdb.c: Likewise.
+       * tst-field.c: Likewise.
+       * tst-nss-getpwent.c: Likewise.
+       * tst-nss-static.c: Likewise.
+       * tst-nss-test1.c: Likewise.
+       * tst-nss-test2.c: Likewise.
+       * tst-nss-test3.c: Likewise.
+       * tst-nss-test4.c: Likewise.
+       * tst-nss-test5.c: Likewise.
+
 2017-08-17  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
        * sysdeps/generic/not-cancel.h (open_not_cancel): Remove macro.
index 4171c7db5575eb4d8762b1d803a89bea9557ebac..09d33f018c79e1c27df4dcf65a0eb7293d519692 100644 (file)
@@ -23,6 +23,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <support/support.h>
+
 /* Check if two passwd structs contain the same data.  */
 static bool
 equal (const struct passwd *a, const struct passwd *b)
@@ -52,13 +54,13 @@ init_test_items (void)
       if (pwd == NULL)
         break;
       struct passwd *target = test_items + test_count;
-      target->pw_name = strdup (pwd->pw_name);
-      target->pw_passwd = strdup (pwd->pw_passwd);
+      target->pw_name = xstrdup (pwd->pw_name);
+      target->pw_passwd = xstrdup (pwd->pw_passwd);
       target->pw_uid = pwd->pw_uid;
       target->pw_gid = pwd->pw_gid;
-      target->pw_gecos = strdup (pwd->pw_gecos);
-      target->pw_dir = strdup (pwd->pw_dir);
-      target->pw_shell = strdup (pwd->pw_shell);
+      target->pw_gecos = xstrdup (pwd->pw_gecos);
+      target->pw_dir = xstrdup (pwd->pw_dir);
+      target->pw_shell = xstrdup (pwd->pw_shell);
     }
   while (++test_count < MAX_TEST_ITEMS);
   endpwent ();
@@ -108,13 +110,7 @@ static void
 test_one (const struct passwd *item, size_t buffer_size,
            char pad, size_t padding_size)
 {
-  char *buffer = malloc (buffer_size + padding_size);
-  if (buffer == NULL)
-    {
-      puts ("error: malloc failure");
-      errors = true;
-      return;
-    }
+  char *buffer = xmalloc (buffer_size + padding_size);
 
   struct passwd pwd;
   struct passwd *result;
@@ -240,5 +236,4 @@ do_test (void)
     return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
index 2685161e650cfca1a894fffa2736dbd330729de7..5b898a932d38b4a2bfdca9e848e4b11b7aacff95 100644 (file)
@@ -21,6 +21,8 @@
 #include <netdb.h>
 #include <errno.h>
 
+#include <support/support.h>
+
 static int
 do_test (void)
 {
@@ -34,5 +36,4 @@ do_test (void)
   return err == ERANGE && h_err == NETDB_INTERNAL ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
index 6b34b1a8f1b07c6b0da00a3f11d7f5dfc646acb2..25f68647e0e221984c8e8ebbcf204a2c8719721f 100644 (file)
@@ -40,6 +40,8 @@
 #include <errno.h>
 #include "nss.h"
 
+#include <support/support.h>
+
 /*
   The following define is necessary for glibc 2.0.6
 */
@@ -177,7 +179,7 @@ test_hosts (void)
   while (gethostname (name, namelen) < 0 && errno == ENAMETOOLONG)
     {
       namelen += 2;            /* tiny increments to test a lot */
-      name = realloc (name, namelen);
+      name = xrealloc (name, namelen);
     }
   if (gethostname (name, namelen) == 0)
     {
@@ -336,5 +338,4 @@ do_test (void)
   return (error_count != 0);
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
index d80be681c2e370bef5cf8a42946c33c36e65770e..8950d7c8c63c443d5df0993227a0b11bf7208a87 100644 (file)
@@ -25,6 +25,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <support/support.h>
+
 static bool errors;
 
 static void
@@ -97,5 +99,4 @@ do_test (void)
   return errors;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
index 7bd69fc378ed304f3eba4a345a3fe70a503a1834..3d4dbe525b34c3dbf53bf54862c55be506504e81 100644 (file)
@@ -21,6 +21,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <support/support.h>
+
 int
 do_test (void)
 {
@@ -37,22 +39,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;
     }
@@ -115,5 +107,4 @@ do_test (void)
 }
 
 #define TIMEOUT 300
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
index 98cf073deb3744121ba322a472da169b43881bf1..6c3dc07622d355bb991830b09dd8f19794dfdc37 100644 (file)
@@ -1,7 +1,8 @@
 /* glibc test for static NSS.  */
 #include <stdio.h>
 
-#define TEST_FUNCTION do_test ()
+#include <support/support.h>
+
 static int
 do_test (void)
 {
@@ -12,4 +13,4 @@ do_test (void)
 }
 
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
index ff1327221921ad24ef183c42fbbafce128548fee..3b4f085b1feb9c8fd721a4b5d813b915084a3cc6 100644 (file)
@@ -22,6 +22,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <support/support.h>
+
 #include "nss_test.h"
 
 static int hook_called = 0;
@@ -120,5 +122,4 @@ do_test (void)
   return retval;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
index 11c2edf118488ee0c88d887faeb97e9ee3b58aa8..ac45d58c4b10a573c3db3bf8307ec36f5ed3c065 100644 (file)
@@ -22,6 +22,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <support/support.h>
+
 #include "nss_test.h"
 
 /* The data in these tables is arbitrary, but the merged data based on
@@ -132,5 +134,4 @@ do_test (void)
   return retval;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
index 308708f387aee6872e42730062230b20082c001a..5098aae67bbdd96890c99f8016a822b7d1e0eac2 100644 (file)
@@ -20,7 +20,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/signal.h>
+
+#include <support/support.h>
 
 #include "nss_test.h"
 
@@ -146,5 +147,4 @@ do_test (void)
     }
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
index 731e0ed10a32d8024f859d67d6f5b9be4d645d61..6e0ac84accdd58abc72d59d8ccb91ece6d22bbe2 100644 (file)
@@ -20,7 +20,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/signal.h>
+
+#include <support/support.h>
 
 #include "nss_test.h"
 
@@ -133,5 +134,4 @@ do_test (void)
     }
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
index fef41f08dfa4ace86f1a1c2dcf6759249deb73c3..8f02cb7779dd8a07bf6904ac8c5a726946a12861 100644 (file)
@@ -22,6 +22,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <support/support.h>
+
 #include "nss_test.h"
 
 /* The specific values and names used here are arbitrary, other than
@@ -104,5 +106,4 @@ do_test (void)
     }
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>