1 #include <fcntl.h> 2 #include <gtest/gtest.h> 3 #include <stdlib.h> 4 #include <sys/auxv.h> 5 #include <sys/uio.h> 6 #include <unistd.h> 7 8 using namespace testing::ext; 9 10 class UnistdGetidTest : public testing::Test { SetUp()11 void SetUp() override {} TearDown()12 void TearDown() override {} 13 }; 14 15 /** 16 * @tc.name: getuid_001 17 * @tc.desc: checks whether the getuid functions behave as expected and return the correct 18 * user and group IDs. 19 * @tc.type: FUNC 20 * */ 21 HWTEST_F(UnistdGetidTest, getuid_001, TestSize.Level1) 22 { 23 EXPECT_EQ(getuid(), getauxval(AT_UID)); 24 } 25 26 /** 27 * @tc.name: geteuid_001 28 * @tc.desc: checks whether the geteuid functions behave as expected and return the correct 29 * user and group IDs. 30 * @tc.type: FUNC 31 * */ 32 HWTEST_F(UnistdGetidTest, geteuid_001, TestSize.Level1) 33 { 34 EXPECT_EQ(geteuid(), getauxval(AT_EUID)); 35 } 36 37 /** 38 * @tc.name: getgid_001 39 * @tc.desc: checks whether getgid functions behave as expected and return the correct 40 * user and group IDs. 41 * @tc.type: FUNC 42 * */ 43 HWTEST_F(UnistdGetidTest, getgid_001, TestSize.Level1) 44 { 45 EXPECT_EQ(getgid(), getauxval(AT_GID)); 46 } 47 48 /** 49 * @tc.name: getegid_001 50 * @tc.desc: checks whether getegid functions behave as expected and return the correct 51 * user and group IDs. 52 * @tc.type: FUNC 53 * */ 54 HWTEST_F(UnistdGetidTest, getegid_001, TestSize.Level1) 55 { 56 EXPECT_EQ(getegid(), getauxval(AT_EGID)); 57 }