Rusty Russell [Tue, 1 Mar 2011 05:31:20 +0000 (16:01 +1030)]
ccanlint: handle weird directories.
David Gibson reports (and I confirmed) that running ccanlint in /tmp
causes an very uninformative segv. Fix that, and add a more useful message,
as well as delaying recursing until we're confident there's code around.
Rusty Russell [Thu, 24 Feb 2011 02:50:01 +0000 (13:20 +1030)]
ccanlint: fix more potential segvs when reporting ccanlint errors.
When I changed score_file_error() to printf-style, I didn't audit all
the callers who were handing string literals. I've finally done that;
I should have broken the compile by renaming it.
Rusty fails refactoring 101. Reported-by: Andreas Schlick
Joey Adams [Sat, 19 Feb 2011 10:36:14 +0000 (05:36 -0500)]
darray: Renamed array module to darray and made several improvements.
* Removed talloc support.
* Added a synopsis and rearranged macro definitions.
* Switched allocation strategy from increments of 64 to powers of 2.
* Replaced array_for and array_rof with the more useful
and portable macros array_foreach and array_foreach_reverse.
* Added typedefs array_* for common types.
Rusty Russell [Tue, 15 Feb 2011 13:01:29 +0000 (23:31 +1030)]
failtest: hook can return FAIL_PROBE
tdb2 has various places where it recovers from failure (eg. falling
back when it can't open /dev/urandom, or allocation for error
logging). We want to test those paths, but doing so thoroughly causes
cominatorial explosion.
Add FAIL_PROBE for such cases: in this case it goes only 3 more calls
deep.
Rusty Russell [Tue, 15 Feb 2011 12:55:03 +0000 (23:25 +1030)]
failtest: don't insist parents and children write the same thing to files.
We insist they write the same things to pipes, since we can't "undo" them,
but strictly speaking we don't care if they write different things into
files.
Rusty Russell [Tue, 15 Feb 2011 12:53:16 +0000 (23:23 +1030)]
failtest: save entire file contents.
The idea of saving files as we do writes doesn't work with mmap: this just
saves the entire contents of all open files before forking child, and
restores them afterwards.
Rusty Russell [Tue, 15 Feb 2011 12:51:42 +0000 (23:21 +1030)]
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.
Sam Vilain [Tue, 22 Feb 2011 04:56:36 +0000 (15:26 +1030)]
net: fix tests on hosts where 'localhost' is v4 _and_ v6
If 'localhost' exists in /etc/hosts with a v4 and a v6 address, the hack
which joins two addrinfo entries together is not necessary. Detect to see
if 'localhost' returned a v6 address, and if so, just return the single
linked list result from getaddrinfo()
(Reworked by Rusty Russell) Signed-off-by: Sam Vilain <sam@vilain.net>
Joel Stanley [Mon, 7 Feb 2011 04:06:15 +0000 (14:36 +1030)]
opt: Fix -Wmissing-field-initializers warning
OPT_ENDTABLE does not initalise all the elements in stuct opt_table.
When compliling with -Wextra -Wmissing-field-initializers is enabled,
which produces the following warning:
iviewiir.c:299:9: error: missing field 'cb' initializer
[-Wmissing-field-initializers]
OPT_ENDTABLE
^
In file included from iviewiir.c:12:
./ccan/opt/opt.h:82:38: note: instantiated from:
#define OPT_ENDTABLE { NULL, OPT_END }
^
By changing the definition of OPT_ENDTABLE to initalise all 7 elements
of struct opt_table, the warning is silenced.
Rusty Russell [Sat, 29 Jan 2011 07:42:20 +0000 (18:12 +1030)]
net: fix latent bug in _info example.
Ben Hutchings points out that struct sockaddr isn't large enough to hold
a struct sockaddr_in6. Our example works because we only access the family
field, but anyone extending it might be surprised; use a union instead.
Rusty Russell [Thu, 20 Jan 2011 01:01:11 +0000 (11:31 +1030)]
ccanlint: don't collect results from test children
This confuses the output, and makes us sometimes see spurious
failure. At least we will still catch valgrind errors in
children of failtest, thanks to --error-exitcode=101.
Rusty Russell [Sun, 9 Jan 2011 02:49:15 +0000 (13:19 +1030)]
ccanlint: -k should not pollute module directory.
It leads to numerous problems, such as the next ccanlint getting confused
trying to compile examples, and "-k examples_compile -k examples_exist"
giving bogus errors.
So instead we leave the temporary dir lying around and delete
individual files which aren't marked "keep".
Rusty Russell [Mon, 17 Jan 2011 05:50:15 +0000 (16:20 +1030)]
ccanlint: check examples actually mention thing they are demonstrating.
Brad suggested this after finding one such cut & paste in str:
rusty@vivaldi:~/devel/cvs/ccan/ccan/str$ ../../tools/ccanlint/ccanlint
Example: sections demonstrate appropriate function (examples_relevant): FAIL
/home/rusty/devel/cvs/ccan/ccan/str/str.h:64:Example for strcount doesn't mention it
Total score: 37/38
Rusty Russell [Mon, 17 Jan 2011 05:47:49 +0000 (16:17 +1030)]
ccanlint: score_file_error() takes printf-format
We simply build up the error string in score_file_error; a bit different
but simpler than current behaviour. We keep around struct file_error
because some tests need it.
Rusty Russell [Thu, 13 Jan 2011 08:55:01 +0000 (19:25 +1030)]
htable: fix type of cmpfn in htable_type
It in fact takes an object and a key to compare, not two keys.
The test case had the key as first element of the object, so it worked,
but ccanlint lost track of module dependencies due to this bug, and thus
would build submodules multiple times.
Rusty Russell [Mon, 10 Jan 2011 05:17:24 +0000 (15:47 +1030)]
rbtree: don't use temporary context to destroy rbtree
It leads to a memory leak if the allocation fails (as we reparent onto NULL).
Also, the extra allocation in the failure path increases test time for
failtest (under valgrind) by a factor of 2.
Rusty Russell [Mon, 10 Jan 2011 05:53:46 +0000 (16:23 +1030)]
rbtree: use failtest to check handling of allocation failures.
Unfortunately this means we have to reduce run-many from 1000 nodes to 100
(as forking under valgrind is really slow: test takes about 2 minutes with
100 nodes).
this is the minimal fix for the problem Rusty found. I previously
thought that the best fix would be to change tc->parent to be valid
for all pointers, but that is expensive for realloc with large numbers
of child pointers, which is much more commmon than I expected it to
be.