failtest, rbuf: fix up incorrect lseek arg order. SEEK_SET == 0, so it's not hurting anyone now, but when I cut & paste it elsewhere... Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
failtest: save and restore file state inside child (on-demand) We currently save all files in the parent, and restore them once the child is gone. That doesn't work in a case where the child manipulates a file the parent doesn't currently have open, so switch to a model where the child cleans itself up, using the already-existing cleanup callbacks. This means that we need to undo much more, especially restoring file offsets. We also need to handle the case where we've already closed the file, and now we're cleaning up. As a bonus, we now handle open() with O_TRUNC properly. The cleanup function now has two modes: one simply frees (so valgrind doesn't complain about failtest leaking so the user can see real leaks in their programs), the other restores things so the parent sees no changes.
failtest: internally eliminate duplicate calls. If we can get a backtrace, we can automatically eliminate identical failures. Surprisingly backtrace() is quite fast, but the savings for the (naively-written) rbtree tests are impressive. ccanlint -v time drops from 43 seconds to 6 seconds.
failtest: fix fascist warn_unused_result warnings
failtest: record close events We trap them, might as well put them in history. This also makes tracking open file descriptors more robust.
failtest: generic cleanup hooks Each function in the history stores a cleanup function, rather than storing extra structures. In particular, we save writes and file offsets using this.
failtest: handle 2-argument open()