9832fd
commit a3fe6a20bf81ef6a97a761dac9050517e7fd7a1f
9832fd
Author: DJ Delorie <dj@redhat.com>
9832fd
Date:   Thu Aug 17 17:58:25 2017 -0400
9832fd
9832fd
    Update nss tests to new skeleton
9832fd
    
9832fd
    * bug17079.c: Update to new test harness.
9832fd
    * test-digits-dots.c: Likewise.
9832fd
    * test-netdb.c: Likewise.
9832fd
    * tst-field.c: Likewise.
9832fd
    * tst-nss-getpwent.c: Likewise.
9832fd
    * tst-nss-static.c: Likewise.
9832fd
    * tst-nss-test1.c: Likewise.
9832fd
    * tst-nss-test2.c: Likewise.
9832fd
    * tst-nss-test3.c: Likewise.
9832fd
    * tst-nss-test4.c: Likewise.
9832fd
    * tst-nss-test5.c: Likewise.
9832fd
9832fd
Partial port of this patch - tst-field.c changes not ported.
9832fd
9832fd
diff --git a/nss/bug17079.c b/nss/bug17079.c
9832fd
index 4171c7db55..09d33f018c 100644
9832fd
--- a/nss/bug17079.c
9832fd
+++ b/nss/bug17079.c
9832fd
@@ -23,6 +23,8 @@
9832fd
 #include <stdlib.h>
9832fd
 #include <string.h>
9832fd
 
9832fd
+#include <support/support.h>
9832fd
+
9832fd
 /* Check if two passwd structs contain the same data.  */
9832fd
 static bool
9832fd
 equal (const struct passwd *a, const struct passwd *b)
9832fd
@@ -52,13 +54,13 @@ init_test_items (void)
9832fd
       if (pwd == NULL)
9832fd
         break;
9832fd
       struct passwd *target = test_items + test_count;
9832fd
-      target->pw_name = strdup (pwd->pw_name);
9832fd
-      target->pw_passwd = strdup (pwd->pw_passwd);
9832fd
+      target->pw_name = xstrdup (pwd->pw_name);
9832fd
+      target->pw_passwd = xstrdup (pwd->pw_passwd);
9832fd
       target->pw_uid = pwd->pw_uid;
9832fd
       target->pw_gid = pwd->pw_gid;
9832fd
-      target->pw_gecos = strdup (pwd->pw_gecos);
9832fd
-      target->pw_dir = strdup (pwd->pw_dir);
9832fd
-      target->pw_shell = strdup (pwd->pw_shell);
9832fd
+      target->pw_gecos = xstrdup (pwd->pw_gecos);
9832fd
+      target->pw_dir = xstrdup (pwd->pw_dir);
9832fd
+      target->pw_shell = xstrdup (pwd->pw_shell);
9832fd
     }
9832fd
   while (++test_count < MAX_TEST_ITEMS);
9832fd
   endpwent ();
9832fd
@@ -108,13 +110,7 @@ static void
9832fd
 test_one (const struct passwd *item, size_t buffer_size,
9832fd
            char pad, size_t padding_size)
9832fd
 {
9832fd
-  char *buffer = malloc (buffer_size + padding_size);
9832fd
-  if (buffer == NULL)
9832fd
-    {
9832fd
-      puts ("error: malloc failure");
9832fd
-      errors = true;
9832fd
-      return;
9832fd
-    }
9832fd
+  char *buffer = xmalloc (buffer_size + padding_size);
9832fd
 
9832fd
   struct passwd pwd;
9832fd
   struct passwd *result;
9832fd
@@ -240,5 +236,4 @@ do_test (void)
9832fd
     return 0;
9832fd
 }
9832fd
 
9832fd
-#define TEST_FUNCTION do_test ()
9832fd
-#include "../test-skeleton.c"
9832fd
+#include <support/test-driver.c>
9832fd
diff --git a/nss/test-digits-dots.c b/nss/test-digits-dots.c
9832fd
index 2685161e65..5b898a932d 100644
9832fd
--- a/nss/test-digits-dots.c
9832fd
+++ b/nss/test-digits-dots.c
9832fd
@@ -21,6 +21,8 @@
9832fd
 #include <netdb.h>
9832fd
 #include <errno.h>
9832fd
 
9832fd
+#include <support/support.h>
9832fd
+
9832fd
 static int
9832fd
 do_test (void)
9832fd
 {
9832fd
@@ -34,5 +36,4 @@ do_test (void)
9832fd
   return err == ERANGE && h_err == NETDB_INTERNAL ? EXIT_SUCCESS : EXIT_FAILURE;
9832fd
 }
9832fd
 
