Eric Blake wrote: > On 04/05/2010 03:08 PM, Bruno Haible wrote: >> Jim Meyering wrote: >>> This could be an argument for wrapping some of the C-only tests in a >>> simple init.sh-using driver (maybe even automatically). Any test that >>> creates a temporary file would benefit. >> >> Yes, I agree: It would make things simpler and more robust if all tests >> that require temporary files would have a shell script as test driver. >> Among others, this would guarantee that temporary files get erased when >> the test gets interrupted with Ctrl-C. In theory, this can be done with >> a signal handler, but most tests are written in a minimal way and don't >> care about this. (Only tests/test-stat-time.c and tests/test-posix_spawn3.c >> install a signal handler for cleanup.) > > Many of my recent *at tests use a common idiom of removing such > temporary files if they happen to exist as garbage from a previous run, > but I agree that changing things over to a shell wrapper would relieve > the burden on the C code needing to be robust against Ctrl-C. On the > other hand, when debugging a test that hangs due to a platform bug, it > would be nice to keep the temporary files around. So if we do switch to > shell wrappers, it would be wise to make the cleanup traps use things > like ${RM=rm} rather than plain rm, to allow the use of RM=: as a way to > override the cleanup.
init.sh's trap calls its remove_tmp_ function. If you're debugging a test, you can override that definition with one that does nothing (say in init.cfg).