From 40046b295d111ff240191344f1e1df5e945c5860 Mon Sep 17 00:00:00 2001 From: limeng151 Date: Thu, 12 Aug 2021 09:20:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9gid=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: limeng151 Change-Id: I53cabd62b0c0d9359a018c967a3b5e9500013593 --- kernel_lite/process_posix/src/UidGidTest.cpp | 12 ++++++------ kernel_lite/process_posix/src/UidGidTest.h | 6 +----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/kernel_lite/process_posix/src/UidGidTest.cpp b/kernel_lite/process_posix/src/UidGidTest.cpp index 00b916d16..ce8df47c6 100755 --- a/kernel_lite/process_posix/src/UidGidTest.cpp +++ b/kernel_lite/process_posix/src/UidGidTest.cpp @@ -640,15 +640,14 @@ HWTEST_F(UidGidTest, testGetgroups, Function | MediumTest | Level1) const int testSize = 10; gid_t gidList[testSize] = {0}; int n = getgroups(0, gidList); - ASSERT_EQ(n, 2); + ASSERT_EQ(n, 1); 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, 2); + ASSERT_EQ(n, 1); ASSERT_EQ(gidList[0], SHELL_GID); - ASSERT_EQ(gidList[1], 0); + } /** @@ -675,6 +674,7 @@ HWTEST_F(UidGidTest, testSetgroups1, Function | MediumTest | Level1) gidListIn[i] = GetRandID(); gidListOut[i] = 0; } + int rt = setgroups(groupSize, gidListIn); EXPECT_EQ(rt, 0); @@ -710,10 +710,9 @@ HWTEST_F(UidGidTest, testSetgroups2, Function | MediumTest | Level1) LOG("Init: make sure groups not changed by other test."); int n = getgroups(0, gidListOut); - EXPECT_EQ(n, 2); + EXPECT_EQ(n, 1); int rt = getgroups(n, gidListOut); EXPECT_EQ(gidListOut[0], SHELL_GID); - EXPECT_EQ(gidListOut[1], 0); EXPECT_EQ(rt, n); LOG("add 2 groups"); @@ -745,6 +744,7 @@ HWTEST_F(UidGidTest, testSetgroupsFail, Function | MediumTest | Level3) LOG("add 2 groups"); gid_t gidListIn[2] = {GetRandID(), GetRandID()}; gid_t gidListOut[4] = {0}; + int rt = setgroups(2, gidListIn); EXPECT_EQ(rt, 0); diff --git a/kernel_lite/process_posix/src/UidGidTest.h b/kernel_lite/process_posix/src/UidGidTest.h index bcfea1e55..8d1fcf489 100755 --- a/kernel_lite/process_posix/src/UidGidTest.h +++ b/kernel_lite/process_posix/src/UidGidTest.h @@ -67,11 +67,7 @@ protected: int rt = getgroups(groupNum, groupsArray); EXPECT_EQ(rt, groupNum); } - void SetUp() - { - LOG("SetUp: set gid"); - setgid(SHELL_GID); - } + void TearDown() { LOG("TearDown: reset uid and gid"); -- GitLab