MCPcopy Create free account
hub / github.com/containerd/nerdctl / TestLockFile

Function TestLockFile

pkg/internal/filesystem/lock_test.go:59–80  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func TestLockFile(t *testing.T) {
60 t.Parallel()
61
62 tempDir := t.TempDir()
63 lock, err := os.CreateTemp(tempDir, "lockfile")
64 assert.NilError(t, err, "creating temp file should succeed")
65 defer lock.Close()
66 // Lock acquisition
67 file, err := filesystem.Lock(lock.Name())
68 assert.NilError(t, err, "acquiring a lock should succeed")
69 err = filesystem.Unlock(file)
70 assert.NilError(t, err, "releasing a lock should succeed")
71
72 file, err = filesystem.ReadOnlyLock(lock.Name())
73 assert.NilError(t, err, "acquiring a read-only lock should succeed")
74 file2, err := filesystem.ReadOnlyLock(lock.Name())
75 assert.NilError(t, err, "acquiring another read-only lock should succeed")
76 err = filesystem.Unlock(file)
77 assert.NilError(t, err, "releasing a read-only lock should succeed")
78 err = filesystem.Unlock(file2)
79 assert.NilError(t, err, "releasing another read-only lock should succeed")
80}
81
82func TestLockWriteConcurrent(t *testing.T) {
83 t.Parallel()

Callers

nothing calls this directly

Calls 6

LockFunction · 0.92
UnlockFunction · 0.92
ReadOnlyLockFunction · 0.92
TempDirMethod · 0.65
NameMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…