From d53fa46a8c928dbecb24174d1eca5ea49e200e2e Mon Sep 17 00:00:00 2001 From: limeng Date: Thu, 16 Sep 2021 15:56:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9mem=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: limeng Change-Id: Ife335f2aab67dbe241fe02e1ef3d5e102eb6bf88 --- kernel_lite/mem_posix/src/MmapApiTest.cpp | 31 ++++++++++++------- kernel_lite/mem_posix/src/MprotectApiTest.cpp | 19 +++++++----- kernel_lite/mem_posix/src/MremapApiTest.cpp | 22 +++++++------ 3 files changed, 45 insertions(+), 27 deletions(-) diff --git a/kernel_lite/mem_posix/src/MmapApiTest.cpp b/kernel_lite/mem_posix/src/MmapApiTest.cpp index c7adadc68..d48ba7f6e 100755 --- a/kernel_lite/mem_posix/src/MmapApiTest.cpp +++ b/kernel_lite/mem_posix/src/MmapApiTest.cpp @@ -348,7 +348,8 @@ HWTEST_F(MmapApiTest, testMmapFilePrivate, Function | MediumTest | Level3) EXPECT_TRUE(munmap(mem, len) == 0) << "ERROR: munmap() != 0"; EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } } @@ -393,7 +394,8 @@ HWTEST_F(MmapApiTest, testMmapFileShare, Function | MediumTest | Level3) EXPECT_TRUE(munmap(mem, len) == 0) << "ERROR: munmap() != 0"; EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } } @@ -433,7 +435,8 @@ HWTEST_F(MmapApiTest, testMmapFileShareOnlyRead, Function | MediumTest | Level1) EXPECT_TRUE(munmap(mem, len) == 0) << "ERROR: munmap() != 0"; EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } } @@ -475,7 +478,8 @@ HWTEST_F(MmapApiTest, testMmapFileShareOnlyWrite, Function | MediumTest | Level3 EXPECT_TRUE(munmap(mem, len) == 0) << "ERROR: munmap() != 0"; EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } } @@ -521,7 +525,8 @@ HWTEST_F(MmapApiTest, testMmapFilePrivateExec, Function | MediumTest | Level4) EXPECT_TRUE(munmap(mem, len) == 0) << "ERROR: munmap() != 0"; EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } } @@ -567,7 +572,8 @@ HWTEST_F(MmapApiTest, testMmapFileShareExec, Function | MediumTest | Level4) EXPECT_TRUE(munmap(mem, len) == 0) << "ERROR: munmap() != 0"; EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } } @@ -610,7 +616,8 @@ HWTEST_F(MmapApiTest, testMmapFileShareNoExec, Function | MediumTest | Level2) EXPECT_TRUE(munmap(mem, len) == 0) << "ERROR: munmap() != 0"; EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } } @@ -743,7 +750,8 @@ HWTEST_F(MmapApiTest, testMmapWriteBack, Function | MediumTest | Level3) EXPECT_TRUE(failure == 0) << "i = " << i << ", rBuffer = " << rBuffer[i]; EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } /** @@ -783,8 +791,8 @@ HWTEST_F(MmapApiTest, testMmapEACCES, Function | MediumTest | Level3) EXPECT_TRUE(munmap(mem, len) == 0) << "ERROR: munmap() != 0"; } EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } /** @@ -888,7 +896,8 @@ HWTEST_F(MmapApiTest, testMmapEINVAL, Function | MediumTest | Level3) } EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } /** diff --git a/kernel_lite/mem_posix/src/MprotectApiTest.cpp b/kernel_lite/mem_posix/src/MprotectApiTest.cpp index dbdec095d..9d84de551 100755 --- a/kernel_lite/mem_posix/src/MprotectApiTest.cpp +++ b/kernel_lite/mem_posix/src/MprotectApiTest.cpp @@ -252,7 +252,8 @@ HWTEST_F(MprotectApiTest, testMprotectFileAddReadPerm, Function | MediumTest | L WaitProcExitedOK(pid); EXPECT_TRUE(munmap(mem, len) == 0) << "ERROR: munmap() != 0"; EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } } @@ -308,7 +309,8 @@ HWTEST_F(MprotectApiTest, testMprotectFileAddWritePerm, Function | MediumTest | EXPECT_TRUE(buf[0] == testChar) << "ERROR: buf[0] != testChar"; EXPECT_TRUE(buf[1] == (testChar + 3)) << "ERROR: buf[1] != (testChar + 3)"; EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } } @@ -350,7 +352,8 @@ HWTEST_F(MprotectApiTest, testMprotectFileAddExecutePerm, Function | MediumTest WaitProcExitedOK(pid); EXPECT_TRUE(munmap(mem, len) == 0) << "ERROR: munmap() != 0"; EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } } @@ -394,7 +397,8 @@ HWTEST_F(MprotectApiTest, testMprotectFileDelWritePerm, Function | MediumTest | EXPECT_TRUE(munmap(mem, len) == 0) << "ERROR: munmap() != 0"; EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } } @@ -437,7 +441,8 @@ HWTEST_F(MprotectApiTest, testMprotectFileDelExecutePerm, Function | MediumTest EXPECT_TRUE(munmap(mem, len) == 0) << "ERROR: munmap() != 0"; EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } } @@ -465,8 +470,8 @@ HWTEST_F(MprotectApiTest, testMprotectEACCES, Function | MediumTest | Level4) EXPECT_TRUE(munmap(mem, len) == 0) << "ERROR: munmap() != 0"; EXPECT_TRUE(close(fd) != -1) << "ERROR: close() == -1"; - - EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0"; + Msleep(1000); + EXPECT_TRUE(remove(file) == 0) << "ERROR: remove() != 0" << errno; } /** diff --git a/kernel_lite/mem_posix/src/MremapApiTest.cpp b/kernel_lite/mem_posix/src/MremapApiTest.cpp index 872e6546b..8f069f7b6 100755 --- a/kernel_lite/mem_posix/src/MremapApiTest.cpp +++ b/kernel_lite/mem_posix/src/MremapApiTest.cpp @@ -97,7 +97,7 @@ HWTEST_F(MremapApiTest, testMremapAnonExpand, Function | MediumTest | Level2) exit(0); } else { WaitProcExitedOK(pid); - EXPECT_TRUE(munmap(mem, expandSize) == 0) << "ERROR: munmap() != 0"; + EXPECT_TRUE(munmap(mem, expandSize) == 0) << "ERROR: munmap() != 0" << errno; } } @@ -135,7 +135,7 @@ HWTEST_F(MremapApiTest, testMremapAnonShrink, Function | MediumTest | Level3) exit(0); } else { ExpectProcCrashed(pid); - EXPECT_TRUE(munmap(mem, shrinkSize) == 0) << "ERROR: munmap() != 0"; + EXPECT_TRUE(munmap(mem, shrinkSize) == 0) << "ERROR: munmap() != 0" << errno; } } @@ -179,7 +179,7 @@ HWTEST_F(MremapApiTest, testMremapAnonExpandFixAddr, Function | MediumTest | Lev exit(0); } else { WaitProcExitedOK(pid); - EXPECT_TRUE(munmap(mem, expandSize) == 0) << "ERROR: munmap() != 0"; + EXPECT_TRUE(munmap(mem, expandSize) == 0) << "ERROR: munmap() != 0" << errno; } } @@ -219,7 +219,7 @@ HWTEST_F(MremapApiTest, testMremapAnonShrinkFixAddr, Function | MediumTest | Lev exit(0); } else { ExpectProcCrashed(pid); - EXPECT_TRUE(munmap(mem, shrinkSize) == 0) << "ERROR: munmap() != 0"; + EXPECT_TRUE(munmap(mem, shrinkSize) == 0) << "ERROR: munmap() != 0" <