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 constexpr size_t N_BITES = 2; 11 12 class UnistdPread64Test : public testing::Test { SetUp()13 void SetUp() override {} TearDown()14 void TearDown() override {} 15 }; 16 17 /** 18 * @tc.name: pread64_001 19 * @tc.desc: checks whether the pread64 function behaves correctly when reading data from a file opened in read-only 20 * mode and when attempting to read data from a file opened in write-only mode. 21 * @tc.type: FUNC 22 * */ 23 HWTEST_F(UnistdPread64Test, pread64_001, TestSize.Level1) 24 { 25 char buf[1]; 26 int fd = open("/dev/null", O_RDONLY); 27 ASSERT_NE(-1, fd); 28 EXPECT_EQ(0, pread64(fd, buf, N_BITES, 0)); 29 close(fd); 30 fd = open("/dev/null", O_WRONLY); 31 ASSERT_NE(-1, fd); 32 EXPECT_EQ(-1, pread64(fd, buf, N_BITES, 0)); 33 close(fd); 34 }