MCPcopy
hub / github.com/containerd/containerd / TestLoopbackOverlay

Function TestLoopbackOverlay

core/mount/manager/manager_linux_test.go:107–315  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

105}
106
107func TestLoopbackOverlay(t *testing.T) {
108 testutil.RequiresRoot(t)
109 ctx := logtest.WithT(context.Background(), t)
110 ctx = namespaces.WithNamespace(ctx, "test")
111 td := t.TempDir()
112 metadb := filepath.Join(td, "mounts.db")
113 targetdir := filepath.Join(td, "m")
114 db, err := bolt.Open(metadb, 0600, nil)
115 if err != nil {
116 t.Fatal(err)
117 }
118
119 l1 := fstest.Apply(
120 fstest.CreateFile("/foo", []byte("foo\n"), 0777),
121 fstest.CreateDir("/a", 0755),
122 fstest.CreateDir("/a/b", 0755),
123 fstest.CreateDir("/a/b/c", 0755),
124 )
125
126 l2 := fstest.Apply(
127 fstest.CreateFile("/foo", []byte("foo\n"), 0777),
128 fstest.CreateDir("/a", 0755),
129 fstest.CreateDir("/a/b", 0755),
130 fstest.CreateDir("/a/b/c", 0755),
131 )
132
133 for _, tc := range []struct {
134 name string
135 mounts func() ([]mount.Mount, error)
136 }{
137 {
138 name: "LoopOptions",
139 mounts: func() ([]mount.Mount, error) {
140 b1, err := initalizeBlockDevice(td, l1)
141 if err != nil {
142 return nil, err
143 }
144 b2, err := initalizeBlockDevice(td, l2)
145 if err != nil {
146 return nil, err
147 }
148 return []mount.Mount{
149 {
150 Type: "ext4",
151 Source: b1,
152 Options: []string{"loop"},
153 },
154 {
155 Type: "ext4",
156 Source: b2,
157 Options: []string{"loop"},
158 },
159 {
160 Type: "format/overlay",
161 Source: "overlay",
162 Options: []string{
163 "lowerdir={{ mount 1 }}:{{ mount 0 }}",
164 },

Callers

nothing calls this directly

Calls 15

ActivateMethod · 0.95
DeactivateMethod · 0.95
RequiresRootFunction · 0.92
WithNamespaceFunction · 0.92
LoopbackHandlerFunction · 0.92
AllFunction · 0.92
UnmountFunction · 0.92
initalizeBlockDeviceFunction · 0.85
WithMountHandlerFunction · 0.85
FatalMethod · 0.80
NewManagerFunction · 0.70
ApplyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…