Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
f5c20786
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f5c20786
编写于
4月 17, 2021
作者:
R
root
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unstable use cases
Change-Id: Iecfb9428e87a25eda5f55fa4b250c66fecaf9002
上级
1255eb11
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
122 deletion
+0
-122
kernel_lite/mem_posix/src/MmapApiTest.cpp
kernel_lite/mem_posix/src/MmapApiTest.cpp
+0
-122
未找到文件。
kernel_lite/mem_posix/src/MmapApiTest.cpp
浏览文件 @
f5c20786
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录