From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 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 dcvr.yhbt.net (Postfix) with ESMTPS id 4152A1F453 for ; Thu, 21 Feb 2019 20:58:10 +0000 (UTC) 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:subject:date:message-id:in-reply-to :references:mime-version:content-type; q=dns; s=default; b=eo4/k pRKTfzSBEpUHSn813/+6A//kg8kk3O7nZZ8slSajW0s0hIOfDyEEwXMB7tQ2IilB uMdJ0fdF2B0zWAsgeU5qovl1Ao8zVnon7+1yxtybaI+e5Z1IY5wIChUI8wgkFziX DSr4DPyT4skj+/4Wcn25/KN0BbaoU4pJ72iBMo= 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:subject:date:message-id:in-reply-to :references:mime-version:content-type; s=default; bh=r7s/PdB1pU0 4fsR0v5j/p46G94E=; b=F87FHaRzl6z1lVOX44epzYbEdewE1g5tByHrA5RDQqZ Epr+BxifOiXj48DrEyZK49vwyL/nWi90fvZ6DS1tt3EMX25rGLpw56OXSRjEvhDG AZoFeB46sAP6lPmNF39qpmW5LZEYOdGgA7CAPAoXL7hWrJDd0an5cCYsRMJrRPC0 = Received: (qmail 55321 invoked by alias); 21 Feb 2019 20:57:42 -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 Received: (qmail 55194 invoked by uid 89); 21 Feb 2019 20:57:41 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v4 5/5] ldbl-opt: Reuse test cases from misc/ that check long double Date: Thu, 21 Feb 2019 17:57:06 -0300 Message-ID: <20190221205706.12225-6-gabriel@inconstante.eti.br> In-Reply-To: <20190221205706.12225-1-gabriel@inconstante.eti.br> References: <20190221205706.12225-1-gabriel@inconstante.eti.br> MIME-Version: 1.0 Content-Type: text/plain X-Ovh-Tracer-Id: 1207246178063994563 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedutddrtdekgddugeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenuc No changes since v3. No changes since v2. No changes since v1. -- 8< -- This patch adds test cases for the compatibility versions of the functions: err, errx, verr, verrx, warn, warnx, vwarn, vwarnx (from err.h), error, and error_at_line (from error.h), when long double has the same format as double (-mlong-double-64). Tested for powerpc64 and powerpc64le. * sysdeps/ieee754/ldbl-opt/Makefile [subdir == misc] (tests-internal): Add tst-nldbl-warn, tst-nldbl-error. (CFLAGS-tst-nldbl-warn.c, CFLAGS-tst-nldbl-error.c): New variables. --- misc/tst-ldbl-error.c | 25 +++++++++++++------------ misc/tst-ldbl-warn.c | 20 ++++++++++++++------ sysdeps/ieee754/ldbl-opt/Makefile | 16 ++++++++++++++++ 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/misc/tst-ldbl-error.c b/misc/tst-ldbl-error.c index d6609f7fe9..0f13fee9f3 100644 --- a/misc/tst-ldbl-error.c +++ b/misc/tst-ldbl-error.c @@ -85,14 +85,15 @@ do_one_test (void *callback, const char *expected, ...) /* Call 'callback', which fills in the output and error buffers. */ result = support_capture_subprocess (callback, NULL); - /* The functions err, errx, verr, and verrx print just the program - name followed by a colon, whereas error and error_at_line print the - whole path to the program. Since the whole path depends on the - working directory used to build and test glibc, remove it from the - comparison against the expected result. */ - const char *needle = "tst-ldbl-error:"; + /* Filter out the name of the program (which should always end with + -error), so that the test case can be reused by ldbl-opt and + ldbl-128ibm-compat. */ + const char *needle = "-error:"; char *message; message = strstr (result.err.buffer, needle); + if (message == NULL) + FAIL_EXIT1 ("test case error"); + message += strlen (needle); /* Verify that the output message is as expected. */ TEST_COMPARE_STRING (message, expected); @@ -104,12 +105,12 @@ static int do_test (void) { struct tests tests[] = { - { &callback_err, "tst-ldbl-error: -1.000000: Success\n" }, - { &callback_errx, "tst-ldbl-error: -1.000000\n" }, - { &callback_verr, "tst-ldbl-error: -1.000000: Success\n" }, - { &callback_verrx, "tst-ldbl-error: -1.000000\n" }, - { &callback_error, "tst-ldbl-error: -1.000000\n" }, - { &callback_error_at_line, "tst-ldbl-error::0: -1.000000\n" } + { &callback_err, " -1.000000: Success\n" }, + { &callback_errx, " -1.000000\n" }, + { &callback_verr, " -1.000000: Success\n" }, + { &callback_verrx, " -1.000000\n" }, + { &callback_error, " -1.000000\n" }, + { &callback_error_at_line, ":0: -1.000000\n" } }; for (int i = 0; i < sizeof (tests) / sizeof (tests[0]); i++) diff --git a/misc/tst-ldbl-warn.c b/misc/tst-ldbl-warn.c index 7d15b55db8..90375a97ea 100644 --- a/misc/tst-ldbl-warn.c +++ b/misc/tst-ldbl-warn.c @@ -59,9 +59,21 @@ do_one_test (int select, const char *format, va_list args, stderr = old_stderr; - /* Close the in-memory stream and check the output buffer. */ + /* Close the in-memory stream. */ xfclose_memstream (&stream); - TEST_COMPARE_STRING (stream.buffer, expected); + + /* Filter out the name of the program (which should always end with + warn), so that the test case can be reused by ldbl-opt and + ldbl-128ibm-compat. */ + const char *needle = "warn: "; + char *message; + message = strstr (stream.buffer, needle); + if (message == NULL) + FAIL_EXIT1 ("test case error"); + message += strlen (needle); + + /* Check that the rest of the output is as expected. */ + TEST_COMPARE_STRING (message, expected); if (stream.buffer != NULL) free (stream.buffer); @@ -74,13 +86,11 @@ do_test_call_varg (const char *format, ...) va_start (args, format); do_one_test (VWARN, format, args, 0, 0, 0, 0, - "tst-ldbl-warn: " "-1.000000 - -2.000000 - -3.000000 - -4.000000: Success\n"); va_end (args); va_start (args, format); do_one_test (VWARNX, format, args, 0, 0, 0, 0, - "tst-ldbl-warn: " "-1.000000 - -2.000000 - -3.000000 - -4.000000\n"); va_end (args); } @@ -92,10 +102,8 @@ do_test_call_rarg (const char *format, long double arg1, double arg2, va_list args; memset (&args, 0, sizeof (args)); do_one_test (WARN, format, args, arg1, arg2, arg3, arg4, - "tst-ldbl-warn: " "-1.000000 - -2.000000 - -3.000000 - -4.000000: Success\n"); do_one_test (WARNX, format, args, arg1, arg2, arg3, arg4, - "tst-ldbl-warn: " "-1.000000 - -2.000000 - -3.000000 - -4.000000\n"); } diff --git a/sysdeps/ieee754/ldbl-opt/Makefile b/sysdeps/ieee754/ldbl-opt/Makefile index 8a2c129f5f..791a5eabd2 100644 --- a/sysdeps/ieee754/ldbl-opt/Makefile +++ b/sysdeps/ieee754/ldbl-opt/Makefile @@ -189,3 +189,19 @@ $(objpfx)tst-nldbl-argp.c: tst-ldbl-argp.c CFLAGS-tst-nldbl-argp.c += -mlong-double-64 endif + +# Tests for err.h and error.h functions (reusing the relevant tests from +# misc/). +ifeq ($(subdir), misc) +tests-internal += tst-nldbl-warn +tests-internal += tst-nldbl-error + +$(objpfx)tst-nldbl-warn.c: tst-ldbl-warn.c + cp $< $@ + +$(objpfx)tst-nldbl-error.c: tst-ldbl-error.c + cp $< $@ + +CFLAGS-tst-nldbl-warn.c += -mlong-double-64 +CFLAGS-tst-nldbl-error.c += -mlong-double-64 +endif -- 2.14.5