From ce0395478c1bf47fa3460b1dde4cb7b9179e76af Mon Sep 17 00:00:00 2001 From: wenlong12 Date: Thu, 20 Jul 2023 20:24:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86codex=E5=91=8A=E8=AD=A6=20Sig?= =?UTF-8?q?ned-off-by:wenlong12=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wenlong12 --- device/plugins/native_hook/test/statistics_test.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/device/plugins/native_hook/test/statistics_test.cpp b/device/plugins/native_hook/test/statistics_test.cpp index b69ed6a0a..80a5eae8f 100644 --- a/device/plugins/native_hook/test/statistics_test.cpp +++ b/device/plugins/native_hook/test/statistics_test.cpp @@ -250,13 +250,15 @@ static void* HhreadFuncCpp(void* param) static void TestMemoryMap() { + constexpr int smartSize = 4096; + constexpr int bigSize = 8192; int fd = open("/bin/hiebpf", O_RDWR | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); if (fd < 0) { printf("open %s failed\n", "/bin/hiebpf"); return; } - void* mapAddr1 = mmap(nullptr, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_POPULATE, fd, 0); + void* mapAddr1 = mmap(nullptr, smartSize, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_POPULATE, fd, 0); if (mapAddr1 == MAP_FAILED) { printf("named mmap failed\n"); close(fd); @@ -264,11 +266,11 @@ static void TestMemoryMap() } printf("named mmap size: 4096, fd: %d\n", fd); - void* mapAddr2 = mmap(nullptr, 8192, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + void* mapAddr2 = mmap(nullptr, bigSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (mapAddr2 == MAP_FAILED) { printf("anonymous mmap failed\n"); close(fd); - munmap(mapAddr1, 4096); + munmap(mapAddr1, smartSize); return; } printf("anonymous mmap size: 8192\n"); @@ -279,8 +281,8 @@ static void TestMemoryMap() memtrace(reinterpret_cast(0x123456), 3333, "memtrace_test", false); // 3333 num printf("memtrace(0x123456, 3333, \"memtrace_test\", false)\n"); close(fd); - munmap(mapAddr1, 4096); - munmap(mapAddr2, 8192); + munmap(mapAddr1, smartSize); + munmap(mapAddr2, bigSize); } int main(int argc, char *argv[])