From 8e0bf02df2d47b597c571a7011ffbefec572421d Mon Sep 17 00:00:00 2001 From: bernhard-gatzhammer Date: Wed, 4 Nov 2015 13:28:02 +0100 Subject: [PATCH] Removed single write multiple reader shared mutex test. This test should test the try_lock for writing and assumed that it would always succeed if there is only one writer and multiple readers. However, this assumption was wrong. The documentation has already been adapted and committed before. EMBB-453 --- base_c/test/shared_mutex_test.cc | 39 --------------------------------------- base_c/test/shared_mutex_test.h | 12 ------------ 2 files changed, 51 deletions(-) diff --git a/base_c/test/shared_mutex_test.cc b/base_c/test/shared_mutex_test.cc index 19ab6cb..63599e3 100644 --- a/base_c/test/shared_mutex_test.cc +++ b/base_c/test/shared_mutex_test.cc @@ -48,13 +48,6 @@ SharedMutexTest::SharedMutexTest() .Add(&SharedMutexTest::TestExclusiveWriterWriterMethod, this, num_threads_ / 2, num_iterations_) .Post(&SharedMutexTest::TestExclusiveWriterPost, this); -// CreateUnit("Single writer") -// .Pre(&SharedMutexTest::TestSingleWriterPre, this) -// .Add(&SharedMutexTest::TestSingleWriterReaderMethod, this, -// num_threads_, num_iterations_) -// .Add(&SharedMutexTest::TestSingleWriterWriterMethod, this, -// 1, num_iterations_) -// .Post(&SharedMutexTest::TestSingleWriterPost, this); } void SharedMutexTest::TestSharedReadPre() { @@ -113,38 +106,6 @@ void SharedMutexTest::TestExclusiveWriterPost() { embb_shared_mutex_destroy(&shared_mutex_); } -//void SharedMutexTest::TestSingleWriterPre() { -// int success = embb_shared_mutex_init(&shared_mutex_); -// PT_ASSERT_EQ_MSG(success, EMBB_SUCCESS, "Failed to initialize shared mutex."); -// -// counter_ = 0; -//} - -//void SharedMutexTest::TestSingleWriterReaderMethod() { -// // Just add some contention -// -// int success = embb_shared_mutex_lock_shared(&shared_mutex_); -// PT_ASSERT_EQ_MSG(success, EMBB_SUCCESS, "Failed to lock for reading."); -// -// success = embb_shared_mutex_unlock_shared(&shared_mutex_); -// PT_ASSERT_EQ_MSG(success, EMBB_SUCCESS, "Failed to unlock (reading)."); -//} -// -//void SharedMutexTest::TestSingleWriterWriterMethod() { -// int success = embb_shared_mutex_lock(&shared_mutex_); -// PT_ASSERT_EQ_MSG(success, EMBB_SUCCESS, "Failed to lock for writing."); -// -// ++counter_; -// -// success = embb_shared_mutex_unlock(&shared_mutex_); -// PT_ASSERT_EQ_MSG(success, EMBB_SUCCESS, "Failed to unlock (writing)."); -//} -// -//void SharedMutexTest::TestSingleWriterPost() { -// PT_ASSERT_EQ_MSG(counter_, num_iterations_, "Counter value is inconsistent."); -// embb_shared_mutex_destroy(&shared_mutex_); -//} - } // namespace test } // namespace base } // namespace embb diff --git a/base_c/test/shared_mutex_test.h b/base_c/test/shared_mutex_test.h index fd4d535..def0098 100644 --- a/base_c/test/shared_mutex_test.h +++ b/base_c/test/shared_mutex_test.h @@ -63,18 +63,6 @@ class SharedMutexTest : public partest::TestCase { void TestExclusiveWriterWriterMethod(); void TestExclusiveWriterPost(); -// /** -// * Multiple readers, single writer. -// * -// * The single writer uses try_lock() and tests if that always obtains the -// * lock. The readers use lock_shared() and test if that always obtains the -// * shared lock (after waiting). -// */ -// void TestSingleWriterPre(); -// void TestSingleWriterReaderMethod(); -// void TestSingleWriterWriterMethod(); -// void TestSingleWriterPost(); - embb_shared_mutex_t shared_mutex_; size_t counter_; size_t num_threads_; -- libgit2 0.26.0