ATF-devel archive

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

Re: tests where exit is success

On Fri, Aug 6, 2010 at 12:30 PM, Antti Kantee <> wrote:
> On Fri Aug 06 2010 at 12:24:03 +0100, Julio Merino wrote:
>> On Wed, Aug 4, 2010 at 12:20 PM, Antti Kantee <> 
>> wrote:
>> > Hi,
>> >
>> > Is it possible to write a test case where success is determined by the
>> > test program exiting?  It is possible to define an expected failure
>> > where the test exits, but what about expected success?
>> A test program is assumed to pass when it exits.  Are you having
>> trouble with this?
> If it exits without returning from ATF_BODY you get the "test program
> exited succesfully but failed to write results" error.

Ah, very true.  Well, that's intended behavior.

>> > The simplest example is testing that exit(3) exits.
>> You'd fork+wait to validate exit call.
>> > However, I am
>> > working on something a little more complicated: a watchdog library.
>> Hmm, can you elaborate?  I'm afraid you'll have to go through some
>> fork/wait dance as mentioned above depending on what you are trying to
>> accomplish.
> Ah, ok.  The fork+wait dance will work.  I guess this is in demand little
> enough to make sense to add it to the atf api.

You mean that it should or should not be added to the api?

Testing exit() seems to be a pretty specific thing that does not
warrant specific support.  Actually, if you are expecting an exit, you
should be validating it explicitly somehow... and fork seems
appropriate!  (Allowing blind exits from anywhere in the test case
would not be appropriate.  atf-run really needs to see that the
results file was created to know that the test exited in a controlled

> Is the trick documented somewhere (apart from being documented in the
> list archives now ;)  ?

Nope.  Is it worth a FAQ entry?  Dunno where else to put such information :-/

Julio Merino

Home | Main Index | Thread Index | Old Index