From patchwork Fri Jul 12 20:48:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 1960023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WLNxz3DmTz1xpd for ; Sat, 13 Jul 2024 06:49:43 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4CB043831252 for ; Fri, 12 Jul 2024 20:49:41 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by sourceware.org (Postfix) with ESMTP id 9C559383125C for ; Fri, 12 Jul 2024 20:48:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9C559383125C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orcam.me.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=orcam.me.uk ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9C559383125C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=78.133.224.34 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720817317; cv=none; b=FGmrZPp8aBKJnaF0wb80I3XSbzehJUasoBk6+bq65TIwL7evvKHGps9jTnCHwcIVFDsl6t3kdRWWwi6o5sI6cIjCUi/L3i5O23FnBYah1RRWV6DeSgnVexYnF43H9cGaRna97TPoNkymtQPdD99SChBJD6CTMG5OzEFg38GL/T4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720817317; c=relaxed/simple; bh=Dt2WaslfyxRCQtzfKth+ZyZkvnhg4AHY7q8hCivEKOs=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=eg8CpRpI81tvdxPTha9iWJIfmn3mlXlRDqlvfrq1K8jFOeRqsFf0v9ZMrxtxZl7bLSFZ60VSIfj+6TxvArLVaVNoJZSlZlcMmJKLvWawKIU6OJLX/oWm2R5piWzMFqiNfto6P88v4NNPwijQerc7zR7Bis8KajLZOcgLP54Z7Ro= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by angie.orcam.me.uk (Postfix, from userid 500) id D53F292009C; Fri, 12 Jul 2024 22:48:33 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id D0BF292009B; Fri, 12 Jul 2024 21:48:33 +0100 (BST) Date: Fri, 12 Jul 2024 21:48:33 +0100 (BST) From: "Maciej W. Rozycki" To: libc-alpha@sourceware.org cc: "Maciej W. Rozycki" Subject: [PATCH v5 2/4] posix: Use facilities in tst-truncate and tst-truncate64 In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-1162.8 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_INFOUSMEBIZ, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: "Maciej W. Rozycki" Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org From: Maciej W. Rozycki Remove local FAIL macro in favor to FAIL_RET from , which provides equivalent reporting, with the name of the file of the failure site additionally included, for the tst-truncate-common core shared between the tst-truncate and tst-truncate64 tests. --- New change in v5. --- posix/tst-truncate-common.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) glibc-tst-truncate-common-fail-ret-exit1.diff Index: glibc/posix/tst-truncate-common.c =================================================================== --- glibc.orig/posix/tst-truncate-common.c +++ glibc/posix/tst-truncate-common.c @@ -21,6 +21,8 @@ #include #include +#include + static void do_prepare (void); #define PREPARE(argc, argv) do_prepare () static int do_test (void); @@ -42,9 +44,6 @@ do_prepare (void) } } -#define FAIL(str) \ - do { printf ("error: %s (line %d)\n", str, __LINE__); return 1; } while (0) - static int do_test_with_offset (off_t offset) { @@ -54,35 +53,35 @@ do_test_with_offset (off_t offset) memset (buf, 0xcf, sizeof (buf)); if (pwrite (temp_fd, buf, sizeof (buf), offset) != sizeof (buf)) - FAIL ("write failed"); + FAIL_RET ("write failed"); if (fstat (temp_fd, &st) < 0 || st.st_size != (offset + sizeof (buf))) - FAIL ("initial size wrong"); + FAIL_RET ("initial size wrong"); if (ftruncate (temp_fd, offset + 800) < 0) - FAIL ("size reduction with ftruncate failed"); + FAIL_RET ("size reduction with ftruncate failed"); if (fstat (temp_fd, &st) < 0 || st.st_size != (offset + 800)) - FAIL ("size after reduction with ftruncate is incorrect"); + FAIL_RET ("size after reduction with ftruncate is incorrect"); /* The following test covers more than POSIX. POSIX does not require that ftruncate() can increase the file size. But we are testing Unix systems. */ if (ftruncate (temp_fd, offset + 1200) < 0) - FAIL ("size increate with ftruncate failed"); + FAIL_RET ("size increate with ftruncate failed"); if (fstat (temp_fd, &st) < 0 || st.st_size != (offset + 1200)) - FAIL ("size after increase is incorrect"); + FAIL_RET ("size after increase is incorrect"); if (truncate (temp_filename, offset + 800) < 0) - FAIL ("size reduction with truncate failed"); + FAIL_RET ("size reduction with truncate failed"); if (fstat (temp_fd, &st) < 0 || st.st_size != (offset + 800)) - FAIL ("size after reduction with truncate incorrect"); + FAIL_RET ("size after reduction with truncate incorrect"); /* The following test covers more than POSIX. POSIX does not require that truncate() can increase the file size. But we are testing Unix systems. */ if (truncate (temp_filename, (offset + 1200)) < 0) - FAIL ("size increase with truncate failed"); + FAIL_RET ("size increase with truncate failed"); if (fstat (temp_fd, &st) < 0 || st.st_size != (offset + 1200)) - FAIL ("size increase with truncate is incorrect"); + FAIL_RET ("size increase with truncate is incorrect"); return 0; }