Merge pull request #8046 from vbatts/vbatts-archive_preserve_hard_links

archive: preserve hardlinks in Tar and Untar
This commit is contained in:
unclejack
2014-10-29 22:04:23 +02:00
5 changed files with 261 additions and 21 deletions
+52
View File
@@ -101,6 +101,58 @@ func TestCommitNewFile(t *testing.T) {
logDone("commit - commit file and read")
}
func TestCommitHardlink(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-t", "--name", "hardlinks", "busybox", "sh", "-c", "touch file1 && ln file1 file2 && ls -di file1 file2")
firstOuput, _, err := runCommandWithOutput(cmd)
if err != nil {
t.Fatal(err)
}
chunks := strings.Split(strings.TrimSpace(firstOuput), " ")
inode := chunks[0]
found := false
for _, chunk := range chunks[1:] {
if chunk == inode {
found = true
break
}
}
if !found {
t.Fatalf("Failed to create hardlink in a container. Expected to find %q in %q", inode, chunks[1:])
}
cmd = exec.Command(dockerBinary, "commit", "hardlinks", "hardlinks")
imageID, _, err := runCommandWithOutput(cmd)
if err != nil {
t.Fatal(imageID, err)
}
imageID = strings.Trim(imageID, "\r\n")
cmd = exec.Command(dockerBinary, "run", "-t", "hardlinks", "ls", "-di", "file1", "file2")
secondOuput, _, err := runCommandWithOutput(cmd)
if err != nil {
t.Fatal(err)
}
chunks = strings.Split(strings.TrimSpace(secondOuput), " ")
inode = chunks[0]
found = false
for _, chunk := range chunks[1:] {
if chunk == inode {
found = true
break
}
}
if !found {
t.Fatalf("Failed to create hardlink in a container. Expected to find %q in %q", inode, chunks[1:])
}
deleteAllContainers()
deleteImages(imageID)
logDone("commit - commit hardlinks")
}
func TestCommitTTY(t *testing.T) {
cmd := exec.Command(dockerBinary, "run", "-t", "--name", "tty", "busybox", "/bin/ls")
if _, err := runCommand(cmd); err != nil {