MCPcopy Index your code
hub / github.com/containerd/containerd / TestFSMountsOverlayWithEROFSDevices

Function TestFSMountsOverlayWithEROFSDevices

internal/fsview/mount_test.go:259–359  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

257}
258
259func TestFSMountsOverlayWithEROFSDevices(t *testing.T) {
260 skipIfNoMkfsErofs(t)
261
262 tc := tartest.TarContext{}.WithModTime(time.Now().UTC())
263
264 // Layer 1 (bottom): regular files including ones that will be hidden
265 layer1Path := makeEROFSFromTar(t, tartest.TarAll(
266 tc.Dir("dir", 0755),
267 tc.File("dir/file1.txt", []byte("file1 content"), 0644),
268 tc.File("dir/file2.txt", []byte("file2 content"), 0644),
269 tc.File("dir/file5.txt", []byte("file5 content"), 0644),
270 tc.Dir("opaquedir", 0755),
271 tc.File("opaquedir/old.txt", []byte("old content"), 0644),
272 ))
273
274 // Layer 2 (top): new files, a whiteout for file5.txt, and an opaque opaquedir.
275 // AUFS-style markers (.wh.*) are converted by mkfs.erofs --aufs to
276 // overlay-native whiteouts (char dev 0:0) and opaque xattrs.
277 layer2Path := makeEROFSFromTar(t, tartest.TarAll(
278 tc.Dir("dir", 0755),
279 tc.File("dir/file3.txt", []byte("file3 content"), 0644),
280 tc.File("dir/.wh.file5.txt", []byte{}, 0644),
281 tc.Dir("opaquedir", 0755),
282 tc.File("opaquedir/.wh..wh..opq", []byte{}, 0644),
283 tc.File("opaquedir/new.txt", []byte("new content"), 0644),
284 ))
285
286 // Merge with layer1 as lower (first arg) and layer2 as upper (last arg)
287 // so whiteouts in layer2 apply to layer1.
288 metaPath := mergeEROFSLayers(t, layer1Path, layer2Path)
289
290 // Create upper directory with additional and override files
291 upperDir := filepath.Join(t.TempDir(), "upper")
292 if err := os.MkdirAll(filepath.Join(upperDir, "dir"), 0755); err != nil {
293 t.Fatal(err)
294 }
295 if err := os.WriteFile(filepath.Join(upperDir, "dir", "file4.txt"), []byte("file4 content"), 0644); err != nil {
296 t.Fatal(err)
297 }
298 // Override file1.txt from lower layer
299 if err := os.WriteFile(filepath.Join(upperDir, "dir", "file1.txt"), []byte("file1 override"), 0644); err != nil {
300 t.Fatal(err)
301 }
302
303 v, err := fsview.FSMounts([]mount.Mount{
304 {
305 Type: "erofs",
306 Source: metaPath,
307 Options: []string{"ro", "device=" + layer1Path, "device=" + layer2Path},
308 },
309 {
310 Type: "format/overlay",
311 Source: "overlay",
312 Options: []string{
313 "upperdir=" + upperDir,
314 "lowerdir={{ mount 0 }}",
315 },
316 },

Callers

nothing calls this directly

Calls 14

TarAllFunction · 0.92
FSMountsFunction · 0.92
skipIfNoMkfsErofsFunction · 0.85
makeEROFSFromTarFunction · 0.85
mergeEROFSLayersFunction · 0.85
WithModTimeMethod · 0.80
DirMethod · 0.80
FatalMethod · 0.80
FileMethod · 0.65
MkdirAllMethod · 0.65
WriteFileMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…