Page MenuHomeFreeBSD

D58099.1794546133.diff
No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None

D58099.1794546133.diff

diff --git a/contrib/atf/atf-sh/atf-check.1 b/contrib/atf/atf-sh/atf-check.1
--- a/contrib/atf/atf-sh/atf-check.1
+++ b/contrib/atf/atf-sh/atf-check.1
@@ -22,7 +22,7 @@
.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.Dd August 13, 2026
+.Dd September 24, 2026
.Dt ATF-CHECK 1
.Os
.Sh NAME
@@ -35,6 +35,7 @@
.Op Fl e Ar action:arg ...
.Op Fl x
.Op Fl r Ar timeout[:interval]
+.Op \&!
.Ar command
.Sh DESCRIPTION
.Nm
@@ -60,6 +61,19 @@
.Ar empty
.Fl e
.Ar empty .
+If
+.Ar command
+is preceded by
+.Sq \&! ,
+it will default to
+.Fl s
+.Ar not-exit:0
+instead of
+.Fl s
+.Ar exit:0 .
+Multiple checks for the same output channel are allowed and, if specified,
+their results will be combined as a logical and (meaning that the output must
+match all the provided checks).
.Pp
.Fl o
.Ar empty
@@ -159,7 +173,7 @@
atf_check true
# Typical usage if failure is expected
-atf_check -s not-exit:0 false
+atf_check ! false
# Checking stdout/stderr
echo foobar >expout
diff --git a/contrib/atf/atf-sh/atf-check.cpp b/contrib/atf/atf-sh/atf-check.cpp
--- a/contrib/atf/atf-sh/atf-check.cpp
+++ b/contrib/atf/atf-sh/atf-check.cpp
@@ -910,13 +910,21 @@
int
atf_check::main(void)
{
+ bool negate = false;
+
+ while (m_argc > 0 && strcmp(m_argv[0], "!") == 0) {
+ negate = !negate;
+ m_argc--;
+ m_argv++;
+ }
+
if (m_argc < 1)
throw atf::application::usage_error("No command specified");
int status = EXIT_FAILURE;
if (m_status_checks.empty()) {
- m_status_checks.push_back(status_check(sc_exit, false, EXIT_SUCCESS,
+ m_status_checks.push_back(status_check(sc_exit, negate, EXIT_SUCCESS,
false));
} else if (m_status_checks.size() > 1) {
// TODO: Remove this restriction.
diff --git a/contrib/atf/atf-sh/atf-check_test.sh b/contrib/atf/atf-sh/atf-check_test.sh
--- a/contrib/atf/atf-sh/atf-check_test.sh
+++ b/contrib/atf/atf-sh/atf-check_test.sh
@@ -90,11 +90,17 @@
h_pass 'false' -s not-exit:0
h_pass 'exit 255' -s exit:255
h_pass 'exit 0' -s not-exit:255
+ h_pass 'false' !
+ h_pass 'true' ! !
+ h_pass 'false' ! ! !
h_fail 'exit 256' -s exit:256
h_fail 'exit -1' -s exit:-1
h_fail 'true' -s not-exit:256
h_fail 'true' -s not-exit:-1
+ h_fail 'true' !
+ h_fail 'false' ! !
+ h_fail 'true' ! ! !
h_pass 'true' -s exit
h_pass 'false' -s exit
diff --git a/contrib/atf/atf-sh/atf_check_test.sh b/contrib/atf/atf-sh/atf_check_test.sh
--- a/contrib/atf/atf-sh/atf_check_test.sh
+++ b/contrib/atf/atf-sh/atf_check_test.sh
@@ -207,6 +207,17 @@
|| atf_fail 'Second command not in output'
}
+atf_test_case negate
+negate_body()
+{
+ atf_check true
+ atf_check ! false
+ atf_check ! ! true
+ atf_check ! ! ! false
+ atf_check true !
+ atf_check -o inline:'!\n' echo !
+}
+
atf_init_test_cases()
{
atf_add_test_case info_ok
@@ -216,6 +227,7 @@
atf_add_test_case null_stderr
atf_add_test_case equal
atf_add_test_case flush_stdout_on_death
+ atf_add_test_case negate
}
# vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 13, 5:02 AM (11 m, 52 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41684132
Default Alt Text
D58099.1794546133.diff (3 KB)

Event Timeline