Poco test using clock_gettime() and gettimeofday()

David Stacey drstacey@tiscali.co.uk
Sat Nov 15 16:57:00 GMT 2014


I'm trying to get the (rather extensive) testsuite for poco-1.4.7 
passing - or at least satisfying myself that any failures are not due to 
a Cygwin problem. The last test I have to worry about is 'testDequeue' 
from the Foundation testsuite.

The Poco code uses two clock classes, one that uses clock_getttime() and 
the other uses gettimeofday(). The test creates two timestamps using the 
two clock classes, both 0.1 seconds in the future. clock_gettime() is 
polled repeatedly until the timestamp is reached. Then the other 
timestamp is checked (using gettimeofday()) to ensure that 0.1 seconds 
has elapsed on this clock also.

I've managed to condense this down into the sample programme attached. 
This always passes in Fedora 20, but passes or fails randomly in Cygwin.

I'm not convinced that the test is valid. Poco seems to be making 
assumptions about clock_gettime() and gettimeofday() that simply aren't 
guaranteed to hold - but obviously do in Fedora at least. For instance, 
the test must be assuming that either the accuracy of the two routines 
is identical, or be making assumptions about rounding in the less 
accurate routine.

I think it would be better to patch the test so that it uses 
clock_gettime() exclusively (and not gettimeofday() at all), and then 
this problem will disappear. But I thought I would submit it here to see 
what you thought before raising a ticket with the Poco developers.

What do you think?

Dave.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: timer_test.cpp
Type: text/x-c++src
Size: 2626 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20141115/26dc7f5a/attachment.bin>
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list