From patchwork Thu Aug 22 14:14:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1975568 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BeKe/84w; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4WqQFD6WWfz1ybW for ; Fri, 23 Aug 2024 00:14:40 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ACAD03871020 for ; Thu, 22 Aug 2024 14:14:38 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id BA063386074B for ; Thu, 22 Aug 2024 14:14:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BA063386074B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BA063386074B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724336065; cv=none; b=eitUg0BuNjB4tTrhoU7dWyw8Ej8dU8UYtBmOIMQzXKFx9yC2v2MxXi3/Pcw0WTar+Eo50H1D7rW+MrQNZYhjj+clt36vpmOnuRGO1tMdEuMv3LGh+qDNH+TzaIzD9wuJ+M3SRX/1ErcVr7gz0fSTdEv+anQQipiofdeuN0Ggpnc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724336065; c=relaxed/simple; bh=2cARWK+1hCZ73WioeOOFdiqmQkoRr1gPHjEv8Aevx1w=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=GBYrN6FEvqAuOC9e06H1ZQSM447EPJ4KtNhwhursFczGO1qw2j8h4tj5WKEtobR/C1B9w2TstKy8CgnuEQq0NE4xdMSZj1e8a8joQfSfEQr14n5x0lSbpmXwNtSs9alp/RXfi/kyF28BYBdEA4N5jNIUIboBZ+0GRrV+gMHiPjQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724336063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=9YEF2YvjFXnFTH0lpQdQLDoajaYzow++KrifK4o9MaI=; b=BeKe/84wPngnk6P6Pr6nBnAjD/mAr7zw6Yb508H7iWjCtx0wHZJf4MYEJhT3ymbEUFRrN7 nzPXAk6IIP1iOTZCHNXrF1XO5ZxLallZDubzO8yd+aPB1Y6cD/WBFwZL4NkKIxAcaJiTzl w3sOtdbgCyqwSItaSsBsOReUdTG+4xE= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-67-i_HsP6x3MbGCS8hfY2wQpg-1; Thu, 22 Aug 2024 10:14:22 -0400 X-MC-Unique: i_HsP6x3MbGCS8hfY2wQpg-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 87D391955BED for ; Thu, 22 Aug 2024 14:14:21 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.22]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A5584300019C for ; Thu, 22 Aug 2024 14:14:20 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH] support: Report errno constants in TEST_COMPARE failures Date: Thu, 22 Aug 2024 16:14:17 +0200 Message-ID: <875xrsr6fa.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org If the expression is errno, decode it as an errno constant using strerrorname_np. Reviewed-by: Arjun Shankar --- support/support_test_compare_failure.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/support/support_test_compare_failure.c b/support/support_test_compare_failure.c index ae73d200cd..dba79e413f 100644 --- a/support/support_test_compare_failure.c +++ b/support/support_test_compare_failure.c @@ -17,7 +17,9 @@ . */ #include +#include #include +#include #include static void @@ -31,7 +33,14 @@ report (const char *which, const char *expr, long long value, int positive, printf ("%lld", value); unsigned long long mask = (~0ULL) >> (8 * (sizeof (unsigned long long) - size)); - printf (" (0x%llx); from: %s\n", (unsigned long long) value & mask, expr); + const char *errno_constant = NULL; + if (strcmp (expr, "errno") == 0 + && positive && (unsigned long long int) value <= INT_MAX) + errno_constant = strerrorname_np (value); + printf (" (0x%llx", (unsigned long long) value & mask); + if (errno_constant != NULL) + printf (", %s", errno_constant); + printf ("); from: %s\n", expr); } void