NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/51667



The following reply was made to PR bin/51667; it has been noted by GNATS.

From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: bin/51667
Date: Sun, 08 Apr 2018 03:31:33 +0700

 This is almost certainly because atf_check is just a shell function that
 calls atf_fail (if the checks fail), and atf_fail is just another shell function
 which (more or less) just does exit 1.
 
 ie: if the test is to fail, the shell running it exits with a "failed" status.
 
 Unfortunately, that is the shell running atf_fail (or atf_check) - some
 child sub-shell exiting with a failure status will only cause the correct
 behaviour for the test if the actual shell running the test also exits.
 
 In a pipeline, with /bin/sh (as allowed by posix, as it was the way the
 original Bourne sh did things) all the processes are run in a sub-shell
 (this is the same reason that
 
 	some_command | while whatever
 		do
 			var=foo
 		done
 
 neve results in var in the parent shell being set - the assignment happens
 in the sub-shell.
 
 That is, the sub-shell exits 1, causing a 1 exit status from the pipeline
 to be 1, but beyond that, the function just keeps on running.
 
 The same effect would be observed if one wanted to try
 
 	(atf-check -s exit:0 false)
 
 false exits with status 1, the "exit:0" test fails, so the test containg this
 check should fail, but it will not, because only the sub-shell exited, not
 the one running the test.
 
 I don't think there is anything that can be done about this, aside from
 just documenting it perhaps.   The alternative would be a major
 re-write of ATF.
 
 I would suggest closing this PR as "sh*t happens, can't be avoided"
 
 kre
 


Home | Main Index | Thread Index | Old Index