Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
| ... | ... |
@@ -4,16 +4,18 @@ import ( |
| 4 | 4 |
"crypto/sha256" |
| 5 | 5 |
"encoding/hex" |
| 6 | 6 |
"fmt" |
| 7 |
- "github.com/docker/docker/daemon/graphdriver" |
|
| 8 |
- "github.com/docker/docker/pkg/archive" |
|
| 9 | 7 |
"io/ioutil" |
| 10 | 8 |
"os" |
| 11 | 9 |
"path" |
| 12 | 10 |
"testing" |
| 11 |
+ |
|
| 12 |
+ "github.com/docker/docker/daemon/graphdriver" |
|
| 13 |
+ "github.com/docker/docker/pkg/archive" |
|
| 13 | 14 |
) |
| 14 | 15 |
|
| 15 | 16 |
var ( |
| 16 |
- tmp = path.Join(os.TempDir(), "aufs-tests", "aufs") |
|
| 17 |
+ tmpOuter = path.Join(os.TempDir(), "aufs-tests") |
|
| 18 |
+ tmp = path.Join(tmpOuter, "aufs") |
|
| 17 | 19 |
) |
| 18 | 20 |
|
| 19 | 21 |
func testInit(dir string, t *testing.T) graphdriver.Driver {
|
| ... | ... |
@@ -640,8 +642,8 @@ func testMountMoreThan42Layers(t *testing.T, mountPath string) {
|
| 640 | 640 |
t.Fatal(err) |
| 641 | 641 |
} |
| 642 | 642 |
|
| 643 |
- d := testInit(mountPath, t).(*Driver) |
|
| 644 | 643 |
defer os.RemoveAll(mountPath) |
| 644 |
+ d := testInit(mountPath, t).(*Driver) |
|
| 645 | 645 |
defer d.Cleanup() |
| 646 | 646 |
var last string |
| 647 | 647 |
var expected int |
| ... | ... |
@@ -662,24 +664,24 @@ func testMountMoreThan42Layers(t *testing.T, mountPath string) {
|
| 662 | 662 |
|
| 663 | 663 |
if err := d.Create(current, parent); err != nil {
|
| 664 | 664 |
t.Logf("Current layer %d", i)
|
| 665 |
- t.Fatal(err) |
|
| 665 |
+ t.Error(err) |
|
| 666 | 666 |
} |
| 667 | 667 |
point, err := d.Get(current, "") |
| 668 | 668 |
if err != nil {
|
| 669 | 669 |
t.Logf("Current layer %d", i)
|
| 670 |
- t.Fatal(err) |
|
| 670 |
+ t.Error(err) |
|
| 671 | 671 |
} |
| 672 | 672 |
f, err := os.Create(path.Join(point, current)) |
| 673 | 673 |
if err != nil {
|
| 674 | 674 |
t.Logf("Current layer %d", i)
|
| 675 |
- t.Fatal(err) |
|
| 675 |
+ t.Error(err) |
|
| 676 | 676 |
} |
| 677 | 677 |
f.Close() |
| 678 | 678 |
|
| 679 | 679 |
if i%10 == 0 {
|
| 680 | 680 |
if err := os.Remove(path.Join(point, parent)); err != nil {
|
| 681 | 681 |
t.Logf("Current layer %d", i)
|
| 682 |
- t.Fatal(err) |
|
| 682 |
+ t.Error(err) |
|
| 683 | 683 |
} |
| 684 | 684 |
expected-- |
| 685 | 685 |
} |
| ... | ... |
@@ -689,28 +691,30 @@ func testMountMoreThan42Layers(t *testing.T, mountPath string) {
|
| 689 | 689 |
// Perform the actual mount for the top most image |
| 690 | 690 |
point, err := d.Get(last, "") |
| 691 | 691 |
if err != nil {
|
| 692 |
- t.Fatal(err) |
|
| 692 |
+ t.Error(err) |
|
| 693 | 693 |
} |
| 694 | 694 |
files, err := ioutil.ReadDir(point) |
| 695 | 695 |
if err != nil {
|
| 696 |
- t.Fatal(err) |
|
| 696 |
+ t.Error(err) |
|
| 697 | 697 |
} |
| 698 | 698 |
if len(files) != expected {
|
| 699 |
- t.Fatalf("Expected %d got %d", expected, len(files))
|
|
| 699 |
+ t.Errorf("Expected %d got %d", expected, len(files))
|
|
| 700 | 700 |
} |
| 701 | 701 |
} |
| 702 | 702 |
|
| 703 | 703 |
func TestMountMoreThan42Layers(t *testing.T) {
|
| 704 |
+ os.RemoveAll(tmpOuter) |
|
| 704 | 705 |
testMountMoreThan42Layers(t, tmp) |
| 705 | 706 |
} |
| 706 | 707 |
|
| 707 | 708 |
func TestMountMoreThan42LayersMatchingPathLength(t *testing.T) {
|
| 708 |
- tmp := "aufs-tests" |
|
| 709 |
+ defer os.RemoveAll(tmpOuter) |
|
| 710 |
+ zeroes := "0" |
|
| 709 | 711 |
for {
|
| 710 | 712 |
// This finds a mount path so that when combined into aufs mount options |
| 711 | 713 |
// 4096 byte boundary would be in between the paths or in permission |
| 712 |
- // section. For '/tmp' it will use '/tmp/aufs-tests00000000/aufs' |
|
| 713 |
- mountPath := path.Join(os.TempDir(), tmp, "aufs") |
|
| 714 |
+ // section. For '/tmp' it will use '/tmp/aufs-tests/00000000/aufs' |
|
| 715 |
+ mountPath := path.Join(tmpOuter, zeroes, "aufs") |
|
| 714 | 716 |
pathLength := 77 + len(mountPath) |
| 715 | 717 |
|
| 716 | 718 |
if mod := 4095 % pathLength; mod == 0 || mod > pathLength-2 {
|
| ... | ... |
@@ -718,6 +722,6 @@ func TestMountMoreThan42LayersMatchingPathLength(t *testing.T) {
|
| 718 | 718 |
testMountMoreThan42Layers(t, mountPath) |
| 719 | 719 |
return |
| 720 | 720 |
} |
| 721 |
- tmp += "0" |
|
| 721 |
+ zeroes += "0" |
|
| 722 | 722 |
} |
| 723 | 723 |
} |