Page MenuHomeFreeBSD

atf-check: Add shortcut for not-exit:0
AcceptedPublic

Authored by des on Jul 8 2026, 7:17 AM.
Tags
None
Referenced Files
F174273622: D58099.id182733.diff
Thu, Oct 1, 10:29 PM
F174199984: D58099.diff
Thu, Oct 1, 7:56 AM
F174182066: D58099.diff
Thu, Oct 1, 5:00 AM
Unknown Object (File)
Mon, Sep 28, 10:13 PM
Unknown Object (File)
Mon, Sep 28, 10:13 PM
Unknown Object (File)
Mon, Sep 28, 10:07 PM
Unknown Object (File)
Mon, Sep 21, 10:59 AM
Unknown Object (File)
Sun, Sep 20, 12:42 AM
Subscribers

Details

Reviewers
ngie
Group Reviewers
tests
Summary

Allow the command to be preceded by an exclamation point, which changes
the default expected result to a clean exit with a non-zero exit code.

MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 75149
Build 72032: arc lint + arc unit

Event Timeline

des requested review of this revision.Jul 8 2026, 7:17 AM

This is a really nice, simple feature request -- I love it!

The concern I have about this change is that ! is a shell builtin operator and this could cause confusion/result in bugs if someone tries to fun the command on the command line in certain shells where ! has special meanings in different contexts (we can't always assume atf-sh is running /bin/sh, unfortunately..).

How about atf_check -s '!0' false instead? If things were done that way the negation operator could be extended to -e and -o without any sort of ambiguity/confusion.

The concern I have about this change is that ! is a shell builtin operator and this could cause confusion/result in bugs if someone tries to fun the command on the command line in certain shells where ! has special meanings in different contexts (we can't always assume atf-sh is running /bin/sh, unfortunately..).

Can you provide an example?

How about atf_check -s '!0' false instead? If things were done that way the negation operator could be extended to -e and -o without any sort of ambiguity/confusion.

No, that completely negates the point of the patch.

This still feels ambiguous in a non-desirable way to me, but I can see the value in making this possible so I want to give this the space to get more feedback instead of me serving as an unnecessary impediment.

  • Please send out a message with a brief summary of the proposed change/asking for feedback to hackers@ and testing@.
  • Please add tests for the new feature:
    • Positive case: '! false' in m_argv[0]: negation behavior should be applied.
    • Negative case: 'true !' in m_argv[1]: negation behavior should not be applied.
  • I would leave existing tests that could be simplified with the new feature as-is until enough time has been given to get feedback on the new feature.
  • I would set the MFC timer to a higher value like 2 weeks or a month.

added tests, which option do you prefer @ngie?

ngie added inline comments.
contrib/atf/atf-sh/atf_check_test.sh
217

This seems possibly deserving of a comment: it might not be immediately clear to someone reading the test that true <foo> always succeeds.

This revision is now accepted and ready to land.Aug 7 2026, 7:54 PM