(t *testing.T)
| 105 | } |
| 106 | |
| 107 | func 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 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…