wolfcw / libfaketime

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

Resetting timer should also reset shared memory #399

Closed sveyret closed 2 years ago

sveyret commented 2 years ago

Hi,

I have an issue using libfaketime. My use case is the following:

The problem is that I don’t manage times to be synchronized:

The only solution I found was to set FAKETIME_DONT_RESET in the app only, and update the library for it also reset the shared memory when start time is reset in the testing process. I can provide a PR.

wolfcw commented 2 years ago

Thanks, your PR with updating shared memory on reset looks good, and I will merge it. Sorry for the delay.

Also, I didn't quite understand whether your testing procedure restarts the application under test over and over again, or whether it is started only once and then the environment variable is updated for the child process. It might also be worth trying to not run the testing process under libfaketime, but only LD_PRELOAD libfaketime when the application under test ist started.

sveyret commented 2 years ago

Yes, we need to restart the application under test in order to test different scenarios at different times. We thought about not running the testing procedure under libfaktime, but this procedure needs to check at what time the tested application reacts, and it would be far more complicated to calculate that time instead of simply have it simulated also.

Thank you for merging the PR.