1 #include <fcntl.h> 2 #include <gtest/gtest.h> 3 #include <fortify/string.h> 4 #include <sys/stat.h> 5 6 constexpr int BUF_SIZE = 10; 7 constexpr int BUF_SIZE_TWO = 14; 8 constexpr int BUF_SIZE_THREE = 15; 9 10 using namespace testing::ext; 11 12 class FortifyOpenat64chkTest : public testing::Test { SetUp()13 void SetUp() override {} TearDown()14 void TearDown() override {} 15 }; 16 17 /** 18 * @tc.name: __strlcpy_chk_001 19 * @tc.desc: Verify if the __strlcpy_chk is functioning properly. 20 * @tc.type: FUNC 21 * */ 22 HWTEST_F(FortifyOpenat64chkTest, __strlcpy_chk_001, TestSize.Level1) 23 { 24 const char* srcChar = "012345678"; 25 char dstChar[BUF_SIZE]; 26 __strlcpy_chk(dstChar, srcChar, BUF_SIZE, sizeof(dstChar)); 27 EXPECT_STREQ("012345678", dstChar); 28 char dstChar2[BUF_SIZE_THREE]; 29 __strlcpy_chk(dstChar2, srcChar, BUF_SIZE_THREE, sizeof(dstChar2)); 30 EXPECT_STREQ("012345678", dstChar2); 31 EXPECT_EQ('\0', dstChar2[BUF_SIZE_TWO]); 32 srcChar = nullptr; 33 } 34