2 ms·
> For example, you want to test that an entry in a caching library is indeed expiring entries like you wanted. How do you change the library to consume a time i
by MaulingMonkey 3y ago
> For example, you want to test that an entry in a caching library is indeed expiring entries like you wanted. How do you change the library to consume a time interface, if that library doesn't expose it to you?
Intercepting/hooking system APIs might be an option in some cases. You might even be able to use something someone else wrote. Some prior art for date/time stuff specifically (which I haven't used and thus can't vouch for:)
• https://manpages.ubuntu.com/manpages/trusty/man1/datefudge.1.html https://manpages.ubuntu.com/manpages/trusty/man1/datefudge.1...
• https://www.nirsoft.net/utils/run_as_date.html https://www.nirsoft.net/utils/run_as_date.html
More dynamic / finer grained hooking (e.g. perhaps targeting a single thread, within a function's scope, because you're not writing a command line tool that quickly exits) is likely to require a more manual touch.