summaryrefslogtreecommitdiff
path: root/lib/tsan/tests
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2014-07-07 17:39:31 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2014-07-07 17:39:31 +0000
commit2ef0c30d2101ca6521b7ecbdd17e4fbcca09a951 (patch)
tree362337877acfa4824664514a5a3b54216bc670c1 /lib/tsan/tests
parent58dd99ec88cc51a5a1adcd4eddff212576a9067c (diff)
Generalize sanitizer allocator public interface.
Introduce new public header <sanitizer/allocator_interface.h> and a set of functions __sanitizer_get_ownership(), __sanitizer_malloc_hook() etc. that will eventually replace their tool-specific equivalents (__asan_get_ownership(), __msan_get_ownership() etc.). Tool-specific functions are now deprecated and implemented as stubs redirecting to __sanitizer_ versions (which are implemented differently in each tool). Replace all uses of __xsan_ versions with __sanitizer_ versions in unit and lit tests. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@212469 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/tests')
-rw-r--r--lib/tsan/tests/unit/tsan_mman_test.cc45
1 files changed, 18 insertions, 27 deletions
diff --git a/lib/tsan/tests/unit/tsan_mman_test.cc b/lib/tsan/tests/unit/tsan_mman_test.cc
index e52a85aac..0c4a8ffc8 100644
--- a/lib/tsan/tests/unit/tsan_mman_test.cc
+++ b/lib/tsan/tests/unit/tsan_mman_test.cc
@@ -11,20 +11,11 @@
//
//===----------------------------------------------------------------------===//
#include <limits>
+#include <sanitizer/allocator_interface.h>
#include "tsan_mman.h"
#include "tsan_rtl.h"
#include "gtest/gtest.h"
-extern "C" {
-uptr __tsan_get_current_allocated_bytes();
-uptr __tsan_get_heap_size();
-uptr __tsan_get_free_bytes();
-uptr __tsan_get_unmapped_bytes();
-uptr __tsan_get_estimated_allocated_size(uptr size);
-bool __tsan_get_ownership(void *p);
-uptr __tsan_get_allocated_size(void *p);
-}
-
namespace __tsan {
TEST(Mman, Internal) {
@@ -118,30 +109,30 @@ TEST(Mman, UsableSize) {
TEST(Mman, Stats) {
ThreadState *thr = cur_thread();
- uptr alloc0 = __tsan_get_current_allocated_bytes();
- uptr heap0 = __tsan_get_heap_size();
- uptr free0 = __tsan_get_free_bytes();
- uptr unmapped0 = __tsan_get_unmapped_bytes();
+ uptr alloc0 = __sanitizer_get_current_allocated_bytes();
+ uptr heap0 = __sanitizer_get_heap_size();
+ uptr free0 = __sanitizer_get_free_bytes();
+ uptr unmapped0 = __sanitizer_get_unmapped_bytes();
- EXPECT_EQ(__tsan_get_estimated_allocated_size(10), (uptr)10);
- EXPECT_EQ(__tsan_get_estimated_allocated_size(20), (uptr)20);
- EXPECT_EQ(__tsan_get_estimated_allocated_size(100), (uptr)100);
+ EXPECT_EQ(10U, __sanitizer_get_estimated_allocated_size(10));
+ EXPECT_EQ(20U, __sanitizer_get_estimated_allocated_size(20));
+ EXPECT_EQ(100U, __sanitizer_get_estimated_allocated_size(100));
char *p = (char*)user_alloc(thr, 0, 10);
- EXPECT_EQ(__tsan_get_ownership(p), true);
- EXPECT_EQ(__tsan_get_allocated_size(p), (uptr)10);
+ EXPECT_TRUE(__sanitizer_get_ownership(p));
+ EXPECT_EQ(10U, __sanitizer_get_allocated_size(p));
- EXPECT_EQ(__tsan_get_current_allocated_bytes(), alloc0 + 16);
- EXPECT_GE(__tsan_get_heap_size(), heap0);
- EXPECT_EQ(__tsan_get_free_bytes(), free0);
- EXPECT_EQ(__tsan_get_unmapped_bytes(), unmapped0);
+ EXPECT_EQ(alloc0 + 16, __sanitizer_get_current_allocated_bytes());
+ EXPECT_GE(__sanitizer_get_heap_size(), heap0);
+ EXPECT_EQ(free0, __sanitizer_get_free_bytes());
+ EXPECT_EQ(unmapped0, __sanitizer_get_unmapped_bytes());
user_free(thr, 0, p);
- EXPECT_EQ(__tsan_get_current_allocated_bytes(), alloc0);
- EXPECT_GE(__tsan_get_heap_size(), heap0);
- EXPECT_EQ(__tsan_get_free_bytes(), free0);
- EXPECT_EQ(__tsan_get_unmapped_bytes(), unmapped0);
+ EXPECT_EQ(alloc0, __sanitizer_get_current_allocated_bytes());
+ EXPECT_GE(__sanitizer_get_heap_size(), heap0);
+ EXPECT_EQ(free0, __sanitizer_get_free_bytes());
+ EXPECT_EQ(unmapped0, __sanitizer_get_unmapped_bytes());
}
TEST(Mman, CallocOverflow) {