summaryrefslogtreecommitdiff
path: root/standalone/tests/map_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'standalone/tests/map_test.cpp')
-rw-r--r--standalone/tests/map_test.cpp26
1 files changed, 9 insertions, 17 deletions
diff --git a/standalone/tests/map_test.cpp b/standalone/tests/map_test.cpp
index ff05258db58..7c40b73ff25 100644
--- a/standalone/tests/map_test.cpp
+++ b/standalone/tests/map_test.cpp
@@ -17,10 +17,10 @@ static const char *MappingName = "scudo:test";
TEST(ScudoMapTest, PageSize) {
EXPECT_EQ(scudo::getPageSizeCached(),
- static_cast<scudo::uptr>(sysconf(_SC_PAGESIZE)));
+ static_cast<scudo::uptr>(getpagesize()));
}
-TEST(ScudoMapDeathTest, MapNoAccessUnmap) {
+TEST(ScudoMapTest, MapNoAccessUnmap) {
const scudo::uptr Size = 4 * scudo::getPageSizeCached();
scudo::MapPlatformData Data = {};
void *P = scudo::map(nullptr, Size, MappingName, MAP_NOACCESS, &Data);
@@ -29,24 +29,16 @@ TEST(ScudoMapDeathTest, MapNoAccessUnmap) {
scudo::unmap(P, Size, UNMAP_ALL, &Data);
}
-TEST(ScudoMapDeathTest, MapUnmap) {
+TEST(ScudoMapTest, MapUnmap) {
const scudo::uptr Size = 4 * scudo::getPageSizeCached();
- EXPECT_DEATH(
- {
- // Repeat few time to avoid missing crash if it's mmaped by unrelated
- // code.
- for (int i = 0; i < 10; ++i) {
- void *P = scudo::map(nullptr, Size, MappingName, 0, nullptr);
- if (!P)
- continue;
- scudo::unmap(P, Size, 0, nullptr);
- memset(P, 0xbb, Size);
- }
- },
- "");
+ void *P = scudo::map(nullptr, Size, MappingName, 0, nullptr);
+ EXPECT_NE(P, nullptr);
+ memset(P, 0xaa, Size);
+ scudo::unmap(P, Size, 0, nullptr);
+ EXPECT_DEATH(memset(P, 0xbb, Size), "");
}
-TEST(ScudoMapDeathTest, MapWithGuardUnmap) {
+TEST(ScudoMapTest, MapWithGuardUnmap) {
const scudo::uptr PageSize = scudo::getPageSizeCached();
const scudo::uptr Size = 4 * PageSize;
scudo::MapPlatformData Data = {};