summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/xray/tests/unit/segmented_array_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/lib/xray/tests/unit/segmented_array_test.cc')
-rw-r--r--compiler-rt/lib/xray/tests/unit/segmented_array_test.cc86
1 files changed, 0 insertions, 86 deletions
diff --git a/compiler-rt/lib/xray/tests/unit/segmented_array_test.cc b/compiler-rt/lib/xray/tests/unit/segmented_array_test.cc
index 73120aafc8e..80991b1b97a 100644
--- a/compiler-rt/lib/xray/tests/unit/segmented_array_test.cc
+++ b/compiler-rt/lib/xray/tests/unit/segmented_array_test.cc
@@ -221,91 +221,5 @@ TEST(SegmentedArrayTest, SimulateStackBehaviour) {
}
}
-TEST(SegmentedArrayTest, PlacementNewOnAlignedStorage) {
- using AllocatorType = typename Array<ShadowStackEntry>::AllocatorType;
- typename std::aligned_storage<sizeof(AllocatorType),
- alignof(AllocatorType)>::type AllocatorStorage;
- new (&AllocatorStorage) AllocatorType(1 << 10);
- auto *A = reinterpret_cast<AllocatorType *>(&AllocatorStorage);
- typename std::aligned_storage<sizeof(Array<ShadowStackEntry>),
- alignof(Array<ShadowStackEntry>)>::type
- ArrayStorage;
- new (&ArrayStorage) Array<ShadowStackEntry>(*A);
- auto *Data = reinterpret_cast<Array<ShadowStackEntry> *>(&ArrayStorage);
-
- static uint64_t Dummy = 0;
- constexpr uint64_t Max = 9;
-
- for (uint64_t i = 0; i < Max; ++i) {
- auto P = Data->Append({i, &Dummy});
- ASSERT_NE(P, nullptr);
- ASSERT_EQ(P->NodePtr, &Dummy);
- auto &Back = Data->back();
- ASSERT_EQ(Back.NodePtr, &Dummy);
- ASSERT_EQ(Back.EntryTSC, i);
- }
-
- // Simulate a stack by checking the data from the end as we're trimming.
- auto Counter = Max;
- ASSERT_EQ(Data->size(), size_t(Max));
- while (!Data->empty()) {
- const auto &Top = Data->back();
- uint64_t *TopNode = Top.NodePtr;
- EXPECT_EQ(TopNode, &Dummy) << "Counter = " << Counter;
- Data->trim(1);
- --Counter;
- ASSERT_EQ(Data->size(), size_t(Counter));
- }
-
- // Once the stack is exhausted, we re-use the storage.
- for (uint64_t i = 0; i < Max; ++i) {
- auto P = Data->Append({i, &Dummy});
- ASSERT_NE(P, nullptr);
- ASSERT_EQ(P->NodePtr, &Dummy);
- auto &Back = Data->back();
- ASSERT_EQ(Back.NodePtr, &Dummy);
- ASSERT_EQ(Back.EntryTSC, i);
- }
-
- // We re-initialize the storage, by calling the destructor and
- // placement-new'ing again.
- Data->~Array();
- A->~AllocatorType();
- new (A) AllocatorType(1 << 10);
- new (Data) Array<ShadowStackEntry>(*A);
-
- // Then re-do the test.
- for (uint64_t i = 0; i < Max; ++i) {
- auto P = Data->Append({i, &Dummy});
- ASSERT_NE(P, nullptr);
- ASSERT_EQ(P->NodePtr, &Dummy);
- auto &Back = Data->back();
- ASSERT_EQ(Back.NodePtr, &Dummy);
- ASSERT_EQ(Back.EntryTSC, i);
- }
-
- // Simulate a stack by checking the data from the end as we're trimming.
- Counter = Max;
- ASSERT_EQ(Data->size(), size_t(Max));
- while (!Data->empty()) {
- const auto &Top = Data->back();
- uint64_t *TopNode = Top.NodePtr;
- EXPECT_EQ(TopNode, &Dummy) << "Counter = " << Counter;
- Data->trim(1);
- --Counter;
- ASSERT_EQ(Data->size(), size_t(Counter));
- }
-
- // Once the stack is exhausted, we re-use the storage.
- for (uint64_t i = 0; i < Max; ++i) {
- auto P = Data->Append({i, &Dummy});
- ASSERT_NE(P, nullptr);
- ASSERT_EQ(P->NodePtr, &Dummy);
- auto &Back = Data->back();
- ASSERT_EQ(Back.NodePtr, &Dummy);
- ASSERT_EQ(Back.EntryTSC, i);
- }
-}
-
} // namespace
} // namespace __xray
OpenPOWER on IntegriCloud