failtest: avoid complaints about copying uninitializes memory. True, we don't actually use the "call", so omit it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
failtest: Remove memory leak Somewhat ironically, a path in failtest related to detecting leaks in the tested program itself leaks memory. This corrects it. Detected by Coverity. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Fix missing va_end()s This corrects several places in ccan where stdarg.h is used but there is a missing va_end(). You can get away with this on many platforms, but not all. Caught by Coverity scan. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
io failtest timer tools: fallout from time changes. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
failtest: fix warning [-Wformat] hi rusty, here is a trival path to fix warning [-Wformat]. Thanks. Tinggong Signed-off-by: Tinggong <wangtinggong@gmail.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
failtest, tools: update for new timespec-using ccan/time module.
antithread, failtest: use ccan/err instead of err.h.
failtest: compile fix for OpenBSD OpenBSD doesn't idempotent-wrap sys/mman.h, so when we #define mmap to an alternative, it fails to compile when sys/mman.h is included again. Workaround is not to #define mmap to add arguments on Open BSD.
failtest: don't assume FD_SETSIZE is maximum runtime fd. This breaks when rlimit is less. Unfortunately, valgrind (32 bit x86, 3.7.0.SVN, Ubuntu) fails to set the file limit properly on the test: reducing it to the obvious getrlimit/setrlimit/getrlimit works fine, so leaving diagnostics for another day.
tlist: remove type arg from tlist_top(), tlist_tail() With the type canary, it's unnecessary. Though the implementation is a bit more awkward since they longer map directly through to list_top/tail.
failtest: do trace via a FILE, not an fd. The current mix of writing to an fd doesn't mix as well with stderr/stdout. And writing to a FILE * is more portable.
failtest: add --trace to replace --tracepath This gives a much deeper insight into what failtest is doing; good for debugging failtest itself.
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: add comment about limitations of untracked pointers.
failtest: fix failpath on open. And separate out the code which follows --failpath so failtest_close() can use it too.
failtest: report failpath problems correctly. It was the wrong way around, and also it's better to show the whole remaining failpath rather than the current letter.
failtest: stop when leak detected. Don't continue when we report a leak: tell the parent it's a failure.
failtest: catch mmap. mmap can also fail on out-of-memory, and for the coming change to the way we save and restore files we want to know about them anyway.
failtest: fix --debugpath Calling failpath_string() here leaves the final letter randomly upper or lower-cased, since call->fail is uninitialized. This means we sometimes don't match the debug string. 1) Initialize call->fail here so it will match the debug string. 2) If our calls don't match --debugpath, abort. 3) Don't match the final letter (which may be upper or lower case) when checking we're still on the path. We could do better, but this is only a sanity-check anyway.
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.