9832fd
-#define TEST_FUNCTION do_test ()
9832fd
-#include "../test-skeleton.c"
9832fd
+#include <support/test-driver.c>
9832fd
diff --git a/nss/tst-nss-static.c b/nss/tst-nss-static.c
9832fd
index 98cf073deb..6c3dc07622 100644
9832fd
--- a/nss/tst-nss-static.c
9832fd
+++ b/nss/tst-nss-static.c
9832fd
@@ -1,7 +1,8 @@
9832fd
 /* glibc test for static NSS.  */
9832fd
 #include <stdio.h>
9832fd
 
9832fd
-#define TEST_FUNCTION do_test ()
9832fd
+#include <support/support.h>
9832fd
+
9832fd
 static int
9832fd
 do_test (void)
9832fd
 {
9832fd
@@ -12,4 +13,4 @@ do_test (void)
9832fd
 }
9832fd
 
9832fd
 
9832fd
-#include "../test-skeleton.c"
9832fd
+#include <support/test-driver.c>
9832fd
diff --git a/nss/tst-nss-test2.c b/nss/tst-nss-test2.c
9832fd
index 11c2edf118..ac45d58c4b 100644
9832fd
--- a/nss/tst-nss-test2.c
9832fd
+++ b/nss/tst-nss-test2.c
9832fd
@@ -22,6 +22,8 @@
9832fd
 #include <stdlib.h>
9832fd
 #include <string.h>
9832fd
 
9832fd
+#include <support/support.h>
9832fd
+
9832fd
 #include "nss_test.h"
9832fd
 
9832fd
 /* The data in these tables is arbitrary, but the merged data based on
9832fd
@@ -132,5 +134,4 @@ do_test (void)
9832fd
   return retval;
9832fd
 }
9832fd
 
9832fd
-#define TEST_FUNCTION do_test ()
9832fd
-#include "../test-skeleton.c"
9832fd
+#include <support/test-driver.c>
9832fd
diff --git a/nss/tst-nss-test3.c b/nss/tst-nss-test3.c
9832fd
index 308708f387..5098aae67b 100644
9832fd
--- a/nss/tst-nss-test3.c
9832fd
+++ b/nss/tst-nss-test3.c
9832fd
@@ -20,7 +20,8 @@
9832fd
 #include <stdio.h>
9832fd
 #include <stdlib.h>
9832fd
 #include <string.h>
9832fd
-#include <sys/signal.h>
9832fd
+
9832fd
+#include <support/support.h>
9832fd
 
9832fd
 #include "nss_test.h"
9832fd
 
9832fd
@@ -146,5 +147,4 @@ do_test (void)
9832fd
     }
9832fd
 }
9832fd
 
9832fd
-#define TEST_FUNCTION do_test ()
9832fd
-#include "../test-skeleton.c"
9832fd
+#include <support/test-driver.c>
9832fd
diff --git a/nss/tst-nss-test4.c b/nss/tst-nss-test4.c
9832fd
index 731e0ed10a..6e0ac84acc 100644
9832fd
--- a/nss/tst-nss-test4.c
9832fd
+++ b/nss/tst-nss-test4.c
9832fd
@@ -20,7 +20,8 @@
9832fd
 #include <stdio.h>
9832fd
 #include <stdlib.h>
9832fd
 #include <string.h>
9832fd
-#include <sys/signal.h>
9832fd
+
9832fd
+#include <support/support.h>
9832fd
 
9832fd
 #include "nss_test.h"
9832fd
 
9832fd
@@ -133,5 +134,4 @@ do_test (void)
9832fd
     }
9832fd
 }
9832fd
 
9832fd
-#define TEST_FUNCTION do_test ()
9832fd
-#include "../test-skeleton.c"
9832fd
+#include <support/test-driver.c>
9832fd
diff --git a/nss/tst-nss-test5.c b/nss/tst-nss-test5.c
9832fd
index fef41f08df..8f02cb7779 100644
9832fd
--- a/nss/tst-nss-test5.c
9832fd
+++ b/nss/tst-nss-test5.c
9832fd
@@ -22,6 +22,8 @@
9832fd
 #include <stdlib.h>
9832fd
 #include <string.h>
9832fd
 
9832fd
+#include <support/support.h>
9832fd
+
9832fd
 #include "nss_test.h"
9832fd
 
9832fd
 /* The specific values and names used here are arbitrary, other than
9832fd
@@ -104,5 +106,4 @@ do_test (void)
9832fd
     }
9832fd
 }
9832fd
 
9832fd
-#define TEST_FUNCTION do_test ()
9832fd
-#include "../test-skeleton.c"
9832fd
+#include <support/test-driver.c>