[PATCH] D54861: [SanitizerCommon] Test `CombinedAllocator::ForEachChunk()` in unit tests.
Dan Liew via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 4 06:06:50 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348260: [SanitizerCommon] Test `CombinedAllocator::ForEachChunk()` in unit tests. (authored by delcypher, committed by ).
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54861/new/
https://reviews.llvm.org/D54861
Files:
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
Index: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
@@ -615,6 +615,22 @@
std::shuffle(allocated.begin(), allocated.end(), r);
+ // Test ForEachChunk(...)
+ {
+ std::set<void *> reported_chunks;
+ auto cb = [](uptr chunk, void *arg) {
+ auto reported_chunks_ptr = reinterpret_cast<std::set<void *> *>(arg);
+ auto pair =
+ reported_chunks_ptr->insert(reinterpret_cast<void *>(chunk));
+ // Check chunk is never reported more than once.
+ ASSERT_TRUE(pair.second);
+ };
+ a->ForEachChunk(cb, reinterpret_cast<void *>(&reported_chunks));
+ for (const auto &allocated_ptr : allocated) {
+ ASSERT_NE(reported_chunks.find(allocated_ptr), reported_chunks.end());
+ }
+ }
+
for (uptr i = 0; i < kNumAllocs; i++) {
void *x = allocated[i];
uptr *meta = reinterpret_cast<uptr*>(a->GetMetaData(x));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54861.176614.patch
Type: text/x-patch
Size: 1150 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181204/515ee63b/attachment.bin>
More information about the llvm-commits
mailing list