diff --git a/kernel_lite/process_posix/src/UidGidTest.cpp b/kernel_lite/process_posix/src/UidGidTest.cpp index cde44231371673ac2c52011b983bfc303b2a7f5b..bd70bfc11273b0edc2549285442ff62a01ccf97b 100755 --- a/kernel_lite/process_posix/src/UidGidTest.cpp +++ b/kernel_lite/process_posix/src/UidGidTest.cpp @@ -640,10 +640,11 @@ 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); + getgroups(n, gidList); + ASSERT_EQ(gidList[0], SHELL_GID); n = getgroups(testSize, gidList); - ASSERT_EQ(n, 1); + ASSERT_EQ(n, 2); ASSERT_EQ(gidList[0], SHELL_GID); } @@ -705,8 +706,9 @@ 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); + getgroups(n, gidListOut); EXPECT_EQ(gidListOut[0], SHELL_GID); LOG("add 2 groups"); @@ -721,8 +723,9 @@ 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); + getgroups(n, gidListOut); EXPECT_EQ(gidListOut[0], SHELL_GID); } diff --git a/kernel_lite/process_posix/src/UidGidTest.h b/kernel_lite/process_posix/src/UidGidTest.h index fc3a1131322bc4814e583a39ee7dc4952f294c32..59857448962bb41bbe69210208176d8b7222e980 100755 --- a/kernel_lite/process_posix/src/UidGidTest.h +++ b/kernel_lite/process_posix/src/UidGidTest.h @@ -57,11 +57,14 @@ protected: void TearDown() { LOG("TearDown: reset uid and gid"); + gid_t gidList[2]; + gidList[0] = SHELL_UID; + gidList[1] = 0; setuid(SHELL_UID); setgid(SHELL_GID); AssertAllUid(SHELL_UID); AssertAllGid(SHELL_GID); - int rt = setgroups(0, NULL); + int rt = setgroups(2, gidList); } };