summaryrefslogtreecommitdiff
path: root/lib/msan/tests
diff options
context:
space:
mode:
authorMarcin Koscielnicki <koriakin@0x04.net>2016-04-18 22:21:02 +0000
committerMarcin Koscielnicki <koriakin@0x04.net>2016-04-18 22:21:02 +0000
commitde3d40e84dc22a9f116b60ac1f13fd1fdb853b2e (patch)
tree26e0cef86a064ebba3ed2d59365883b3e5f39a8c /lib/msan/tests
parent67c4cad56d662b70fa341c55871cfc176198b8d7 (diff)
[msan] Don't hardcode 4kiB page size in msan_test.cc.
This breaks the valloc test on PowerPC, which has 64kiB pages. Since getting page size portably is nontrivial, and there's already a function for that in __sanitizer, just use it. Unfortunately, sanitizer_common.h conflicts with the interface headers inclucded by msan_test.cc (and a few of its own macros), so we have to declare it manually. Differential Revision: http://reviews.llvm.org/D19227 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266688 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/msan/tests')
-rw-r--r--lib/msan/tests/msan_test.cc25
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/msan/tests/msan_test.cc b/lib/msan/tests/msan_test.cc
index 0ef4b0c16..a7a06a062 100644
--- a/lib/msan/tests/msan_test.cc
+++ b/lib/msan/tests/msan_test.cc
@@ -115,7 +115,14 @@ void *mempcpy(void *dest, const void *src, size_t n);
# define SUPERUSER_GROUP "root"
#endif
-const size_t kPageSize = 4096;
+// We cannot include sanitizer_common.h (it conflicts with public interface
+// headers), so just pull this function directly.
+
+namespace __sanitizer {
+uintptr_t GetPageSizeCached();
+}
+using __sanitizer::GetPageSizeCached;
+
const size_t kMaxPathLength = 4096;
typedef unsigned char U1;
@@ -3225,28 +3232,30 @@ TEST(MemorySanitizer, posix_memalign) {
#if !defined(__FreeBSD__)
TEST(MemorySanitizer, memalign) {
void *p = memalign(4096, 13);
- EXPECT_EQ(0U, (uintptr_t)p % kPageSize);
+ EXPECT_EQ(0U, (uintptr_t)p % 4096);
free(p);
}
#endif
TEST(MemorySanitizer, valloc) {
void *a = valloc(100);
- EXPECT_EQ(0U, (uintptr_t)a % kPageSize);
+ uintptr_t PageSize = GetPageSizeCached();
+ EXPECT_EQ(0U, (uintptr_t)a % PageSize);
free(a);
}
// There's no pvalloc() on FreeBSD.
#if !defined(__FreeBSD__)
TEST(MemorySanitizer, pvalloc) {
- void *p = pvalloc(kPageSize + 100);
- EXPECT_EQ(0U, (uintptr_t)p % kPageSize);
- EXPECT_EQ(2 * kPageSize, __sanitizer_get_allocated_size(p));
+ uintptr_t PageSize = GetPageSizeCached();
+ void *p = pvalloc(PageSize + 100);
+ EXPECT_EQ(0U, (uintptr_t)p % PageSize);
+ EXPECT_EQ(2 * PageSize, __sanitizer_get_allocated_size(p));
free(p);
p = pvalloc(0); // pvalloc(0) should allocate at least one page.
- EXPECT_EQ(0U, (uintptr_t)p % kPageSize);
- EXPECT_EQ(kPageSize, __sanitizer_get_allocated_size(p));
+ EXPECT_EQ(0U, (uintptr_t)p % PageSize);
+ EXPECT_EQ(PageSize, __sanitizer_get_allocated_size(p));
free(p);
}
#endif