Skip to content

Commit

Permalink
test: fix regression test for a285a91 around tsurugi issue 378
Browse files Browse the repository at this point in the history
  • Loading branch information
thawk105 committed Dec 6, 2023
1 parent fefe2fe commit de2ee1d
Show file tree
Hide file tree
Showing 11 changed files with 290 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT
std::atomic<Status> cb_rc2{};
std::atomic<Status> cb_rc3{};
std::atomic<Status> cb_rc4{};
std::atomic<bool> was_called_4{false};
[[maybe_unused]] reason_code rc1{};
[[maybe_unused]] reason_code rc2{};
[[maybe_unused]] reason_code rc3{};
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT
std::atomic<Status> cb_rc2{};
std::atomic<Status> cb_rc3{};
std::atomic<Status> cb_rc4{};
std::atomic<bool> was_called_4{false};
[[maybe_unused]] reason_code rc1{};
[[maybe_unused]] reason_code rc2{};
[[maybe_unused]] reason_code rc3{};
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT
std::atomic<Status> cb_rc2{};
std::atomic<Status> cb_rc3{};
std::atomic<Status> cb_rc4{};
std::atomic<bool> was_called_2{false};
std::atomic<bool> was_called_4{false};
[[maybe_unused]] reason_code rc1{};
[[maybe_unused]] reason_code rc2{};
[[maybe_unused]] reason_code rc3{};
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,41 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT
std::atomic<Status> cb_rc2{};
std::atomic<Status> cb_rc3{};
std::atomic<Status> cb_rc4{};
std::atomic<bool> was_called_1{false};
std::atomic<bool> was_called_2{false};
std::atomic<bool> was_called_3{false};
std::atomic<bool> 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
Expand Down Expand Up @@ -209,13 +221,19 @@ 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_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 {
Expand All @@ -225,13 +243,19 @@ 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);
}

// 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,41 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT
std::atomic<Status> cb_rc2{};
std::atomic<Status> cb_rc3{};
std::atomic<Status> cb_rc4{};
std::atomic<bool> was_called_1{false};
std::atomic<bool> was_called_2{false};
std::atomic<bool> was_called_3{false};
std::atomic<bool> 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
Expand Down Expand Up @@ -209,13 +221,19 @@ 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_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 {
Expand All @@ -225,13 +243,19 @@ 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);
}

// 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,41 @@ TEST_P(Visio_TestCase, test_1) { // NOLINT
std::atomic<Status> cb_rc2{};
std::atomic<Status> cb_rc3{};
std::atomic<Status> cb_rc4{};
std::atomic<bool> was_called_1{false};
std::atomic<bool> was_called_2{false};
std::atomic<bool> was_called_3{false};
std::atomic<bool> 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
Expand Down Expand Up @@ -209,13 +221,19 @@ 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_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 {
Expand All @@ -225,13 +243,19 @@ 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);
}

// 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 {
Expand Down
Loading

0 comments on commit de2ee1d

Please sign in to comment.