From patchwork Wed Aug 9 21:41:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DJ Delorie X-Patchwork-Id: 799979 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-82957-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="ySPu2qHy"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xSPqh59rPz9sN5 for ; Thu, 10 Aug 2017 07:42:08 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:in-reply-to:date:message-id :mime-version:content-type; q=dns; s=default; b=RjPiLu/7rpNQNo8V gulrXktgJ/lsyone606hIyODwJSSCzj0VTBfm7q2E7FCEsrjIaQrHV1LD2pS4PJs HJxBSPoWtSXXdRE6Xk86LVJhOydMb2XUWaH91Cyr6xSNh1MR5wk0LtzQ7vgAtJVp IOJrFXgWBzJyQLmhZ08MNU8FiG8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:in-reply-to:date:message-id :mime-version:content-type; s=default; bh=o5QQaqcf9781ouV++CpsoH JXKoc=; b=ySPu2qHyh1LB1D1u4EBFB9H5/3Zl9QYbZvYwgB9O6qTqGYpaMEiptO 6Yd1mT4H8tj0ZevvTNjRyn/1Lr/ETfIYszIF2CA9KohRwvU8xvR2G8zsqByQxwFD 2Y5k9bocIJtKjaeqUedlmz0nfUpkbx/n8r+fOKghdO7u71jxMsACw= Received: (qmail 85207 invoked by alias); 9 Aug 2017 21:41:49 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 84933 invoked by uid 89); 9 Aug 2017 21:41:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=994, 1335, H*r:8.14.7, 22, 8 X-HELO: mx1.redhat.com DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C4026C07D1FA Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dj@redhat.com From: DJ Delorie To: Joseph Myers Cc: libc-alpha@sourceware.org Subject: Re: [patch] NSS test harness upgrade In-Reply-To: (message from Joseph Myers on Thu, 27 Jul 2017 23:23:06 +0000) Date: Wed, 09 Aug 2017 17:41:38 -0400 Message-ID: MIME-Version: 1.0 Joseph Myers writes: > These tests should all be converted to use . Like this? * 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. diff --git a/nss/bug17079.c b/nss/bug17079.c index 4171c7d..09d33f0 100644 --- a/nss/bug17079.c +++ b/nss/bug17079.c @@ -23,6 +23,8 @@ #include #include +#include + /* 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 diff --git a/nss/test-digits-dots.c b/nss/test-digits-dots.c index 2685161..5b898a9 100644 --- a/nss/test-digits-dots.c +++ b/nss/test-digits-dots.c @@ -21,6 +21,8 @@ #include #include +#include + 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 diff --git a/nss/test-netdb.c b/nss/test-netdb.c index 6b34b1a..25f6864 100644 --- a/nss/test-netdb.c +++ b/nss/test-netdb.c @@ -40,6 +40,8 @@ #include #include "nss.h" +#include + /* 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 diff --git a/nss/tst-field.c b/nss/tst-field.c index d80be68..8950d7c 100644 --- a/nss/tst-field.c +++ b/nss/tst-field.c @@ -25,6 +25,8 @@ #include #include +#include + static bool errors; static void @@ -97,5 +99,4 @@ do_test (void) return errors; } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include diff --git a/nss/tst-nss-getpwent.c b/nss/tst-nss-getpwent.c index 7bd69fc..3d4dbe5 100644 --- a/nss/tst-nss-getpwent.c +++ b/nss/tst-nss-getpwent.c @@ -21,6 +21,8 @@ #include #include +#include + 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 diff --git a/nss/tst-nss-static.c b/nss/tst-nss-static.c index 98cf073..f101263 100644 --- a/nss/tst-nss-static.c +++ b/nss/tst-nss-static.c @@ -1,7 +1,8 @@ /* glibc test for static NSS. */ #include -#define TEST_FUNCTION do_test () +#include + static int do_test (void) { @@ -12,4 +13,5 @@ do_test (void) } -#include "../test-skeleton.c" +#include + diff --git a/nss/tst-nss-test1.c b/nss/tst-nss-test1.c index ff13272..3b4f085 100644 --- a/nss/tst-nss-test1.c +++ b/nss/tst-nss-test1.c @@ -22,6 +22,8 @@ #include #include +#include + #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 diff --git a/nss/tst-nss-test2.c b/nss/tst-nss-test2.c index 11c2edf..ac45d58 100644 --- a/nss/tst-nss-test2.c +++ b/nss/tst-nss-test2.c @@ -22,6 +22,8 @@ #include #include +#include + #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 diff --git a/nss/tst-nss-test3.c b/nss/tst-nss-test3.c index 308708f..5098aae 100644 --- a/nss/tst-nss-test3.c +++ b/nss/tst-nss-test3.c @@ -20,7 +20,8 @@ #include #include #include -#include + +#include #include "nss_test.h" @@ -146,5 +147,4 @@ do_test (void) } } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include diff --git a/nss/tst-nss-test4.c b/nss/tst-nss-test4.c index 731e0ed..6e0ac84 100644 --- a/nss/tst-nss-test4.c +++ b/nss/tst-nss-test4.c @@ -20,7 +20,8 @@ #include #include #include -#include + +#include #include "nss_test.h" @@ -133,5 +134,4 @@ do_test (void) } } -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" +#include diff --git a/nss/tst-nss-test5.c b/nss/tst-nss-test5.c index fef41f0..8f02cb7 100644 --- a/nss/tst-nss-test5.c +++ b/nss/tst-nss-test5.c @@ -22,6 +22,8 @@ #include #include +#include + #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