github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/test/syscalls/linux/readv_common.h (about)

     1  // Copyright 2018 The gVisor Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  #ifndef GVISOR_TEST_SYSCALLS_READV_COMMON_H_
    16  #define GVISOR_TEST_SYSCALLS_READV_COMMON_H_
    17  
    18  #include <stddef.h>
    19  
    20  namespace gvisor {
    21  namespace testing {
    22  
    23  // A NUL-terminated string containing the data used by tests using the following
    24  // test helpers.
    25  extern const char kReadvTestData[];
    26  
    27  // The size of kReadvTestData, including the terminating NUL.
    28  extern const size_t kReadvTestDataSize;
    29  
    30  // ReadAllOneBuffer asserts that it can read kReadvTestData from an fd using
    31  // exactly one iovec.
    32  void ReadAllOneBuffer(int fd);
    33  
    34  // ReadAllOneLargeBuffer asserts that it can read kReadvTestData from an fd
    35  // using exactly one iovec containing an overly large buffer.
    36  void ReadAllOneLargeBuffer(int fd);
    37  
    38  // ReadOneHalfAtATime asserts that it can read test_data_from an fd using
    39  // exactly two iovecs that are roughly equivalent in size.
    40  void ReadOneHalfAtATime(int fd);
    41  
    42  // ReadOneBufferPerByte asserts that it can read kReadvTestData from an fd
    43  // using one iovec per byte.
    44  void ReadOneBufferPerByte(int fd);
    45  
    46  // ReadBuffersOverlapping asserts that it can read kReadvTestData from an fd
    47  // where two iovecs are overlapping.
    48  void ReadBuffersOverlapping(int fd);
    49  
    50  // ReadBuffersDiscontinuous asserts that it can read kReadvTestData from an fd
    51  // where each iovec is discontinuous from the next by 1 byte.
    52  void ReadBuffersDiscontinuous(int fd);
    53  
    54  // ReadIovecsCompletelyFilled asserts that the previous iovec is completely
    55  // filled before moving onto the next.
    56  void ReadIovecsCompletelyFilled(int fd);
    57  
    58  }  // namespace testing
    59  }  // namespace gvisor
    60  
    61  #endif  // GVISOR_TEST_SYSCALLS_READV_COMMON_H_