[Development] date/time adjust for (auto) testing
Thiago Macieira
thiago.macieira at intel.com
Sat Jun 6 00:26:59 CEST 2015
On Wednesday 03 June 2015 08:38:48 André Somers wrote:
> Hi,
>
> We have applications that use the current date and time at places spread
> around the code. For normal operations, that works very nicely. However,
> we find that for (auto) testing, it would be very convenient if we could
> trick the application into believing it is some other date/time, so that
> we can test if certain behaviours work the way we would like to
> automatically. Currently, these tests take a lot of time because we
> actually need to manually adjust the system date and time, do some
> stuff, then adjust again, etc.
>
> It would be really confortable if there was some control to set a
> date/time offset (so the time keeps running) or a fixed date/time to be
> returned from currentDate(), currentTime() or currentDateTime()
> respectively. I guess access to such a thing does not belong in the main
> Qt classes, but is really a testing tool, so perhaps it could find
> refuge in QtTest somewhere. Would a contribution adding such a thing
> stand any chance of being accepted, or would this be considered out of
> scope or even unwanted?
Yes, I think so.
The only gotcha is that the functions that would most benefit from the feature
*are* the functions you mentioned. It would be so nice to properly test that
we handle daylight savings transitions correctly. So what functions /
functionality are you thinking of testing that would require this?
One way to do that is to use ELF interception of the glibc gettimeofday()
function. On Windows, interception is also possible, but requires a very ugly
hack.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list