Tests and RNG

Chris Shoemaker c.shoemaker at cox.net
Fri Feb 24 09:44:14 EST 2006


On Fri, Feb 24, 2006 at 04:25:21PM +1100, cxl000 at hotmail.com wrote:
> My thinking was that it would be fairly easy to instrument the test (or
> qof) to log the initial seed and thus have it reported when the test
> failed and having the seed available would enable a developer to
> reproduce the problem which then makes it easier to find the root cause
> be it in the test code or application code.
> 
> If you re-initialize the RNG in the test and log this value then testing
> could be a simple as hardcode the seen for debugging purposes.

This is a good plan.  I'd suggest adding to src/test-core/test-stuff.c
a wrapper around srand that logs the seed and then prints it in
vfailure_args().

> However if it is not considered worthwhile I'll not send patches. ;-)

Please do.  However, quite honestly, that lack of RNG seed logging in
the tests is a pretty minor deficiency compared to the fact that the
tests simple don't exercise much of gnucash's API.  This is especially
frustrating for the code in src/engine/, which is a good candidate for
unit tests because a) it doesn't need a gui b) it's supposed to have
well-defined (ergo testable) semantics and c) some of it is subtle.

I know that writing good tests is a lot harder than logging the seed,
but in case someone's looking for a bigger job to do, I thought I'd
throw it out there.  You could start with the seed logging and then
continue from there.  :)

-chris


More information about the gnucash-devel mailing list