• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 class UnistdWritevTest : public testing::Test {
SetUp()11     void SetUp() override {}
TearDown()12     void TearDown() override {}
13 };
14 
15 /**
16  * @tc.name: writev_001
17  * @tc.desc: Writes iovcnt buffers of data described by iov to the file associated with fd.
18  * @tc.type: FUNC
19  * */
20 HWTEST_F(UnistdWritevTest, writev_001, TestSize.Level1)
21 {
22     const char* str0 = "test ";
23     const char* str1 = "writev\n";
24     struct iovec iov[2];
25 
26     iov[0].iov_base = reinterpret_cast<void*>(const_cast<char*>(str0));
27     iov[0].iov_len = strlen(str0) + 1;
28     iov[1].iov_base = reinterpret_cast<void*>(const_cast<char*>(str1));
29     iov[1].iov_len = strlen(str1) + 1;
30 
31     EXPECT_EQ(iov[0].iov_len + iov[1].iov_len, writev(STDOUT_FILENO, iov, 2));
32 }