NetBSD Problem Report #58570
From www@netbsd.org Sat Aug 10 13:55:00 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits)
client-signature RSA-PSS (2048 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 29CC71A9242
for <gnats-bugs@gnats.NetBSD.org>; Sat, 10 Aug 2024 13:55:00 +0000 (UTC)
Message-Id: <20240810135458.E39941A9243@mollari.NetBSD.org>
Date: Sat, 10 Aug 2024 13:54:58 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: ATF_CHECK_ERRNO semantics and/or documentation is confusing
X-Send-Pr-Version: www-1.0
>Number: 58570
>Category: bin
>Synopsis: ATF_CHECK_ERRNO semantics and/or documentation is confusing
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Aug 10 14:00:00 +0000 2024
>Last-Modified: Sat Aug 10 18:35:01 +0000 2024
>Originator: Taylor R Campbell
>Release: current, 10, 9, ...
>Organization:
The NetATF Errnodation
>Environment:
>Description:
Every time I read or reach for ATF_CHECK_ERRNO or ATF_REQUIRE_ERRNO, I have to look at the documentation to confirm what they mean. That would be fine, except I don't understand what they are actually checking/requiring from the text in the man page:
ATF_CHECK_ERRNO() and ATF_REQUIRE_ERRNO() take, first, the error code
that the check is expecting to find in the errno variable and, second, a
boolean expression that, if evaluates to true, means that a call failed
and errno has to be checked against the first value.
So I have to look at the source code to confirm what they mean.
I think (I hope) what they mean is:
ATF_CHECK_ERRNO(EWOTSIT, foo() == -1) checks that foo() == -1 is true, _and_ that errno == EWOTSIT.
>How-To-Repeat:
read or reach for ATF_CHECK_ERRNO/ATF_REQUIRE_ERRNO
>Fix:
Yes, please!
Clarifying the language in the man page would save me a lot of time.
>Audit-Trail:
From: Christoph Badura <bad@bsd.de>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: bin/58570: ATF_CHECK_ERRNO semantics and/or documentation is
confusing
Date: Sat, 10 Aug 2024 18:43:30 +0200
No, it is trying to say that it checks that if foo() == -1, then (errno ==
EWOTSIT).
I believe the idea is being able that if something fails, errno has the
expected value.
--chris
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: bin/58570: ATF_CHECK_ERRNO semantics and/or documentation is confusing
Date: Sun, 11 Aug 2024 01:31:50 +0700
Date: Sat, 10 Aug 2024 16:45:02 +0000 (UTC)
From: Christoph Badura <bad@bsd.de>
Message-ID: <20240810164502.0E8C81A9244@mollari.NetBSD.org>
| No, it is trying to say that it checks that if foo() == -1, then (errno ==
| EWOTSIT).
Yes, it tests that, but it also expects that foo() will return -1, and
if it doesn't, the test has also failed.
| I believe the idea is being able that if something fails, errno has the
| expected value.
Yes, but to test that reliably, the something has to actually fail.
If something is coded (in a test) to fail, one might expect the test
writer to know why it should fail, and hence which errno value should
be produced. Testing something that you expect might work (and hence
must at least be plausibly correct) would make it difficult most of the
time to know what might cause the error when it fails, and hence which
errno value to expect.
kre
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.