Here\'s a little test I\'ve written to verify that time does indeed only run forwards in Linux.
#include
#include
bool timeG
Time should not run backwards on real hardware; on a VM your mileage may vary.
In any case, your application should probably not assume that time doesn't run backwards by a very small amount (think, maybe 1 second).
Yes, clock_gettime is good but even that could run backwards in the case of faulty hardware (or a VM, as in your example).
I have seen a hardware bug make time run backwards (albeit very occasionally), it was a cause of some very peculiar problems.
In particular, anything which involves comparing file timestamps will go wrong when time goes backwards.