1 #include <fcntl.h> 2 #include <gtest/gtest.h> 3 #include <sys/stat.h> 4 #define _LARGEFILE64_SOURCE 5 #include <fortify/fcntl.h> 6 7 using namespace testing::ext; 8 9 class FortifyOpenatchkTest : public testing::Test { SetUp()10 void SetUp() override {} TearDown()11 void TearDown() override {} 12 }; 13 14 /** 15 * @tc.name: __openat_chk_001 16 * @tc.desc: Verify if the __openat_chk is functioning properly. 17 * @tc.type: FUNC 18 * */ 19 HWTEST_F(FortifyOpenatchkTest, __openat_chk_001, TestSize.Level1) 20 { 21 int result1 = __openat_chk(0, "/dev/null", O_WRONLY); 22 int result2 = __openat_chk(0, "/dev/null", O_RDONLY); 23 int result3 = __openat_chk(0, "openat_test", O_WRONLY); 24 int result4 = __openat_chk(0, "openat_test", O_RDONLY); 25 EXPECT_LE(0, result1); 26 EXPECT_LE(0, result2); 27 EXPECT_EQ(-1, result3); 28 EXPECT_EQ(-1, result4); 29 }