Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F174273622
D58099.id182733.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D58099.id182733.diff
View Options
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 June 21, 2020
+.Dd July 26, 2026
.Dt ATF-CHECK 1
.Os
.Sh NAME
@@ -34,6 +34,7 @@
.Op Fl o Ar action:arg ...
.Op Fl e Ar action:arg ...
.Op Fl x
+.Op \&!
.Ar command
.Sh DESCRIPTION
.Nm
@@ -58,6 +59,16 @@
.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).
@@ -153,7 +164,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
@@ -898,13 +898,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));
else if (m_status_checks.size() > 1) {
// TODO: Remove this restriction.
throw atf::application::usage_error("Cannot specify -s more than once");
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
Details
Attached
Mime Type
text/plain
Expires
Fri, Oct 2, 10:29 PM (17 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40061162
Default Alt Text
D58099.id182733.diff (3 KB)
Attached To
Mode
D58099: atf-check: Add shortcut for not-exit:0
Attached
Detach File
Event Timeline
Log In to Comment