Skip to content

Instantly share code, notes, and snippets.

@ahmetb ahmetb/Mtim is updated
Last active Aug 29, 2015

Embed
What would you like to do?
50% chance Mtim field doesn't get updated
root@e25213faeb41:/go/src/github.com/docker/docker# go test -v github.com/docker/docker/pkg/archive -run TestChangesDirsMutated
=== RUN TestChangesDirsMutated
--- PASS: TestChangesDirsMutated (0.11 seconds)
changes_test.go:208: Lstat(old): &{name:symlink2 size:7 mode:134218239 modTime:{sec:63551388019 nsec:33650046 loc:0x6f8f40} sys:0xc208048510}
changes_test.go:209: Lstat(new): &{name:symlink2 size:13 mode:134218239 modTime:{sec:63551388019 nsec:43652546 loc:0x6f8f40} sys:0xc208048630}
changes_test.go:210: sameFsTime=false, expected=false
changes_test.go:212: stat(old): &{Dev:34 Ino:171198 Nlink:1 Mode:41471 Uid:0 Gid:0 X__pad0:0 Rdev:0 Size:7 Blksize:4096 Blocks:0 Atim:{Sec:1415791219 Nsec:33650046} Mtim:{Sec:1415791219 Nsec:33650046} Ctim:{Sec:1415791219 Nsec:43652546} X__unused:[0 0 0]}
changes_test.go:213: stat(new): &{Dev:34 Ino:172134 Nlink:1 Mode:41471 Uid:0 Gid:0 X__pad0:0 Rdev:0 Size:13 Blksize:4096 Blocks:0 Atim:{Sec:1415791219 Nsec:43652546} Mtim:{Sec:1415791219 Nsec:43652546} Ctim:{Sec:1415791219 Nsec:43652546} X__unused:[0 0 0]}
changes_test.go:214: sameFsTimespec=false, expected=false
PASS
diff --git a/pkg/archive/changes_test.go b/pkg/archive/changes_test.go
index 34c0f0d..3b10507 100644
--- a/pkg/archive/changes_test.go
+++ b/pkg/archive/changes_test.go
@@ -1,6 +1,7 @@
package archive
import (
+ "syscall"
"io/ioutil"
"os"
"os/exec"
@@ -179,6 +180,14 @@ func mutateSampleDir(t *testing.T, root string) {
}
// Change a symlink
+ stat1,err := os.Lstat(path.Join(root, "symlink2"))
+ if err != nil { t.Fatal(err) }
+
+ s1 := &syscall.Stat_t{}
+ err = syscall.Lstat(path.Join(root, "symlink2"), s1)
+ if err != nil { t.Fatal(err) }
+ ss1 := FromStat_t(s1)
+
if err := os.RemoveAll(path.Join(root, "symlink2")); err != nil {
t.Fatal(err)
}
@@ -186,6 +195,23 @@ func mutateSampleDir(t *testing.T, root string) {
t.Fatal(err)
}
+ stat2, err := os.Lstat(path.Join(root, "symlink2"))
+ if err != nil { t.Fatal(err) }
+
+ s2 := &syscall.Stat_t{}
+ err = syscall.Lstat(path.Join(root, "symlink2"), s2)
+ if err != nil { t.Fatal(err) }
+ ss2 := FromStat_t(s2)
+
+ t.Logf("Lstat(old): %+v", stat1)
+ t.Logf("Lstat(new): %+v", stat2)
+ t.Logf("sameFsTime=%v, expected=false\n", sameFsTime(stat1.ModTime(), stat2.ModTime()))
+
+ t.Logf("stat(old): %+v", s1)
+ t.Logf("stat(new): %+v", s2)
+ t.Logf("sameFsTimespec=%v, expected=false", sameFsTimeSpec(ss1.GetLastModification(), ss2.GetLastModification()))
+
+
// Replace dir with file
if err := os.RemoveAll(path.Join(root, "dir2")); err != nil {
t.Fatal(err)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.