From de2ee1d1d8e63fe7f34afe57501d4d635445a531 Mon Sep 17 00:00:00 2001 From: Takayuki Tanabe Date: Wed, 6 Dec 2023 17:05:08 +0900 Subject: [PATCH] test: fix regression test for a285a9149f23ac1428a316bde3da83067432470a around tsurugi issue 378 project-tsurugi/tsurugi-issues#438 --- .../Visio-TestCase/Visio-TestCase_5b_test.cpp | 12 +++++- .../Visio-TestCase/Visio-TestCase_5c_test.cpp | 8 +++- .../Visio-TestCase/Visio-TestCase_5d_test.cpp | 16 +++++++- .../Visio-TestCase/Visio-TestCase_6b_test.cpp | 32 +++++++++++++-- .../Visio-TestCase/Visio-TestCase_6c_test.cpp | 32 +++++++++++++-- .../Visio-TestCase/Visio-TestCase_6d_test.cpp | 32 +++++++++++++-- .../Visio-TestCase/Visio-TestCase_7c_test.cpp | 40 ++++++++++++++++--- .../Visio-TestCase/Visio-TestCase_7e_test.cpp | 40 ++++++++++++++++--- .../Visio-TestCase/Visio-TestCase_7f_test.cpp | 40 ++++++++++++++++--- .../Visio-TestCase/Visio-TestCase_7g_test.cpp | 40 ++++++++++++++++--- .../Visio-TestCase/Visio-TestCase_7h_test.cpp | 40 ++++++++++++++++--- 11 files changed, 290 insertions(+), 42 deletions(-) diff --git a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_5b_test.cpp b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_5b_test.cpp index de3b7e92e..1c525985e 100644 --- a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_5b_test.cpp +++ b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_5b_test.cpp @@ -77,6 +77,7 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT std::atomic cb_rc2{}; std::atomic cb_rc3{}; std::atomic cb_rc4{}; + std::atomic was_called_4{false}; [[maybe_unused]] reason_code rc1{}; [[maybe_unused]] reason_code rc2{}; [[maybe_unused]] reason_code rc3{}; @@ -96,10 +97,12 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT cb_rc3.store(rs, std::memory_order_release); rc3 = rc; }; - auto cb4 = [&cb_rc4, &rc4](Status rs, [[maybe_unused]] reason_code rc, + auto cb4 = [&cb_rc4, &rc4, + &was_called_4](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc4.store(rs, std::memory_order_release); rc4 = rc; + was_called_4 = true; }; // setup @@ -198,7 +201,8 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // success case ASSERT_OK(search_key(t4, stu, "u", buf)); ASSERT_EQ(buf, "0"); - commit(t4, cb4); + auto t4_rc = commit(t4, cb4); + if (t2_type == transaction_type::LONG) { ASSERT_FALSE(t4_rc); } } // t2 write z, commit @@ -232,6 +236,10 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t4 if (!t4_was_finished) { + if (t4_type == transaction_type::LONG) { + // wait commit + while (!was_called_4) { _mm_pause(); } + } if (t4_can_commit) { ASSERT_EQ(cb_rc4, Status::OK); } else { diff --git a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_5c_test.cpp b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_5c_test.cpp index 057867134..215b87c35 100644 --- a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_5c_test.cpp +++ b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_5c_test.cpp @@ -77,6 +77,7 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT std::atomic cb_rc2{}; std::atomic cb_rc3{}; std::atomic cb_rc4{}; + std::atomic was_called_4{false}; [[maybe_unused]] reason_code rc1{}; [[maybe_unused]] reason_code rc2{}; [[maybe_unused]] reason_code rc3{}; @@ -96,10 +97,12 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT cb_rc3.store(rs, std::memory_order_release); rc3 = rc; }; - auto cb4 = [&cb_rc4, &rc4](Status rs, [[maybe_unused]] reason_code rc, + auto cb4 = [&cb_rc4, &rc4, + &was_called_4](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc4.store(rs, std::memory_order_release); rc4 = rc; + was_called_4 = true; }; // setup @@ -232,6 +235,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t4 if (!t4_was_finished) { + if (t4_type == transaction_type::LONG) { + while (!was_called_4) { _mm_pause(); } // wait for commit + } if (t4_can_commit) { ASSERT_EQ(cb_rc4, Status::OK); } else { diff --git a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_5d_test.cpp b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_5d_test.cpp index 0e1439f81..149791b39 100644 --- a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_5d_test.cpp +++ b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_5d_test.cpp @@ -77,6 +77,8 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT std::atomic cb_rc2{}; std::atomic cb_rc3{}; std::atomic cb_rc4{}; + std::atomic was_called_2{false}; + std::atomic was_called_4{false}; [[maybe_unused]] reason_code rc1{}; [[maybe_unused]] reason_code rc2{}; [[maybe_unused]] reason_code rc3{}; @@ -86,20 +88,24 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT cb_rc1.store(rs, std::memory_order_release); rc1 = rc; }; - auto cb2 = [&cb_rc2, &rc2](Status rs, [[maybe_unused]] reason_code rc, + auto cb2 = [&cb_rc2, &rc2, + &was_called_2](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc2.store(rs, std::memory_order_release); rc2 = rc; + was_called_2 = true; }; auto cb3 = [&cb_rc3, &rc3](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc3.store(rs, std::memory_order_release); rc3 = rc; }; - auto cb4 = [&cb_rc4, &rc4](Status rs, [[maybe_unused]] reason_code rc, + auto cb4 = [&cb_rc4, &rc4, + &was_called_4](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc4.store(rs, std::memory_order_release); rc4 = rc; + was_called_4 = true; }; // setup @@ -216,6 +222,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t2 if (!t2_was_finished) { + if (t2_type == transaction_type::LONG) { + while (!was_called_2) { _mm_pause(); } + } if (t2_can_commit) { ASSERT_EQ(cb_rc2, Status::OK); } else { @@ -232,6 +241,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t4 if (!t4_was_finished) { + if (t4_type == transaction_type::LONG) { + while (!was_called_4) { _mm_pause(); } + } if (t4_can_commit) { ASSERT_EQ(cb_rc4, Status::OK); } else { diff --git a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_6b_test.cpp b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_6b_test.cpp index 33e20b623..45cd4f5bf 100644 --- a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_6b_test.cpp +++ b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_6b_test.cpp @@ -77,29 +77,41 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT std::atomic cb_rc2{}; std::atomic cb_rc3{}; std::atomic cb_rc4{}; + std::atomic was_called_1{false}; + std::atomic was_called_2{false}; + std::atomic was_called_3{false}; + std::atomic was_called_4{false}; [[maybe_unused]] reason_code rc1{}; [[maybe_unused]] reason_code rc2{}; [[maybe_unused]] reason_code rc3{}; [[maybe_unused]] reason_code rc4{}; - auto cb1 = [&cb_rc1, &rc1](Status rs, [[maybe_unused]] reason_code rc, + auto cb1 = [&cb_rc1, &rc1, + &was_called_1](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc1.store(rs, std::memory_order_release); rc1 = rc; + was_called_1 = true; }; - auto cb2 = [&cb_rc2, &rc2](Status rs, [[maybe_unused]] reason_code rc, + auto cb2 = [&cb_rc2, &rc2, + &was_called_2](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc2.store(rs, std::memory_order_release); rc2 = rc; + was_called_2 = true; }; - auto cb3 = [&cb_rc3, &rc3](Status rs, [[maybe_unused]] reason_code rc, + auto cb3 = [&cb_rc3, &rc3, + &was_called_3](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc3.store(rs, std::memory_order_release); rc3 = rc; + was_called_3 = true; }; - auto cb4 = [&cb_rc4, &rc4](Status rs, [[maybe_unused]] reason_code rc, + auto cb4 = [&cb_rc4, &rc4, + &was_called_4](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc4.store(rs, std::memory_order_release); rc4 = rc; + was_called_4 = true; }; // setup @@ -209,6 +221,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t1 if (t1_can_commit) { + if (t1_type == transaction_type::LONG) { + while (!was_called_1) { _mm_pause(); } + } ASSERT_EQ(cb_rc1, Status::OK); } else { ASSERT_EQ(cb_rc1, Status::ERR_CC); @@ -216,6 +231,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t2 if (!t2_was_finished) { + if (t2_type == transaction_type::LONG) { + while (!was_called_2) { _mm_pause(); } + } if (t2_can_commit) { ASSERT_EQ(cb_rc2, Status::OK); } else { @@ -225,6 +243,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t3 if (t3_can_commit) { + if (t3_type == transaction_type::LONG) { + while (!was_called_3) { _mm_pause(); } + } ASSERT_EQ(cb_rc3, Status::OK); } else { ASSERT_EQ(cb_rc3, Status::ERR_CC); @@ -232,6 +253,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t4 if (!t4_was_finished) { + if (t4_type == transaction_type::LONG) { + while (!was_called_4) { _mm_pause(); } + } if (t4_can_commit) { ASSERT_EQ(cb_rc4, Status::OK); } else { diff --git a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_6c_test.cpp b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_6c_test.cpp index 5e9080963..c71fd69dc 100644 --- a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_6c_test.cpp +++ b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_6c_test.cpp @@ -77,29 +77,41 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT std::atomic cb_rc2{}; std::atomic cb_rc3{}; std::atomic cb_rc4{}; + std::atomic was_called_1{false}; + std::atomic was_called_2{false}; + std::atomic was_called_3{false}; + std::atomic was_called_4{false}; [[maybe_unused]] reason_code rc1{}; [[maybe_unused]] reason_code rc2{}; [[maybe_unused]] reason_code rc3{}; [[maybe_unused]] reason_code rc4{}; - auto cb1 = [&cb_rc1, &rc1](Status rs, [[maybe_unused]] reason_code rc, + auto cb1 = [&cb_rc1, &rc1, + &was_called_1](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc1.store(rs, std::memory_order_release); rc1 = rc; + was_called_1 = true; }; - auto cb2 = [&cb_rc2, &rc2](Status rs, [[maybe_unused]] reason_code rc, + auto cb2 = [&cb_rc2, &rc2, + &was_called_2](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc2.store(rs, std::memory_order_release); rc2 = rc; + was_called_2 = true; }; - auto cb3 = [&cb_rc3, &rc3](Status rs, [[maybe_unused]] reason_code rc, + auto cb3 = [&cb_rc3, &rc3, + &was_called_3](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc3.store(rs, std::memory_order_release); rc3 = rc; + was_called_3 = true; }; - auto cb4 = [&cb_rc4, &rc4](Status rs, [[maybe_unused]] reason_code rc, + auto cb4 = [&cb_rc4, &rc4, + &was_called_4](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc4.store(rs, std::memory_order_release); rc4 = rc; + was_called_4 = true; }; // setup @@ -209,6 +221,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t1 if (t1_can_commit) { + if (t1_type == transaction_type::LONG) { + while (!was_called_1) { _mm_pause(); } + } ASSERT_EQ(cb_rc1, Status::OK); } else { ASSERT_EQ(cb_rc1, Status::ERR_CC); @@ -216,6 +231,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t2 if (!t2_was_finished) { + if (t2_type == transaction_type::LONG) { + while (!was_called_2) { _mm_pause(); } + } if (t2_can_commit) { ASSERT_EQ(cb_rc2, Status::OK); } else { @@ -225,6 +243,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t3 if (t3_can_commit) { + if (t3_type == transaction_type::LONG) { + while (!was_called_3) { _mm_pause(); } + } ASSERT_EQ(cb_rc3, Status::OK); } else { ASSERT_EQ(cb_rc3, Status::ERR_CC); @@ -232,6 +253,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t4 if (!t4_was_finished) { + if (t4_type == transaction_type::LONG) { + while (!was_called_4) { _mm_pause(); } + } if (t4_can_commit) { ASSERT_EQ(cb_rc4, Status::OK); } else { diff --git a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_6d_test.cpp b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_6d_test.cpp index c1ced9cc5..d80015dab 100644 --- a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_6d_test.cpp +++ b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_6d_test.cpp @@ -77,29 +77,41 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT std::atomic cb_rc2{}; std::atomic cb_rc3{}; std::atomic cb_rc4{}; + std::atomic was_called_1{false}; + std::atomic was_called_2{false}; + std::atomic was_called_3{false}; + std::atomic was_called_4{false}; [[maybe_unused]] reason_code rc1{}; [[maybe_unused]] reason_code rc2{}; [[maybe_unused]] reason_code rc3{}; [[maybe_unused]] reason_code rc4{}; - auto cb1 = [&cb_rc1, &rc1](Status rs, [[maybe_unused]] reason_code rc, + auto cb1 = [&cb_rc1, &rc1, + &was_called_1](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc1.store(rs, std::memory_order_release); rc1 = rc; + was_called_1 = true; }; - auto cb2 = [&cb_rc2, &rc2](Status rs, [[maybe_unused]] reason_code rc, + auto cb2 = [&cb_rc2, &rc2, + &was_called_2](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc2.store(rs, std::memory_order_release); rc2 = rc; + was_called_2 = true; }; - auto cb3 = [&cb_rc3, &rc3](Status rs, [[maybe_unused]] reason_code rc, + auto cb3 = [&cb_rc3, &rc3, + &was_called_3](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc3.store(rs, std::memory_order_release); rc3 = rc; + was_called_3 = true; }; - auto cb4 = [&cb_rc4, &rc4](Status rs, [[maybe_unused]] reason_code rc, + auto cb4 = [&cb_rc4, &rc4, + &was_called_4](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc4.store(rs, std::memory_order_release); rc4 = rc; + was_called_4 = true; }; // setup @@ -209,6 +221,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t1 if (t1_can_commit) { + if (t1_type == transaction_type::LONG) { + while (!was_called_1) { _mm_pause(); } + } ASSERT_EQ(cb_rc1, Status::OK); } else { ASSERT_EQ(cb_rc1, Status::ERR_CC); @@ -216,6 +231,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t2 if (!t2_was_finished) { + if (t2_type == transaction_type::LONG) { + while (!was_called_2) { _mm_pause(); } + } if (t2_can_commit) { ASSERT_EQ(cb_rc2, Status::OK); } else { @@ -225,6 +243,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t3 if (t3_can_commit) { + if (t3_type == transaction_type::LONG) { + while (!was_called_3) { _mm_pause(); } + } ASSERT_EQ(cb_rc3, Status::OK); } else { ASSERT_EQ(cb_rc3, Status::ERR_CC); @@ -232,6 +253,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t4 if (!t4_was_finished) { + if (t4_type == transaction_type::LONG) { + while (!was_called_4) { _mm_pause(); } + } if (t4_can_commit) { ASSERT_EQ(cb_rc4, Status::OK); } else { diff --git a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7c_test.cpp b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7c_test.cpp index 95f70292a..16bcd060e 100644 --- a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7c_test.cpp +++ b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7c_test.cpp @@ -84,35 +84,50 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT std::atomic cb_rc3{}; std::atomic cb_rc4{}; std::atomic cb_rc5{}; + std::atomic was_called_1{false}; + std::atomic was_called_2{false}; + std::atomic was_called_3{false}; + std::atomic was_called_4{false}; + std::atomic was_called_5{false}; [[maybe_unused]] reason_code rc1{}; [[maybe_unused]] reason_code rc2{}; [[maybe_unused]] reason_code rc3{}; [[maybe_unused]] reason_code rc4{}; [[maybe_unused]] reason_code rc5{}; - auto cb1 = [&cb_rc1, &rc1](Status rs, [[maybe_unused]] reason_code rc, + auto cb1 = [&cb_rc1, &rc1, + &was_called_1](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc1.store(rs, std::memory_order_release); rc1 = rc; + was_called_1 = true; }; - auto cb2 = [&cb_rc2, &rc2](Status rs, [[maybe_unused]] reason_code rc, + auto cb2 = [&cb_rc2, &rc2, + &was_called_2](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc2.store(rs, std::memory_order_release); rc2 = rc; + was_called_2 = true; }; - auto cb3 = [&cb_rc3, &rc3](Status rs, [[maybe_unused]] reason_code rc, + auto cb3 = [&cb_rc3, &rc3, + &was_called_3](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc3.store(rs, std::memory_order_release); rc3 = rc; + was_called_3 = true; }; - auto cb4 = [&cb_rc4, &rc4](Status rs, [[maybe_unused]] reason_code rc, + auto cb4 = [&cb_rc4, &rc4, + &was_called_4](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc4.store(rs, std::memory_order_release); rc4 = rc; + was_called_4 = true; }; - auto cb5 = [&cb_rc5, &rc5](Status rs, [[maybe_unused]] reason_code rc, + auto cb5 = [&cb_rc5, &rc5, + &was_called_5](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc5.store(rs, std::memory_order_release); rc5 = rc; + was_called_5 = true; }; // setup @@ -227,22 +242,37 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT // verify t1 if (t1_can_commit) { + if (t1_type == transaction_type::LONG) { + while (!was_called_1) { _mm_pause(); } + } ASSERT_EQ(cb_rc1, Status::OK); } else { ASSERT_EQ(cb_rc1, Status::ERR_CC); } // verify t2 + if (t2_type == transaction_type::LONG) { + while (!was_called_2) { _mm_pause(); } + } ASSERT_EQ(cb_rc2, Status::OK); // verify t3 + if (t3_type == transaction_type::LONG) { + while (!was_called_3) { _mm_pause(); } + } ASSERT_EQ(cb_rc3, Status::OK); // verify t4 + if (t4_type == transaction_type::LONG) { + while (!was_called_4) { _mm_pause(); } + } ASSERT_EQ(cb_rc4, Status::OK); // verify t5 if (!t5_was_finished) { + if (t5_type == transaction_type::LONG) { + while (!was_called_5) { _mm_pause(); } + } if (t5_can_commit) { ASSERT_EQ(cb_rc5, Status::OK); } else { diff --git a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7e_test.cpp b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7e_test.cpp index 6efe62b2b..69a6a5b96 100644 --- a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7e_test.cpp +++ b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7e_test.cpp @@ -81,35 +81,50 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT std::atomic cb_rc3{}; std::atomic cb_rc4{}; std::atomic cb_rc5{}; + std::atomic was_called_1{false}; + std::atomic was_called_2{false}; + std::atomic was_called_3{false}; + std::atomic was_called_4{false}; + std::atomic was_called_5{false}; [[maybe_unused]] reason_code rc1{}; [[maybe_unused]] reason_code rc2{}; [[maybe_unused]] reason_code rc3{}; [[maybe_unused]] reason_code rc4{}; [[maybe_unused]] reason_code rc5{}; - auto cb1 = [&cb_rc1, &rc1](Status rs, [[maybe_unused]] reason_code rc, + auto cb1 = [&cb_rc1, &rc1, + &was_called_1](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc1.store(rs, std::memory_order_release); rc1 = rc; + was_called_1 = true; }; - auto cb2 = [&cb_rc2, &rc2](Status rs, [[maybe_unused]] reason_code rc, + auto cb2 = [&cb_rc2, &rc2, + &was_called_2](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc2.store(rs, std::memory_order_release); rc2 = rc; + was_called_2 = true; }; - auto cb3 = [&cb_rc3, &rc3](Status rs, [[maybe_unused]] reason_code rc, + auto cb3 = [&cb_rc3, &rc3, + &was_called_3](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc3.store(rs, std::memory_order_release); rc3 = rc; + was_called_3 = true; }; - auto cb4 = [&cb_rc4, &rc4](Status rs, [[maybe_unused]] reason_code rc, + auto cb4 = [&cb_rc4, &rc4, + &was_called_4](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc4.store(rs, std::memory_order_release); rc4 = rc; + was_called_4 = true; }; - auto cb5 = [&cb_rc5, &rc5](Status rs, [[maybe_unused]] reason_code rc, + auto cb5 = [&cb_rc5, &rc5, + &was_called_5](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc5.store(rs, std::memory_order_release); rc5 = rc; + was_called_5 = true; }; // setup @@ -223,6 +238,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT commit(t1, cb1); // verify t1 + if (t1_type == transaction_type::LONG) { + while (!was_called_1) { _mm_pause(); } + } if (t1_can_commit) { ASSERT_EQ(cb_rc1, Status::OK); } else { @@ -230,16 +248,28 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT } // verify t2 + if (t2_type == transaction_type::LONG) { + while (!was_called_2) { _mm_pause(); } + } ASSERT_EQ(cb_rc2, Status::OK); // verify t3 + if (t3_type == transaction_type::LONG) { + while (!was_called_3) { _mm_pause(); } + } ASSERT_EQ(cb_rc3, Status::OK); // verify t4 + if (t4_type == transaction_type::LONG) { + while (!was_called_4) { _mm_pause(); } + } ASSERT_EQ(cb_rc4, Status::OK); // verify t5 if (!t5_was_finished) { + if (t5_type == transaction_type::LONG) { + while (!was_called_5) { _mm_pause(); } + } if (t5_can_commit) { ASSERT_EQ(cb_rc5, Status::OK); } else { diff --git a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7f_test.cpp b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7f_test.cpp index 7fa49e8e8..890d1eb4a 100644 --- a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7f_test.cpp +++ b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7f_test.cpp @@ -82,35 +82,50 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT std::atomic cb_rc3{}; std::atomic cb_rc4{}; std::atomic cb_rc5{}; + std::atomic was_called_1{false}; + std::atomic was_called_2{false}; + std::atomic was_called_3{false}; + std::atomic was_called_4{false}; + std::atomic was_called_5{false}; [[maybe_unused]] reason_code rc1{}; [[maybe_unused]] reason_code rc2{}; [[maybe_unused]] reason_code rc3{}; [[maybe_unused]] reason_code rc4{}; [[maybe_unused]] reason_code rc5{}; - auto cb1 = [&cb_rc1, &rc1](Status rs, [[maybe_unused]] reason_code rc, + auto cb1 = [&cb_rc1, &rc1, + &was_called_1](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc1.store(rs, std::memory_order_release); rc1 = rc; + was_called_1 = true; }; - auto cb2 = [&cb_rc2, &rc2](Status rs, [[maybe_unused]] reason_code rc, + auto cb2 = [&cb_rc2, &rc2, + &was_called_2](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc2.store(rs, std::memory_order_release); rc2 = rc; + was_called_2 = true; }; - auto cb3 = [&cb_rc3, &rc3](Status rs, [[maybe_unused]] reason_code rc, + auto cb3 = [&cb_rc3, &rc3, + &was_called_3](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc3.store(rs, std::memory_order_release); rc3 = rc; + was_called_3 = true; }; - auto cb4 = [&cb_rc4, &rc4](Status rs, [[maybe_unused]] reason_code rc, + auto cb4 = [&cb_rc4, &rc4, + &was_called_4](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc4.store(rs, std::memory_order_release); rc4 = rc; + was_called_4 = true; }; - auto cb5 = [&cb_rc5, &rc5](Status rs, [[maybe_unused]] reason_code rc, + auto cb5 = [&cb_rc5, &rc5, + &was_called_5](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc5.store(rs, std::memory_order_release); rc5 = rc; + was_called_5 = true; }; // setup @@ -224,6 +239,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT commit(t1, cb1); // verify t1 + if (t1_type == transaction_type::LONG) { + while (!was_called_1) { _mm_pause(); } + } if (t1_can_commit) { ASSERT_EQ(cb_rc1, Status::OK); } else { @@ -231,16 +249,28 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT } // verify t2 + if (t2_type == transaction_type::LONG) { + while (!was_called_2) { _mm_pause(); } + } ASSERT_EQ(cb_rc2, Status::OK); // verify t3 + if (t3_type == transaction_type::LONG) { + while (!was_called_3) { _mm_pause(); } + } ASSERT_EQ(cb_rc3, Status::OK); // verify t4 + if (t4_type == transaction_type::LONG) { + while (!was_called_4) { _mm_pause(); } + } ASSERT_EQ(cb_rc4, Status::OK); // verify t5 if (!t5_was_finished) { + if (t5_type == transaction_type::LONG) { + while (!was_called_5) { _mm_pause(); } + } if (t5_can_commit) { ASSERT_EQ(cb_rc5, Status::OK); } else { diff --git a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7g_test.cpp b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7g_test.cpp index 3c1d12d55..9ea550030 100644 --- a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7g_test.cpp +++ b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7g_test.cpp @@ -80,35 +80,50 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT std::atomic cb_rc3{}; std::atomic cb_rc4{}; std::atomic cb_rc5{}; + std::atomic was_called_1{false}; + std::atomic was_called_2{false}; + std::atomic was_called_3{false}; + std::atomic was_called_4{false}; + std::atomic was_called_5{false}; [[maybe_unused]] reason_code rc1{}; [[maybe_unused]] reason_code rc2{}; [[maybe_unused]] reason_code rc3{}; [[maybe_unused]] reason_code rc4{}; [[maybe_unused]] reason_code rc5{}; - auto cb1 = [&cb_rc1, &rc1](Status rs, [[maybe_unused]] reason_code rc, + auto cb1 = [&cb_rc1, &rc1, + &was_called_1](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc1.store(rs, std::memory_order_release); rc1 = rc; + was_called_1 = true; }; - auto cb2 = [&cb_rc2, &rc2](Status rs, [[maybe_unused]] reason_code rc, + auto cb2 = [&cb_rc2, &rc2, + &was_called_2](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc2.store(rs, std::memory_order_release); rc2 = rc; + was_called_2 = true; }; - auto cb3 = [&cb_rc3, &rc3](Status rs, [[maybe_unused]] reason_code rc, + auto cb3 = [&cb_rc3, &rc3, + &was_called_3](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc3.store(rs, std::memory_order_release); rc3 = rc; + was_called_3 = true; }; - auto cb4 = [&cb_rc4, &rc4](Status rs, [[maybe_unused]] reason_code rc, + auto cb4 = [&cb_rc4, &rc4, + &was_called_4](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc4.store(rs, std::memory_order_release); rc4 = rc; + was_called_4 = true; }; - auto cb5 = [&cb_rc5, &rc5](Status rs, [[maybe_unused]] reason_code rc, + auto cb5 = [&cb_rc5, &rc5, + &was_called_5](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc5.store(rs, std::memory_order_release); rc5 = rc; + was_called_5 = true; }; // setup @@ -222,6 +237,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT commit(t1, cb1); // verify t1 + if (t1_type == transaction_type::LONG) { + while (!was_called_1) { _mm_pause(); } + } if (t1_can_commit) { ASSERT_EQ(cb_rc1, Status::OK); } else { @@ -229,16 +247,28 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT } // verify t2 + if (t2_type == transaction_type::LONG) { + while (!was_called_2) { _mm_pause(); } + } ASSERT_EQ(cb_rc2, Status::OK); // verify t3 + if (t3_type == transaction_type::LONG) { + while (!was_called_3) { _mm_pause(); } + } ASSERT_EQ(cb_rc3, Status::OK); // verify t4 + if (t4_type == transaction_type::LONG) { + while (!was_called_4) { _mm_pause(); } + } ASSERT_EQ(cb_rc4, Status::OK); // verify t5 if (!t5_was_finished) { + if (t5_type == transaction_type::LONG) { + while (!was_called_5) { _mm_pause(); } + } if (t5_can_commit) { ASSERT_EQ(cb_rc5, Status::OK); } else { diff --git a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7h_test.cpp b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7h_test.cpp index 5064b4c36..40fb4115c 100644 --- a/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7h_test.cpp +++ b/test/concurrency_control/anomaly/Visio-TestCase/Visio-TestCase_7h_test.cpp @@ -80,35 +80,50 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT std::atomic cb_rc3{}; std::atomic cb_rc4{}; std::atomic cb_rc5{}; + std::atomic was_called_1{false}; + std::atomic was_called_2{false}; + std::atomic was_called_3{false}; + std::atomic was_called_4{false}; + std::atomic was_called_5{false}; [[maybe_unused]] reason_code rc1{}; [[maybe_unused]] reason_code rc2{}; [[maybe_unused]] reason_code rc3{}; [[maybe_unused]] reason_code rc4{}; [[maybe_unused]] reason_code rc5{}; - auto cb1 = [&cb_rc1, &rc1](Status rs, [[maybe_unused]] reason_code rc, + auto cb1 = [&cb_rc1, &rc1, + &was_called_1](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc1.store(rs, std::memory_order_release); rc1 = rc; + was_called_1 = true; }; - auto cb2 = [&cb_rc2, &rc2](Status rs, [[maybe_unused]] reason_code rc, + auto cb2 = [&cb_rc2, &rc2, + &was_called_2](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc2.store(rs, std::memory_order_release); rc2 = rc; + was_called_2 = true; }; - auto cb3 = [&cb_rc3, &rc3](Status rs, [[maybe_unused]] reason_code rc, + auto cb3 = [&cb_rc3, &rc3, + &was_called_3](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc3.store(rs, std::memory_order_release); rc3 = rc; + was_called_3 = true; }; - auto cb4 = [&cb_rc4, &rc4](Status rs, [[maybe_unused]] reason_code rc, + auto cb4 = [&cb_rc4, &rc4, + &was_called_4](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc4.store(rs, std::memory_order_release); rc4 = rc; + was_called_4 = true; }; - auto cb5 = [&cb_rc5, &rc5](Status rs, [[maybe_unused]] reason_code rc, + auto cb5 = [&cb_rc5, &rc5, + &was_called_5](Status rs, [[maybe_unused]] reason_code rc, [[maybe_unused]] durability_marker_type dm) { cb_rc5.store(rs, std::memory_order_release); rc5 = rc; + was_called_5 = true; }; // setup @@ -222,6 +237,9 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT commit(t1, cb1); // verify t1 + if (t1_type == transaction_type::LONG) { + while (!was_called_1) { _mm_pause(); } + } if (t1_can_commit) { ASSERT_EQ(cb_rc1, Status::OK); } else { @@ -229,16 +247,28 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT } // verify t2 + if (t2_type == transaction_type::LONG) { + while (!was_called_2) { _mm_pause(); } + } ASSERT_EQ(cb_rc2, Status::OK); // verify t3 + if (t3_type == transaction_type::LONG) { + while (!was_called_3) { _mm_pause(); } + } ASSERT_EQ(cb_rc3, Status::OK); // verify t4 + if (t4_type == transaction_type::LONG) { + while (!was_called_4) { _mm_pause(); } + } ASSERT_EQ(cb_rc4, Status::OK); // verify t5 if (!t5_was_finished) { + if (t5_type == transaction_type::LONG) { + while (!was_called_5) { _mm_pause(); } + } if (t5_can_commit) { ASSERT_EQ(cb_rc5, Status::OK); } else {