wolfcw / libfaketime

libfaketime modifies the system time for a single application
https://github.com/wolfcw/libfaketime
GNU General Public License v2.0
2.71k stars 324 forks source link

libfaketime cannot fake std::chrono::system_clock with GCC 4.8.5 #448

Closed RCoeurjoly closed 9 months ago

RCoeurjoly commented 9 months ago

I am having the same problem as #176. I have tried with several versions of libfaketime:

  1. 0.9.9
  2. master (commit 0af80dd)
  3. commit c89582f (mentioned by @wolfcw in https://github.com/wolfcw/libfaketime/pull/302#issuecomment-786180198)

It fails in to catch the fake time with all three.

I am using the following command:

LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1 FAKETIME="2020-12-24 20:30:00" .test_faketime

The code is:

`#include

include

int main() { const auto today = std::chrono::system_clock::now(); const time_t tt = std::chrono::system_clock::to_time_t( today ); std::cout << "now: " << ctime(&tt) << std::endl; return 0; }`

wolfcw commented 9 months ago

did you enable INTERCEPT_SYSCALL in libfaketime's src/Makefile? As in #176, the problem is not reproducible, e.g., on Debian 12.4, so maybe the solution over there might also work on your system. If it does not, more information on your target system and the used libraries would be needed.

RCoeurjoly commented 9 months ago

enabling INTERCEPT_SYSCALL I get a good result with FAKETIME, but not with FAKETIME_TIMESTAMP_FILE. I will close this issue and open another one. Thanks!

RCoeurjoly commented 9 months ago

Closed.