提交 f5c20786 编写于 作者: R root

Remove unstable use cases

Change-Id: Iecfb9428e87a25eda5f55fa4b250c66fecaf9002
上级 1255eb11
......@@ -930,128 +930,6 @@ HWTEST_F(MmapApiTest, testMmapENOMEM, Function | MediumTest | Level3)
}
}
/**
* @tc.number SUB_KERNEL_MEM_MMAP_2100
* @tc.name mmap function overlay region and fix map test
* @tc.desc [C-L*-311] MUST NOT alter NDK API behavior.
*/
HWTEST_F(MmapApiTest, testMmapOverlayWithFixedFlag, Function | MediumTest | Level3)
{
size_t len = 0x00200000;
int flag = MAP_ANON | MAP_SHARED | MAP_FIXED;
char *mem = (char *)mmap(nullptr, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0);
LOG("mem = %p, mem + len = %p", mem, mem + len);
ASSERT_TRUE(mem != MAP_FAILED) << "mem == MAP_FAILED";
char *getAddr = mem + 0x00100000;
char *newAddr = (char *)mmap((void *)getAddr, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0);
LOG("getAddr = %p, newAddr = %p, newAddr + len = %p", getAddr, newAddr, newAddr + len);
EXPECT_TRUE(newAddr != MAP_FAILED && newAddr != getAddr) << "mem == MAP_FAILED or newAddr == getAddr";
char *fixAddr = (char *)mmap((void *)getAddr, len, PROT_READ | PROT_WRITE, flag, -1, 0);
LOG("getAddr = %p, fixAddr = %p, fixAddr + len = %p", getAddr, fixAddr, fixAddr + len);
EXPECT_TRUE(fixAddr == getAddr) << "fixAddr != mem";
if (fixAddr != MAP_FAILED) {
EXPECT_TRUE(munmap(fixAddr, len) == 0) << "ERROR: munmap() != 0";
}
if (newAddr != MAP_FAILED) {
EXPECT_TRUE(munmap(newAddr, len) == 0) << "ERROR: munmap() != 0";
}
if (mem != MAP_FAILED) {
EXPECT_TRUE(munmap(mem, len) == 0) << "ERROR: munmap() != 0";
}
}
/**
* @tc.number SUB_KERNEL_MEM_MMAP_2200
* @tc.name mmap function anonymous private and file private map with MAP_FIXED flag test
* @tc.desc [C-L*-311] MUST NOT alter NDK API behavior.
*/
HWTEST_F(MmapApiTest, testMmapPrivateWithFixedFlag, Function | MediumTest | Level2)
{
size_t len = PAGE_SIZE;
unsigned long fixAddr = 0x24000000UL;
int flag = MAP_ANON | MAP_PRIVATE | MAP_FIXED;
char *mem = (char *)mmap((void *)fixAddr, len, PROT_READ | PROT_WRITE, flag, -1, 0);
LOG("mem = %p, mem + len = %p", mem, mem + len);
ASSERT_TRUE(mem != MAP_FAILED) << "mem == MAP_FAILED";
/* read and write test */
mem[0] = 0x30;
mem[4] = mem[0];
EXPECT_TRUE(munmap(mem, len) == 0) << "ERROR: munmap() != 0";
/* mmap file map with MAP_FIXED flag test */
char buf[PAGE_SIZE] = {0};
char file[] = MMAP_TESTFILE;
int fd = open(file, O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
ASSERT_TRUE(fd != -1) << "ERROR: open() == -1";
int wByte = write(fd, buf, len);
EXPECT_TRUE(wByte > 0) << "ERROR: write() <= 0";
fixAddr = 0x26000000UL;
mem = (char *)mmap((void *)fixAddr, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 0);
LOG("mem = %p, mem + len = %p", mem, mem + len);
ASSERT_TRUE(mem != MAP_FAILED) << "mem == MAP_FAILED";
/* read and write test */
mem[128] = 0x36;
mem[256] = mem[128];
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";
}
/**
* @tc.number SUB_KERNEL_MEM_MMAP_2300
* @tc.name mmap function file share map with MAP_FIXED flag test
* @tc.desc [C-L*-311] MUST NOT alter NDK API behavior.
*/
HWTEST_F(MmapApiTest, testMmapShareWithFixedFlag, Function | MediumTest | Level2)
{
const size_t len = PAGE_SIZE;
char testChar = 'A';
int prot = PROT_READ | PROT_WRITE;
int flags = MAP_SHARED | MAP_FIXED;
char buf[PAGE_SIZE] = {0};
unsigned long fixAddr = 0x24000000UL;
char file[] = MMAP_TESTFILE;
int fd = open(file, O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
ASSERT_TRUE(fd != -1) << "ERROR: open() == -1";
int wByte = write(fd, buf, len);
EXPECT_TRUE(wByte > 0) << "ERROR: write() <= 0";
char *mem = (char *)mmap((void *)fixAddr, len, prot, flags, fd, 0);
ASSERT_TRUE(mem != MAP_FAILED) << "mem == MAP_FAILED";
pid_t pid = fork();
EXPECT_TRUE(pid >= 0) << "Fork Error";
if (pid == 0) {
mem[0] = testChar;
mem[1] = testChar + 3;
exit(0);
} else {
WaitProcExitedOK(pid);
LOG("mem[0] = %c (0x%02x)", mem[0], mem[0]);
LOG("mem[1] = %c (0x%02x)", mem[1], mem[1]);
EXPECT_TRUE(mem[0] == testChar) << "mem[0] = " << mem[0];
EXPECT_TRUE(mem[1] == (testChar + 3)) << "mem[1] = " << mem[1];
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";
}
}
/**
* @tc.number SUB_KERNEL_MEM_MUNMAP_0100
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册