From 7ff86c1f9a06dad5f5590544e7667666dbd162ba Mon Sep 17 00:00:00 2001 From: Kostya Kortchinsky Date: Mon, 30 Oct 2017 19:06:59 +0000 Subject: Fix warning + death test + failing test on Windows (D39072). Summary: Fixes https://reviews.llvm.org/D39072 Reviewers: cryptoad Reviewed By: cryptoad Subscribers: kubamracek Differential Revision: https://reviews.llvm.org/D39427 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316943 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/sanitizer_common/tests/sanitizer_common_test.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'lib/sanitizer_common/tests') diff --git a/lib/sanitizer_common/tests/sanitizer_common_test.cc b/lib/sanitizer_common/tests/sanitizer_common_test.cc index 38170ea6d..576649cea 100644 --- a/lib/sanitizer_common/tests/sanitizer_common_test.cc +++ b/lib/sanitizer_common/tests/sanitizer_common_test.cc @@ -349,25 +349,23 @@ TEST(SanitizerCommon, ReservedAddressRangeMap) { unsigned char buffer[init_size]; memcpy(buffer, reinterpret_cast(res), init_size); - // Invalid mappings should fail. - EXPECT_DEATH(address_range.Map(res, 0), ".*"); - // TODO(flowerhack): Once this is switched to the "real" implementation, make // sure you can only mmap into offsets in the Init range. } TEST(SanitizerCommon, ReservedAddressRangeUnmap) { uptr PageSize = GetPageSizeCached(); - uptr init_size = PageSize * 4; + uptr init_size = PageSize * 8; ReservedAddressRange address_range; uptr base_addr = address_range.Init(init_size); CHECK_NE(base_addr, (void*)-1); CHECK_EQ(base_addr, address_range.Map(base_addr, init_size)); // Unmapping the entire range should succeed. - address_range.Unmap(base_addr, PageSize * 4); + address_range.Unmap(base_addr, init_size); - // Remap that range in. + // Map a new range. + base_addr = address_range.Init(init_size); CHECK_EQ(base_addr, address_range.Map(base_addr, init_size)); // Windows doesn't allow partial unmappings. @@ -384,7 +382,7 @@ TEST(SanitizerCommon, ReservedAddressRangeUnmap) { #endif // Unmapping in the middle of the ReservedAddressRange should fail. - EXPECT_DEATH(address_range.Unmap(base_addr + 0xf, 0xff), ".*"); + EXPECT_DEATH(address_range.Unmap(base_addr + (PageSize * 2), PageSize), ".*"); } } // namespace __sanitizer -- cgit v1.2.3