From: Sebastien Ponce Date: Thu, 9 Oct 2014 13:44:06 +0000 (+0200) Subject: Added missing semaphore in libradosstriper AIO tests leading to potential memory... X-Git-Tag: v0.88~53^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F2419%2Fhead;p=ceph.git Added missing semaphore in libradosstriper AIO tests leading to potential memory corruption and thus test failures Signed-off-by: Sebastien Ponce --- diff --git a/src/test/libradosstriper/aio.cc b/src/test/libradosstriper/aio.cc index dbb6a335de03..009976c85aec 100644 --- a/src/test/libradosstriper/aio.cc +++ b/src/test/libradosstriper/aio.cc @@ -81,6 +81,8 @@ TEST_F(StriperTest, WaitForSafe) { ASSERT_EQ(0, rados_striper_aio_write(striper, "WaitForSafe", my_completion, buf, sizeof(buf), 0)); TestAlarm alarm; rados_aio_wait_for_safe(my_completion); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); rados_aio_release(my_completion); } @@ -95,6 +97,8 @@ TEST_F(StriperTestPP, WaitForSafePP) { ASSERT_EQ(0, striper.aio_write("WaitForSafePP", my_completion, bl1, sizeof(buf), 0)); TestAlarm alarm; my_completion->wait_for_safe(); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); my_completion->release(); } @@ -122,6 +126,8 @@ TEST_F(StriperTest, RoundTrip) { rados_aio_wait_for_complete(my_completion2); } ASSERT_EQ(0, memcmp(buf, buf2, sizeof(buf))); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); rados_aio_release(my_completion); rados_aio_release(my_completion2); } @@ -150,6 +156,8 @@ TEST_F(StriperTest, RoundTrip2) { rados_aio_wait_for_safe(my_completion2); } ASSERT_EQ(0, memcmp(buf, buf2, sizeof(buf))); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); rados_aio_release(my_completion); rados_aio_release(my_completion2); } @@ -177,6 +185,8 @@ TEST_F(StriperTestPP, RoundTripPP) { my_completion2->wait_for_complete(); } ASSERT_EQ(0, memcmp(buf, bl2.c_str(), sizeof(buf))); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); my_completion->release(); my_completion2->release(); } @@ -204,6 +214,8 @@ TEST_F(StriperTestPP, RoundTripPP2) { my_completion2->wait_for_safe(); } ASSERT_EQ(0, memcmp(buf, bl2.c_str(), sizeof(buf))); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); my_completion->release(); my_completion2->release(); } @@ -238,6 +250,8 @@ TEST_F(StriperTest, IsComplete) { } } ASSERT_EQ(0, memcmp(buf, buf2, sizeof(buf))); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); rados_aio_release(my_completion); rados_aio_release(my_completion2); } @@ -271,6 +285,8 @@ TEST_F(StriperTestPP, IsCompletePP) { } } ASSERT_EQ(0, memcmp(buf, bl2.c_str(), sizeof(buf))); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); my_completion->release(); my_completion2->release(); } @@ -304,6 +320,8 @@ TEST_F(StriperTest, IsSafe) { rados_aio_wait_for_complete(my_completion2); } ASSERT_EQ(0, memcmp(buf, buf2, sizeof(buf))); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); rados_aio_release(my_completion); rados_aio_release(my_completion2); } @@ -336,6 +354,8 @@ TEST_F(StriperTestPP, IsSafePP) { my_completion2->wait_for_complete(); } ASSERT_EQ(0, memcmp(buf, bl2.c_str(), sizeof(buf))); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); my_completion->release(); my_completion2->release(); } @@ -373,6 +393,8 @@ TEST_F(StriperTest, RoundTripAppend) { ASSERT_EQ((int)(sizeof(buf) + sizeof(buf2)), rados_aio_get_return_value(my_completion3)); ASSERT_EQ(0, memcmp(buf3, buf, sizeof(buf))); ASSERT_EQ(0, memcmp(buf3 + sizeof(buf), buf2, sizeof(buf2))); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); rados_aio_release(my_completion); rados_aio_release(my_completion2); rados_aio_release(my_completion3); @@ -413,6 +435,8 @@ TEST_F(StriperTestPP, RoundTripAppendPP) { ASSERT_EQ(sizeof(buf) + sizeof(buf2), (unsigned)my_completion3->get_return_value()); ASSERT_EQ(0, memcmp(bl3.c_str(), buf, sizeof(buf))); ASSERT_EQ(0, memcmp(bl3.c_str() + sizeof(buf), buf2, sizeof(buf2))); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); my_completion->release(); my_completion2->release(); my_completion3->release(); @@ -438,6 +462,8 @@ TEST_F(StriperTest, Flush) { rados_aio_wait_for_complete(my_completion2); } ASSERT_EQ(0, memcmp(buf, buf2, sizeof(buf))); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); rados_aio_release(my_completion); rados_aio_release(my_completion2); } @@ -461,6 +487,8 @@ TEST_F(StriperTestPP, FlushPP) { my_completion2->wait_for_complete(); } ASSERT_EQ(0, memcmp(buf, bl2.c_str(), sizeof(buf))); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); my_completion->release(); my_completion2->release(); } @@ -497,6 +525,8 @@ TEST_F(StriperTest, RoundTripWriteFull) { } ASSERT_EQ(sizeof(buf2), (unsigned)rados_aio_get_return_value(my_completion3)); ASSERT_EQ(0, memcmp(buf3, buf2, sizeof(buf2))); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); rados_aio_release(my_completion); rados_aio_release(my_completion2); rados_aio_release(my_completion3); @@ -536,6 +566,8 @@ TEST_F(StriperTestPP, RoundTripWriteFullPP) { } ASSERT_EQ(sizeof(buf2), (unsigned)my_completion3->get_return_value()); ASSERT_EQ(0, memcmp(bl3.c_str(), buf2, sizeof(buf2))); + sem_wait(&test_data.m_sem); + sem_wait(&test_data.m_sem); my_completion->release(); my_completion2->release(); my_completion3->release();