You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by sh...@apache.org on 2019/04/01 19:03:55 UTC
[trafficserver] branch master updated: AcidPtr test persistence
This is an automated email from the ASF dual-hosted git repository.
shinrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new aa10988 AcidPtr test persistence
aa10988 is described below
commit aa1098895dc2495796dc25b2519c2a01c5d0c744
Author: Aaron Canary <ac...@oath.com>
AuthorDate: Mon Mar 11 13:25:08 2019 -0500
AcidPtr test persistence
---
src/tscore/unit_tests/test_AcidPtr.cc | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/tscore/unit_tests/test_AcidPtr.cc b/src/tscore/unit_tests/test_AcidPtr.cc
index f33af7b..c8994cf 100644
--- a/src/tscore/unit_tests/test_AcidPtr.cc
+++ b/src/tscore/unit_tests/test_AcidPtr.cc
@@ -95,6 +95,28 @@ TEST_CASE("AcidPtr Isolation")
CHECK(*p.getPtr() == 42);
}
+TEST_CASE("AcidPtr persistence")
+{
+ AcidPtr<int> p(new int(40));
+ std::shared_ptr<const int> r1, r2, r3, r4;
+ REQUIRE(p.getPtr() != nullptr);
+ r1 = p.getPtr();
+ {
+ AcidCommitPtr<int> w = p;
+ r2 = p.getPtr();
+ *w += 1; // update p at end of scope
+ }
+ r3 = p.getPtr();
+ {
+ *AcidCommitPtr<int>(p) += 1; // leaves scope immediately if not named.
+ r4 = p.getPtr();
+ }
+ CHECK(*r1 == 40); // references to data are still valid, but inconsistent. (todo: rename AcidPtr to AiPtr?)
+ CHECK(*r2 == 40);
+ CHECK(*r3 == 41);
+ CHECK(*r4 == 42);
+}
+
TEST_CASE("AcidPtr Abort")
{
AcidPtr<int> p;