diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-08-07 11:11:40 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2019-01-04 09:45:59 -0500 |
commit | 52d95f50729b40628ae77d667d262c5235e50cb8 (patch) | |
tree | ef587b5834d13645b5997bd287f2acef66060f9f /libpod/lock/locks_test.go | |
parent | b489feff717a9976ee177acd4b239acf2dc9c326 (diff) | |
download | podman-52d95f50729b40628ae77d667d262c5235e50cb8.tar.gz podman-52d95f50729b40628ae77d667d262c5235e50cb8.tar.bz2 podman-52d95f50729b40628ae77d667d262c5235e50cb8.zip |
Propogate error codes from SHM lock creation and open
Also add a few more unit tests
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'libpod/lock/locks_test.go')
-rw-r--r-- | libpod/lock/locks_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libpod/lock/locks_test.go b/libpod/lock/locks_test.go index ce4882643..62a36c5da 100644 --- a/libpod/lock/locks_test.go +++ b/libpod/lock/locks_test.go @@ -80,6 +80,42 @@ func TestCreateNewSHMBadSize(t *testing.T) { assert.Error(t, err) } +// Test that creating an SHM with 0 size fails +func TestCreateNewSHMZeroSize(t *testing.T) { + _, err := CreateSHMLock(0) + assert.Error(t, err) +} + +// Test that deallocating an unallocated lock errors +func TestDeallocateUnallocatedLockErrors(t *testing.T) { + runLockTest(t, func(t *testing.T, locks *SHMLocks) { + err := locks.DeallocateSemaphore(0) + assert.Error(t, err) + }) +} + +// Test that unlocking an unlocked lock fails +func TestUnlockingUnlockedLockFails(t *testing.T) { + runLockTest(t, func(t *testing.T, locks *SHMLocks) { + err := locks.UnlockSemaphore(0) + assert.Error(t, err) + }) +} + +// Test that locking and double-unlocking fails +func TestDoubleUnlockFails(t *testing.T) { + runLockTest(t, func(t *testing.T, locks *SHMLocks) { + err := locks.LockSemaphore(0) + assert.NoError(t, err) + + err = locks.UnlockSemaphore(0) + assert.NoError(t, err) + + err = locks.UnlockSemaphore(0) + assert.Error(t, err) + }) +} + // Test allocating - lock - unlock - deallocate cycle, single lock func TestLockLifecycleSingleLock(t *testing.T) { runLockTest(t, func(t *testing.T, locks *SHMLocks) { |