From 36169d399c4b1eee359ae51c660b3a6a3b4a8097 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Mon, 14 Aug 2017 14:20:59 +0100 Subject: [PATCH] [unit-tests] add failing test. You currently can get a read lock when a write lock is already held. --- unit-tests/block_t.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/unit-tests/block_t.cc b/unit-tests/block_t.cc index c1a3172..6da67db 100644 --- a/unit-tests/block_t.cc +++ b/unit-tests/block_t.cc @@ -233,6 +233,13 @@ TEST(BlockTests, concurrent_read_locks) bm->read_lock(0); } +TEST(BlockTests, no_concurrent_read_and_write_locks) +{ + bm4096::ptr bm = create_bm<4096>(); + bm4096::write_ref wr = bm->write_lock(0); + ASSERT_THROW(bm->read_lock(0), runtime_error); +} + TEST(BlockTests, read_then_write) { bm4096::ptr bm = create_bm<4096>();