提交 2c748682 编写于 作者: L limeng151

修改groups用例的问题

Signed-off-by: Nlimeng151 <limeng151@huawei.com>
Change-Id: I9c45dadcd362a5dc68abbba522eb002e183604be
上级 eb2f7c2a
...@@ -640,10 +640,11 @@ HWTEST_F(UidGidTest, testGetgroups, Function | MediumTest | Level1) ...@@ -640,10 +640,11 @@ HWTEST_F(UidGidTest, testGetgroups, Function | MediumTest | Level1)
const int testSize = 10; const int testSize = 10;
gid_t gidList[testSize] = {0}; gid_t gidList[testSize] = {0};
int n = getgroups(0, gidList); int n = getgroups(0, gidList);
ASSERT_EQ(n, 1); ASSERT_EQ(n, 2);
ASSERT_EQ(gidList[0], 0); getgroups(n, gidList);
ASSERT_EQ(gidList[0], SHELL_GID);
n = getgroups(testSize, gidList); n = getgroups(testSize, gidList);
ASSERT_EQ(n, 1); ASSERT_EQ(n, 2);
ASSERT_EQ(gidList[0], SHELL_GID); ASSERT_EQ(gidList[0], SHELL_GID);
} }
...@@ -705,8 +706,9 @@ HWTEST_F(UidGidTest, testSetgroups2, Function | MediumTest | Level1) ...@@ -705,8 +706,9 @@ HWTEST_F(UidGidTest, testSetgroups2, Function | MediumTest | Level1)
gid_t gidListOut[4] = {0}; gid_t gidListOut[4] = {0};
LOG("Init: make sure groups not changed by other test."); LOG("Init: make sure groups not changed by other test.");
int n = getgroups(1, gidListOut); int n = getgroups(0, gidListOut);
EXPECT_EQ(n, 1); EXPECT_EQ(n, 2);
getgroups(n, gidListOut);
EXPECT_EQ(gidListOut[0], SHELL_GID); EXPECT_EQ(gidListOut[0], SHELL_GID);
LOG("add 2 groups"); LOG("add 2 groups");
...@@ -721,8 +723,9 @@ HWTEST_F(UidGidTest, testSetgroups2, Function | MediumTest | Level1) ...@@ -721,8 +723,9 @@ HWTEST_F(UidGidTest, testSetgroups2, Function | MediumTest | Level1)
LOG("clear groups"); LOG("clear groups");
rt = setgroups(0, NULL); rt = setgroups(0, NULL);
EXPECT_EQ(rt, 0); EXPECT_EQ(rt, 0);
n = getgroups(2, gidListOut); n = getgroups(0, gidListOut);
EXPECT_EQ(n, 1); EXPECT_EQ(n, 1);
getgroups(n, gidListOut);
EXPECT_EQ(gidListOut[0], SHELL_GID); EXPECT_EQ(gidListOut[0], SHELL_GID);
} }
......
...@@ -57,11 +57,14 @@ protected: ...@@ -57,11 +57,14 @@ protected:
void TearDown() void TearDown()
{ {
LOG("TearDown: reset uid and gid"); LOG("TearDown: reset uid and gid");
gid_t gidList[2];
gidList[0] = SHELL_UID;
gidList[1] = 0;
setuid(SHELL_UID); setuid(SHELL_UID);
setgid(SHELL_GID); setgid(SHELL_GID);
AssertAllUid(SHELL_UID); AssertAllUid(SHELL_UID);
AssertAllGid(SHELL_GID); AssertAllGid(SHELL_GID);
int rt = setgroups(0, NULL); int rt = setgroups(2, gidList);
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册