[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/external/bsd/atf/dist/atf-sh
Julio Merino <julio%meroh.net@localhost> wrote:
>On Fri, Jan 10, 2014 at 1:39 AM, Christos Zoulas
>> Module Name: src
>> Committed By: christos
>> Date: Fri Jan 10 01:39:32 UTC 2014
>> Modified Files:
>> src/external/bsd/atf/dist/atf-sh: libatf-sh.subr
>> Log Message:
>> Undo previous; unfortunately the cleanup routine gets called in a different
>> shell so it can't cleanup stuff set in the environment of the first shell.
>What are you trying to fix?
In the test case for t_hostent in lib/libc/net/, the tests initially
contained the cleanup code after the test. If the test failed, then
the cleanup did not get called. So I decided to use the _cleanup()
feature of ATF. I ran the test with atf-run and the cleanup did
not work. I wanted to examine the single test case that failed and
I did not know how to run a single test case with atf-run. So I
ran the test directly. The cleanup code did not get called which
was unexpected. So I made that change and it worked for the most
part but not in the error case. Then I realized that all the tests
do set -e, so that makes the shell exit on error. That made me
realize that the reason the cleanup does not work when it gets
called from atf-run is because the cleanup is invoked in a separate
shell, so the state of the test is lost (like shell variables set
by the setup code). So I decided to set all the variables again
during the cleanup.
I would have preferred that the cleanup functionality was implemented
differently, running in the context of the shell that ran the test.
This could have been done by issuing a 'trap test_cleanup 0' before
invoking the test, instead of all the complex stuff that is currently
been done (unless I am missing something).
>I don't see how this prevents running tests in parallel. You just need
>to maintain one work directory for every test body/cleanup pair and
>delete the directory only after cleanup... and you cannot share work
>directories among tests anyway so you have to do that one way or
If I need to pass state between the body of the test function and
the cleanup function, where do I put that state?
Main Index |
Thread Index |