misc/cgo/testshared fails on fast enough machines that don't have fine-grained file timestamps #10724
Per #10571, let's not add 4 more seconds of sleep here. Death by a thousand cuts, straw camel back, etc.
I'd prefer to move this into Go code in src/cmd/dist/test.go and then it would be much easier to do things like sleep up to 1 second (measuring how long the previous commands took), and do things like check the inode for other changes, if applicable first. It's also easier to parallelize things in Go.
Most machines are fast enough to do all these steps in a second, I guess most people are using ext4 or something by now. I agree with @bradfitz that sleeps are not the answer. Maybe use https://godoc.org/os#Chtimes to push the times into the past?
I think and agree that in general moving file times backwards is the best guaranteed reliable way of doing this. You get full control without delays and without worrying about timestamp precision or the speed of operations.
But it turns out you can't push them too far into the past because then they are older than the compilers and everything gets rebuilt anyway :) Can you try the change at https://golang.org/cl/9768?
This change works for me. However, 'date -d ...' is not portable; it's a GNU date extension and is missing on (for example) FreeBSD, where 'date -d' means something completely different.
(You may already know this and just be trying out the approach to make sure it works.)
Can we please just move this to Go code in src/cmd/dist/test.go and not worry about portability of shell code? We already have a portable language.
Ever since it was introduced, one of my machines fails in misc/cgo/testshared when building git master. The failure message:
The ultimate cause is that this machine is fast enough to build (or finish building by writing the files out), touch a file, copy files, and rebuild, all in the same second, and my copy of the git repo is on a filesystem that only has timestamps with a one second granularity. In this situation you need to insert artificial delays of at least a second both before and after the touch-and-copy code in testshared:
The machine that this fails on is a 64-bit Fedora 21 machine using an ext3 filesystem (mounted with relatime, but I don't believe that makes any difference). On Linux, ext3 does not support nanosecond timestamps but ext4 and various other filesystems do to some extent.