• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <errno.h>
2 #include <gtest/gtest.h>
3 #include <utmp.h>
4 
5 using namespace testing::ext;
6 
7 class LegacyEndutentTest : public testing::Test {
SetUp()8     void SetUp() override {}
TearDown()9     void TearDown() override {}
10 };
11 
12 /**
13  * @tc.name: endutent_001
14  * @tc.desc: Ensure that the endutent() function is correctly closing the user accounting database after the iteration
15  *           is complete and that the ut_user field of each user entry is not empty
16  * @tc.type: FUNC
17  **/
18 HWTEST_F(LegacyEndutentTest, endutent_001, TestSize.Level1)
19 {
20     setutent();
21     struct utmp* user;
22     errno = 0;
23     while ((user = getutent()) != nullptr) {
24         EXPECT_NE(" ", user->ut_user);
25     }
26     endutent();
27     EXPECT_EQ(0, errno);
28 }