Hacker News new | ask | show | jobs
by rmetzler 696 days ago
For linux, there is faketime, which will set a specific date and time for all child processes. This enables you to test software you don't even compile for time-based problems, e.g. logic around Feb 29th or daylight saving time.
2 comments

Since go don’t use the libc related time functions on linux, but rather makes syscalls directly, faketime will not work for any programs written in Go.
Thank you for clarifying.
LD_PRELOAD is bit yucky though in my opinion. I suppose ptrace is the only other option though :/
It's not the only other option! It's not less yucky, but you can creatively stomp on the vDSO functions which back the time-related functions (gettimeofday, clock_gettime, time); I've written about it at [0] and have a "library" (more like a proof of concept) at [1].

[0]: https://blog.davidv.dev/posts/cursing-a-process-vdso-for-tim...

[1]: https://github.com/DavidVentura/tpom