wolfcw / libfaketime

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

Advanced timestamp format "YYYY-MM-DD hh:mm:ss" with value '1970-01-01 00:00:00 utc' returns 1 instead of 0 very rarely #462

Closed amansehgal0u2 closed 4 months ago

amansehgal0u2 commented 4 months ago

reproduced with

counter=0;
while true; do
  t1=$(external/faketime/faketime '1970-01-01 00:00:00 utc' date +%s)
  t2=$(external/faketime/faketime '1970-01-01 00:00:00 utc' date +%s)
  if [ "$t1" != "$t2" ]; then
    echo "times do not match!"
    echo "t1: $t1"
    echo "t2: $t2"
    echo "failed on iteration $counter"
    exit 0
  fi
  ((counter++))
done

this will cause t2 to be 1 which is unexpected

amansehgal0u2 commented 4 months ago

need to use -f option. Read through the code and realized the problem. Closing.