(t *testing.T, fsType string)
| 40 | } |
| 41 | |
| 42 | func testLookup(t *testing.T, fsType string) { |
| 43 | testutil.RequiresRoot(t) |
| 44 | mnt := t.TempDir() |
| 45 | |
| 46 | loop, err := loopback.New(100 << 20) // 100 MB |
| 47 | if err != nil { |
| 48 | t.Fatal(err) |
| 49 | } |
| 50 | if out, err := exec.Command("mkfs", "-t", fsType, loop.Device).CombinedOutput(); err != nil { |
| 51 | // not fatal |
| 52 | loop.Close() |
| 53 | t.Skipf("could not mkfs (%s) %s: %v (out: %q)", fsType, loop.Device, err, string(out)) |
| 54 | } |
| 55 | if out, err := exec.Command("mount", loop.Device, mnt).CombinedOutput(); err != nil { |
| 56 | // not fatal |
| 57 | loop.Close() |
| 58 | t.Skipf("could not mount %s: %v (out: %q)", loop.Device, err, string(out)) |
| 59 | } |
| 60 | defer func() { |
| 61 | testutil.Unmount(t, mnt) |
| 62 | loop.Close() |
| 63 | }() |
| 64 | assert.True(t, strings.HasPrefix(loop.Device, "/dev/loop")) |
| 65 | checkLookup(t, fsType, mnt, mnt) |
| 66 | |
| 67 | newMnt := t.TempDir() |
| 68 | |
| 69 | if out, err := exec.Command("mount", "--bind", mnt, newMnt).CombinedOutput(); err != nil { |
| 70 | t.Fatalf("could not mount %s to %s: %v (out: %q)", mnt, newMnt, err, string(out)) |
| 71 | } |
| 72 | defer func() { |
| 73 | testutil.Unmount(t, newMnt) |
| 74 | }() |
| 75 | checkLookup(t, fsType, newMnt, newMnt) |
| 76 | |
| 77 | subDir := filepath.Join(newMnt, "subDir") |
| 78 | err = os.MkdirAll(subDir, 0700) |
| 79 | if err != nil { |
| 80 | t.Fatal(err) |
| 81 | } |
| 82 | checkLookup(t, fsType, newMnt, subDir) |
| 83 | } |
| 84 | |
| 85 | func TestLookupWithExt4(t *testing.T) { |
| 86 | testLookup(t, "ext4") |
no test coverage detected
searching dependent graphs…