Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
6a011683
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看板
提交
6a011683
编写于
7月 19, 2021
作者:
O
openharmony_ci
提交者:
Gitee
7月 19, 2021
浏览文件
操作
浏览文件
下载
差异文件
!332 【kernel_lite】【master】修改groups用例引起的相关问题
Merge pull request !332 from limeng/kernel_lite_20210716_03
上级
be347d7e
8794d07c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
8 deletion
+36
-8
kernel_lite/process_posix/src/UidGidTest.cpp
kernel_lite/process_posix/src/UidGidTest.cpp
+16
-7
kernel_lite/process_posix/src/UidGidTest.h
kernel_lite/process_posix/src/UidGidTest.h
+20
-1
未找到文件。
kernel_lite/process_posix/src/UidGidTest.cpp
浏览文件 @
6a011683
...
...
@@ -640,11 +640,15 @@ HWTEST_F(UidGidTest, testGetgroups, Function | MediumTest | Level1)
const
int
testSize
=
10
;
gid_t
gidList
[
testSize
]
=
{
0
};
int
n
=
getgroups
(
0
,
gidList
);
ASSERT_EQ
(
n
,
1
);
ASSERT_EQ
(
gidList
[
0
],
0
);
ASSERT_EQ
(
n
,
2
);
int
rt
=
getgroups
(
n
,
gidList
);
ASSERT_EQ
(
gidList
[
0
],
SHELL_GID
);
ASSERT_EQ
(
gidList
[
1
],
0
);
ASSERT_EQ
(
rt
,
n
);
n
=
getgroups
(
testSize
,
gidList
);
ASSERT_EQ
(
n
,
1
);
ASSERT_EQ
(
n
,
2
);
ASSERT_EQ
(
gidList
[
0
],
SHELL_GID
);
ASSERT_EQ
(
gidList
[
1
],
0
);
}
/**
...
...
@@ -705,12 +709,15 @@ HWTEST_F(UidGidTest, testSetgroups2, Function | MediumTest | Level1)
gid_t
gidListOut
[
4
]
=
{
0
};
LOG
(
"Init: make sure groups not changed by other test."
);
int
n
=
getgroups
(
1
,
gidListOut
);
EXPECT_EQ
(
n
,
1
);
int
n
=
getgroups
(
0
,
gidListOut
);
EXPECT_EQ
(
n
,
2
);
int
rt
=
getgroups
(
n
,
gidListOut
);
EXPECT_EQ
(
gidListOut
[
0
],
SHELL_GID
);
EXPECT_EQ
(
gidListOut
[
1
],
0
);
EXPECT_EQ
(
rt
,
n
);
LOG
(
"add 2 groups"
);
int
rt
=
setgroups
(
2
,
gidListIn
);
rt
=
setgroups
(
2
,
gidListIn
);
EXPECT_EQ
(
rt
,
0
);
n
=
getgroups
(
4
,
gidListOut
);
EXPECT_EQ
(
n
,
3
);
...
...
@@ -721,8 +728,10 @@ HWTEST_F(UidGidTest, testSetgroups2, Function | MediumTest | Level1)
LOG
(
"clear groups"
);
rt
=
setgroups
(
0
,
NULL
);
EXPECT_EQ
(
rt
,
0
);
n
=
getgroups
(
2
,
gidListOut
);
n
=
getgroups
(
0
,
gidListOut
);
EXPECT_EQ
(
n
,
1
);
rt
=
getgroups
(
n
,
gidListOut
);
EXPECT_EQ
(
rt
,
n
);
EXPECT_EQ
(
gidListOut
[
0
],
SHELL_GID
);
}
...
...
kernel_lite/process_posix/src/UidGidTest.h
浏览文件 @
6a011683
...
...
@@ -23,6 +23,9 @@
// max test number of uid/gid, not actual max number
const
int
MAX_UGID
=
100000
;
static
int
groupNum
=
-
1
;
const
int
ARRAY_SIZE
=
10
;
static
gid_t
groupsArray
[
ARRAY_SIZE
]
=
{
0
};
// Assert all uid == expectUid
#define AssertAllUid(expectUid) do { \
...
...
@@ -54,14 +57,30 @@ public:
return
id
;
}
protected:
static
void
SetUpTestCase
()
{
for
(
int
i
=
0
;
i
<
ARRAY_SIZE
;
i
++
)
{
groupsArray
[
i
]
=
-
1
;
}
groupNum
=
getgroups
(
0
,
groupsArray
);
EXPECT_NE
(
groupNum
,
-
1
);
int
rt
=
getgroups
(
groupNum
,
groupsArray
);
EXPECT_EQ
(
rt
,
groupNum
);
}
void
TearDown
()
{
LOG
(
"TearDown: reset uid and gid"
);
gid_t
groupIds
[
groupNum
];
LOG
(
"TearDown: reset uid and gid %d"
,
sizeof
(
groupIds
)
/
sizeof
(
gid_t
));
for
(
int
i
=
0
;
i
<
groupNum
;
i
++
)
{
groupIds
[
i
]
=
groupsArray
[
i
];
}
setuid
(
SHELL_UID
);
setgid
(
SHELL_GID
);
AssertAllUid
(
SHELL_UID
);
AssertAllGid
(
SHELL_GID
);
int
rt
=
setgroups
(
0
,
NULL
);
int
rt
=
setgroups
(
groupNum
,
groupIds
);
EXPECT_EQ
(
rt
,
0
);
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录