MCPcopy
hub / github.com/containerd/containerd / testLookup

Function testLookup

core/mount/lookup_linux_test.go:42–83  ·  view source on GitHub ↗
(t *testing.T, fsType string)

Source from the content-addressed store, hash-verified

40}
41
42func 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
85func TestLookupWithExt4(t *testing.T) {
86 testLookup(t, "ext4")

Callers 2

TestLookupWithExt4Function · 0.85
TestLookupWithXFSFunction · 0.85

Calls 5

checkLookupFunction · 0.85
FatalMethod · 0.80
CloseMethod · 0.65
UnmountMethod · 0.65
MkdirAllMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…