In revision 648ed6360b2b7cda81a6079b00dc436d09c745b8 of ATF, there have been several bug fixes regarding the clean up of work directories. These bug fixes are related to dealing with race conditions that may arise, and Kyua needs to deal with them as well.
Basically, during cleanup, any errors raised should not stop the cleanup. Some of these errors can be ignored (like failing to scan the contents of a directory iff the directory itself can be removed) and some other errors can be retried a few times after a grace period. No matter what, unrecoverable errors during cleanup (i.e. errors that prevent us from cleaning the work directory altogether) should report the test case as broken, not crash the runtime engine. (Kyua most likely does not crash in these conditions, but an "expected" exception propagates too high up the call chain and that's not desired.)
Lastly, we also need to implement unmounting of directories within the work directory.
Testing for this functionality is quite tricky and unportable. While I
think the new code should do the right thing and cover the problems we
discovered before in atf-run, I'm not sure it does. I still have to try
this on the NetBSD tests to see how things go.