1 #include <errno.h> 2 #include <gtest/gtest.h> 3 #include <syslog.h> 4 using namespace testing::ext; 5 6 class MiscCloselogTest : public testing::Test { SetUp()7 void SetUp() override {} TearDown()8 void TearDown() override {} 9 }; 10 11 /** 12 * @tc.name: closelog_001 13 * @tc.desc: Ensure that the closelog() function is correctly closing the logging system after the program has 14 * finished logging messages. 15 * @tc.type: FUNC 16 **/ 17 HWTEST_F(MiscCloselogTest, closelog_001, TestSize.Level1) 18 { 19 openlog("my_program", LOG_PID, LOG_USER); 20 syslog(LOG_INFO, "This is a test log message."); 21 errno = 0; 22 closelog(); 23 EXPECT_EQ(0, errno); 24 }