ATF-devel archive

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

Introducing the nofork branch


As you may know, ATF test programs create subprocesses to run the test
case code in an isolated manner.  While I think this is a nice thing,
it makes the internal framework code overly complicated (seriously)
and it makes debugging of failing test cases difficult.  Playing with
follow-fork-mode in gdb is not nice as others will attest, and test
work directories vanishing on a failure also cause headache.  I've
received several requests asking for a way to disable the forking.
And, people, here it is!  Sorry for the long delay in addressing these
concerns, but... it has been a tough change.

I've been working on an experimental branch,
org.NetBSD.atf.src.nofork, which basically gets rid of the forking and
simplifies a lot of code.  Let me restate it: this is EXPERIMENTAL.
Very experimental.  So far it is just a proof of concept, and the
top-level TODO.nofork file will tell you, roughly, why.

But "What is in the branch? -- you wonder.  If my memory serves well:

- Test programs no longer print a cryptic format
(application/X-atf-tcs) on a special file channel.  They can now print
whatever they want on the screen.  (For reasons below.)

- Test programs no longer write their status into a special file
descriptor.  Instead, they create a file with the results.  (New
semantics of the -r flag.)

- Test programs no longer isolate their test cases.  This means that
they will NOT create temporary directories nor sanitize the
environment any more.  Yes, running, by hand, a test case with
external dependencies will most likely yield different results
depending on where (machine, directory, user environment) it is run.

- atf-run has been adjusted to perform the test case isolation.
Result: there is now a single canonical place for what "isolation"
means.  Before, the three language bindings (C, C++ and shell) had to
be kept in sync with each other (read: not a nice thing to do at all).
 As a side effect, writing new bindings for other languages will be
much, much easier (read: trivial) from now on.

- Test programs no longer fork.  They run the test case code
in-process, and a crash of the test case will result in a crash of the
test program.

- Test programs are no longer able to run several test cases in a row.
 The execution of a test program now requires a test case name, and
that single test case is executed.

- atf-run forks test programs (as before), but now it forks once for
each test case.  This is to provide the per-test-case isolation that
we had before.

Expect many more changes to come before this can be merged mainline.
Some of these changes will further affect the public interfaces of
binaries and libraries.  But oh well, we are still at 0.7.

I believe this also has made, at least, atf-sh faster.  Unscientific
test: running atf's test suite took 1m 10s before on one of my
machines, and now it takes around 45s.  Expect other performance
improvements as the branch is polished.  (For example: atf-run blindly
tries to execute the cleanup part of each test case even if it is not
defined; this needs fixing.)

If you have made it this far, congratulations!  Your price: you can
grab the code from the monotone server at  See
the web site for more details on how
to proceed.

Comments welcome... and enjoy!

Julio Merino

Home | Main Index | Thread Index | Old Index