MCPcopy
hub / github.com/containerd/containerd / createLoopbackDevice

Function createLoopbackDevice

internal/dmverity/dmverity_test.go:187–207  ·  view source on GitHub ↗
(t *testing.T, dir string, size string)

Source from the content-addressed store, hash-verified

185}
186
187func createLoopbackDevice(t *testing.T, dir string, size string) (string, string) {
188 t.Helper()
189 file, err := os.CreateTemp(dir, "dmverity-tests-")
190 assert.NoError(t, err)
191
192 sizeInBytes, err := units.RAMInBytes(size)
193 assert.NoError(t, err)
194
195 err = file.Truncate(sizeInBytes * 2)
196 assert.NoError(t, err)
197
198 err = file.Close()
199 assert.NoError(t, err)
200
201 imagePath := file.Name()
202
203 loopDevice, err := mount.AttachLoopDevice(imagePath)
204 assert.NoError(t, err)
205
206 return imagePath, loopDevice
207}
208
209// waitForDevice waits for a device-mapper device to appear in /dev/mapper
210func waitForDevice(t *testing.T, devicePath string) {

Callers 1

TestDMVerityFunction · 0.70

Calls 4

AttachLoopDeviceFunction · 0.92
TruncateMethod · 0.65
CloseMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…