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

Function TestCompactLowerdirOption

core/mount/mount_linux_test.go:57–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

55}
56
57func TestCompactLowerdirOption(t *testing.T) {
58 tcases := []struct {
59 opts []string
60 commondir string
61 newopts []string
62 }{
63 // no lowerdir or only one
64 {
65 []string{"workdir=a"},
66 "",
67 []string{"workdir=a"},
68 },
69 {
70 []string{"workdir=a", "lowerdir=b"},
71 "",
72 []string{"workdir=a", "lowerdir=b"},
73 },
74
75 // >= 2 lowerdir
76 {
77 []string{"lowerdir=/snapshots/1/fs:/snapshots/10/fs"},
78 "/snapshots/",
79 []string{"lowerdir=1/fs:10/fs"},
80 },
81 {
82 []string{"lowerdir=/snapshots/1/fs:/snapshots/10/fs:/snapshots/2/fs"},
83 "/snapshots/",
84 []string{"lowerdir=1/fs:10/fs:2/fs"},
85 },
86
87 // if common dir is /
88 {
89 []string{"lowerdir=/snapshots/1/fs:/other_snapshots/1/fs"},
90 "",
91 []string{"lowerdir=/snapshots/1/fs:/other_snapshots/1/fs"},
92 },
93
94 // if common dir is .
95 {
96 []string{"lowerdir=a:aaa"},
97 "",
98 []string{"lowerdir=a:aaa"},
99 },
100 }
101
102 for i, tc := range tcases {
103 dir, opts := compactLowerdirOption(tc.opts)
104 if dir != tc.commondir {
105 t.Fatalf("[%d case] expected common dir (%s), but got (%s)", i+1, tc.commondir, dir)
106 }
107
108 if !reflect.DeepEqual(opts, tc.newopts) {
109 t.Fatalf("[%d case] expected options (%v), but got (%v)", i+1, tc.newopts, opts)
110 }
111 }
112}
113
114func TestFUSEHelper(t *testing.T) {

Callers

nothing calls this directly

Calls 1

compactLowerdirOptionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…