Opened 8 years ago

Closed 8 years ago

#1780 closed defect (fixed)

time.time() not accurate enough for some recent tests in xfrin

Reported by: jelte Owned by: jelte
Priority: medium Milestone: Sprint-20120320
Component: xfrin Version:
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: N/A
Sub-Project: DNS Feature Depending on Ticket:
Estimated Difficulty: 0 Add Hours to Ticket: 0
Total Hours: 0 Internal?: no

Description

This is not a *big* problem; the relevant tests merely need to check whether time has passed. But when calling time.time() twice, fast, the difference between them can get rounded down to 0.0 some of the time.

See for example:
http://git.bind10.isc.org/~tester/builder//BIND10-cppcheck/20120314083000-FreeBSD8-amd64-GCC/logs/unittests.out

The code that uses this value takes the possibility of 0 into account, btw, but the tests don't. The tests could potentially also fail if time went in a negative direction (which is possible if you change your system clock).

Subtickets

Change History (5)

comment:1 Changed 8 years ago by jelte

  • Owner changed from jelte to UnAssigned
  • Status changed from new to reviewing

Ready for review,

in the relevant tests, time.time() is temporarily replace by the function returned by get_fake_time_time(). After each test that uses this, it is restored to the original function (So as not to mess up unittest framework's concept of time).

Also renamed one test which had the same name as another test.

comment:2 Changed 8 years ago by jelte

  • Milestone changed from New Tasks to Sprint-20120320

oh well since I accidentally already did it, might as well put it in this sprint too

comment:3 Changed 8 years ago by stephen

  • Owner changed from UnAssigned to stephen

comment:4 Changed 8 years ago by stephen

  • Owner changed from stephen to jelte

Reviewed commit 5852324e1ad021881339e6ef4cb62611bdfc1b5a

Looks OK, please merge.

comment:5 Changed 8 years ago by jelte

  • Resolution set to fixed
  • Status changed from reviewing to closed

Thanks! Merged, closing ticket.

Note: See TracTickets for help on using tickets.