| 6 | // |
| 7 | // https://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 | #include <algorithm> |
| 16 | #include <string> |
| 17 | #include <utility> |
| 18 |
| 19 | #include <gtest/gtest.h> |
| 20 |
| 21 | #include <openssl/bio.h> |
| 22 | #include <openssl/crypto.h> |
| 23 | #include <openssl/err.h> |
| 24 | #include <openssl/mem.h> |
| 25 |
| 26 | #include "../internal.h" |
| 27 | #include "../test/file_util.h" |
| 28 | #include "../test/test_util.h" |
| 29 |
| 30 | #if !defined(OPENSSL_WINDOWS) |
| 31 | #include <arpa/inet.h> |
| 32 | #include <errno.h> |
| 33 | #include <fcntl.h> |
| 34 | #include <netinet/in.h> |
| 35 | #include <poll.h> |
| 36 | #include <string.h> |
| 37 | #include <sys/socket.h> |
| 38 | #include <unistd.h> |
| 39 | #else |
| 40 | #include <fcntl.h> |
| 41 | #include <io.h> |
| 42 | #include <winsock2.h> |
| 43 | #include <ws2tcpip.h> |
| 44 | #endif |
| 45 |
| 46 | namespace { |
| 47 |
| 48 | #if !defined(OPENSSL_WINDOWS) |
| 49 | using Socket = int; |
| 50 | #define INVALID_SOCKET (-1) |
| 51 | static int closesocket(int sock) { return close(sock); } |
| 52 | static std::string LastSocketError() { return strerror(errno); } |
| 53 | static const int kOpenReadOnlyBinary = O_RDONLY; |
| 54 | static const int kOpenReadOnlyText = O_RDONLY; |
| 55 | #else |
| 56 | using Socket = SOCKET; |
| 57 | static std::string LastSocketError() { |
| 58 | char buf[DECIMAL_SIZE(int) + 1]; |
| 59 | snprintf(buf, sizeof(buf), "%d", WSAGetLastError()); |
| 60 | return buf; |
| 61 | } |
| 62 | static const int kOpenReadOnlyBinary = _O_RDONLY | _O_BINARY; |
| 63 | static const int kOpenReadOnlyText = O_RDONLY | _O_TEXT; |
| 64 | #endif |
| 65 |
| 66 | class OwnedSocket { |
| 67 | public: |
| 68 | OwnedSocket() = default; |
| 69 | explicit OwnedSocket(Socket sock) : sock_(sock) {} |
| 70 | OwnedSocket(OwnedSocket &&other) { *this = std::move(other); } |
| 71 | ~OwnedSocket() { reset(); } |
| 72 | OwnedSocket &operator=(OwnedSocket &&other) { |
| 73 | reset(other.release()); |
| 74 | return *this; |
| 75 | } |
| 76 |
| 77 | bool is_valid() const { return sock_ != INVALID_SOCKET; } |
| 78 | Socket get() const { return sock_; } |
| 79 | Socket release() { return std::exchange(sock_, INVALID_SOCKET); } |
| 80 |
| 81 | void reset(Socket sock = INVALID_SOCKET) { |
| 82 | if (is_valid()) { |
| 83 | closesocket(sock_); |
| 84 | } |
| 85 |
| 86 | sock_ = sock; |
| 87 | } |
| 88 |
| 89 | private: |
| 90 | Socket sock_ = INVALID_SOCKET; |
| 91 | }; |
| 92 |
| 93 | struct SockaddrStorage { |
| 94 | int family() const { return storage.ss_family; } |
| 95 |
| 96 | sockaddr *addr_mut() { return reinterpret_cast<sockaddr *>(&storage); } |
| 97 | const sockaddr *addr() const { |
| 98 | return reinterpret_cast<const sockaddr *>(&storage); |
| 99 | } |
| 100 |
| 101 | sockaddr_in ToIPv4() const { |
| 102 | if (family() != AF_INET || len != sizeof(sockaddr_in)) { |
| 103 | abort(); |
| 104 | } |
| 105 | // These APIs were seemingly designed before C's strict aliasing rule, and |
| 106 | // C++'s strict union handling. Make a copy so the compiler does not read |
| 107 | // this as an aliasing violation. |
| 108 | sockaddr_in ret; |
| 109 | OPENSSL_memcpy(&ret, &storage, sizeof(ret)); |
| 110 | return ret; |
| 111 | } |
| 112 |
| 113 | sockaddr_in6 ToIPv6() const { |
| 114 | if (family() != AF_INET6 || len != sizeof(sockaddr_in6)) { |
| 115 | abort(); |
| 116 | } |
| 117 | // These APIs were seemingly designed before C's strict aliasing rule, and |
| 118 | // C++'s strict union handling. Make a copy so the compiler does not read |
| 119 | // this as an aliasing violation. |
| 120 | sockaddr_in6 ret; |
| 121 | OPENSSL_memcpy(&ret, &storage, sizeof(ret)); |
| 122 | return ret; |
| 123 | } |
| 124 |
| 125 | sockaddr_storage storage = {}; |
| 126 | socklen_t len = sizeof(storage); |
| 127 | }; |
| 128 |
| 129 | static OwnedSocket Bind(int family, const sockaddr *addr, socklen_t addr_len) { |
| 130 | OwnedSocket sock(socket(family, SOCK_STREAM, 0)); |
| 131 | if (!sock.is_valid()) { |
| 132 | return OwnedSocket(); |
| 133 | } |
| 134 |
| 135 | if (bind(sock.get(), addr, addr_len) != 0) { |
| 136 | return OwnedSocket(); |
| 137 | } |
| 138 |
| 139 | return sock; |
| 140 | } |
| 141 |
| 142 | static OwnedSocket ListenLoopback(int backlog) { |
| 143 | // Try binding to IPv6. |
| 144 | sockaddr_in6 sin6; |
| 145 | OPENSSL_memset(&sin6, 0, sizeof(sin6)); |
| 146 | sin6.sin6_family = AF_INET6; |
| 147 | if (inet_pton(AF_INET6, "::1", &sin6.sin6_addr) != 1) { |
| 148 | return OwnedSocket(); |
| 149 | } |
| 150 | OwnedSocket sock = |
| 151 | Bind(AF_INET6, reinterpret_cast<const sockaddr *>(&sin6), sizeof(sin6)); |
| 152 | if (!sock.is_valid()) { |
| 153 | // Try binding to IPv4. |
| 154 | sockaddr_in sin; |
| 155 | OPENSSL_memset(&sin, 0, sizeof(sin)); |
| 156 | sin.sin_family = AF_INET; |
| 157 | if (inet_pton(AF_INET, "127.0.0.1", &sin.sin_addr) != 1) { |
| 158 | return OwnedSocket(); |
| 159 | } |
| 160 | sock = Bind(AF_INET, reinterpret_cast<const sockaddr *>(&sin), sizeof(sin)); |
| 161 | } |
| 162 | if (!sock.is_valid()) { |
| 163 | return OwnedSocket(); |
| 164 | } |
| 165 |
| 166 | if (listen(sock.get(), backlog) != 0) { |
| 167 | return OwnedSocket(); |
| 168 | } |
| 169 |
| 170 | return sock; |
| 171 | } |
| 172 |
| 173 | static bool SocketSetNonBlocking(Socket sock) { |
| 174 | #if defined(OPENSSL_WINDOWS) |
| 175 | u_long arg = 1; |
| 176 | return ioctlsocket(sock, FIONBIO, &arg) == 0; |
| 177 | #else |
| 178 | int flags = fcntl(sock, F_GETFL, 0); |
| 179 | if (flags < 0) { |
| 180 | return false; |
| 181 | } |
| 182 | flags |= O_NONBLOCK; |
| 183 | return fcntl(sock, F_SETFL, flags) == 0; |
| 184 | #endif |
| 185 | } |
| 186 |
| 187 | enum class WaitType { kRead, kWrite }; |
| 188 |
| 189 | static bool WaitForSocket(Socket sock, WaitType wait_type) { |
| 190 | // Use an arbitrary 5 second timeout, so the test doesn't hang indefinitely if |
| 191 | // there's an issue. |
| 192 | static const int kTimeoutSeconds = 5; |
| 193 | #if defined(OPENSSL_WINDOWS) |
| 194 | fd_set read_set, write_set; |
| 195 | FD_ZERO(&read_set); |
| 196 | FD_ZERO(&write_set); |
| 197 | fd_set *wait_set = wait_type == WaitType::kRead ? &read_set : &write_set; |
| 198 | FD_SET(sock, wait_set); |
| 199 | timeval timeout; |
| 200 | timeout.tv_sec = kTimeoutSeconds; |
| 201 | timeout.tv_usec = 0; |
| 202 | if (select(0 /* unused on Windows */, &read_set, &write_set, nullptr, |
| 203 | &timeout) <= 0) { |
| 204 | return false; |
| 205 | } |
| 206 | return FD_ISSET(sock, wait_set); |
| 207 | #else |
| 208 | short events = wait_type == WaitType::kRead ? POLLIN : POLLOUT; |
| 209 | pollfd fd = {/*fd=*/sock, events, /*revents=*/0}; |
| 210 | return poll(&fd, 1, kTimeoutSeconds * 1000) == 1 && (fd.revents & events); |
| 211 | #endif |
| 212 | } |
| 213 |
| 214 | TEST(BIOTest, SocketConnect) { |
| 215 | static const char kTestMessage[] = "test"; |
| 216 | OwnedSocket listening_sock = ListenLoopback(/*backlog=*/1); |
| 217 | ASSERT_TRUE(listening_sock.is_valid()) << LastSocketError(); |
| 218 |
| 219 | SockaddrStorage addr; |
| 220 | ASSERT_EQ(getsockname(listening_sock.get(), addr.addr_mut(), &addr.len), 0) |
| 221 | << LastSocketError(); |
| 222 |
| 223 | char hostname[80]; |
| 224 | if (addr.family() == AF_INET6) { |
| 225 | snprintf(hostname, sizeof(hostname), "[::1]:%d", |
| 226 | ntohs(addr.ToIPv6().sin6_port)); |
| 227 | } else { |
| 228 | snprintf(hostname, sizeof(hostname), "127.0.0.1:%d", |
| 229 | ntohs(addr.ToIPv4().sin_port)); |
| 230 | } |
| 231 |
| 232 | // Connect to it with a connect BIO. |
| 233 | bssl::UniquePtr<BIO> bio(BIO_new_connect(hostname)); |
| 234 | ASSERT_TRUE(bio); |
| 235 |
| 236 | // Write a test message to the BIO. This is assumed to be smaller than the |
| 237 | // transport buffer. |
| 238 | ASSERT_EQ(static_cast<int>(sizeof(kTestMessage)), |
| 239 | BIO_write(bio.get(), kTestMessage, sizeof(kTestMessage))) |
| 240 | << LastSocketError(); |
| 241 |
| 242 | // Accept the socket. |
| 243 | OwnedSocket sock(accept(listening_sock.get(), addr.addr_mut(), &addr.len)); |
| 244 | ASSERT_TRUE(sock.is_valid()) << LastSocketError(); |
| 245 |
| 246 | // Check the same message is read back out. |
| 247 | char buf[sizeof(kTestMessage)]; |
| 248 | ASSERT_EQ(static_cast<int>(sizeof(kTestMessage)), |
| 249 | recv(sock.get(), buf, sizeof(buf), 0)) |
| 250 | << LastSocketError(); |
| 251 | EXPECT_EQ(Bytes(kTestMessage, sizeof(kTestMessage)), Bytes(buf, sizeof(buf))); |
| 252 | } |
| 253 |
| 254 | TEST(BIOTest, SocketNonBlocking) { |
| 255 | OwnedSocket listening_sock = ListenLoopback(/*backlog=*/1); |
| 256 | ASSERT_TRUE(listening_sock.is_valid()) << LastSocketError(); |
| 257 |
| 258 | // Connect to |listening_sock|. |
| 259 | SockaddrStorage addr; |
| 260 | ASSERT_EQ(getsockname(listening_sock.get(), addr.addr_mut(), &addr.len), 0) |
| 261 | << LastSocketError(); |
| 262 | OwnedSocket connect_sock(socket(addr.family(), SOCK_STREAM, 0)); |
| 263 | ASSERT_TRUE(connect_sock.is_valid()) << LastSocketError(); |
| 264 | ASSERT_EQ(connect(connect_sock.get(), addr.addr(), addr.len), 0) |
| 265 | << LastSocketError(); |
| 266 | ASSERT_TRUE(SocketSetNonBlocking(connect_sock.get())) << LastSocketError(); |
| 267 | bssl::UniquePtr<BIO> connect_bio( |
| 268 | BIO_new_socket(connect_sock.get(), BIO_NOCLOSE)); |
| 269 | ASSERT_TRUE(connect_bio); |
| 270 |
| 271 | // Make a corresponding accepting socket. |
| 272 | OwnedSocket accept_sock( |
| 273 | accept(listening_sock.get(), addr.addr_mut(), &addr.len)); |
| 274 | ASSERT_TRUE(accept_sock.is_valid()) << LastSocketError(); |
| 275 | ASSERT_TRUE(SocketSetNonBlocking(accept_sock.get())) << LastSocketError(); |
| 276 | bssl::UniquePtr<BIO> accept_bio( |
| 277 | BIO_new_socket(accept_sock.get(), BIO_NOCLOSE)); |
| 278 | ASSERT_TRUE(accept_bio); |
| 279 |
| 280 | // Exchange data through the socket. |
| 281 | static const char kTestMessage[] = "hello, world"; |
| 282 |
| 283 | // Reading from |accept_bio| should not block. |
| 284 | char buf[sizeof(kTestMessage)]; |
| 285 | int ret = BIO_read(accept_bio.get(), buf, sizeof(buf)); |
| 286 | EXPECT_EQ(ret, -1); |
| 287 | EXPECT_TRUE(BIO_should_read(accept_bio.get())) << LastSocketError(); |
| 288 |
| 289 | // Writing to |connect_bio| should eventually overflow the transport buffers |
| 290 | // and also give a retryable error. |
| 291 | int bytes_written = 0; |
| 292 | for (;;) { |
| 293 | ret = BIO_write(connect_bio.get(), kTestMessage, sizeof(kTestMessage)); |
| 294 | if (ret <= 0) { |
| 295 | EXPECT_EQ(ret, -1); |
| 296 | EXPECT_TRUE(BIO_should_write(connect_bio.get())) << LastSocketError(); |
| 297 | break; |
| 298 | } |
| 299 | bytes_written += ret; |
| 300 | } |
| 301 | EXPECT_GT(bytes_written, 0); |
| 302 |
| 303 | // |accept_bio| should readable. Drain it. Note data is not always available |
| 304 | // from loopback immediately, notably on macOS, so wait for the socket first. |
| 305 | int bytes_read = 0; |
| 306 | while (bytes_read < bytes_written) { |
| 307 | ASSERT_TRUE(WaitForSocket(accept_sock.get(), WaitType::kRead)) |
| 308 | << LastSocketError(); |
| 309 | ret = BIO_read(accept_bio.get(), buf, sizeof(buf)); |
| 310 | ASSERT_GT(ret, 0); |
| 311 | bytes_read += ret; |
| 312 | } |
| 313 |
| 314 | // |connect_bio| should become writeable again. |
| 315 | ASSERT_TRUE(WaitForSocket(accept_sock.get(), WaitType::kWrite)) |
| 316 | << LastSocketError(); |
| 317 | ret = BIO_write(connect_bio.get(), kTestMessage, sizeof(kTestMessage)); |
| 318 | EXPECT_EQ(static_cast<int>(sizeof(kTestMessage)), ret); |
| 319 |
| 320 | ASSERT_TRUE(WaitForSocket(accept_sock.get(), WaitType::kRead)) |
| 321 | << LastSocketError(); |
| 322 | ret = BIO_read(accept_bio.get(), buf, sizeof(buf)); |
| 323 | EXPECT_EQ(static_cast<int>(sizeof(kTestMessage)), ret); |
| 324 | EXPECT_EQ(Bytes(buf), Bytes(kTestMessage)); |
| 325 |
| 326 | // Close one socket. We should get an EOF out the other. |
| 327 | connect_bio.reset(); |
| 328 | connect_sock.reset(); |
| 329 |
| 330 | ASSERT_TRUE(WaitForSocket(accept_sock.get(), WaitType::kRead)) |
| 331 | << LastSocketError(); |
| 332 | ret = BIO_read(accept_bio.get(), buf, sizeof(buf)); |
| 333 | EXPECT_EQ(ret, 0) << LastSocketError(); |
| 334 | EXPECT_FALSE(BIO_should_read(accept_bio.get())); |
| 335 | } |
| 336 |
| 337 | TEST(BIOTest, Printf) { |
| 338 | // Test a short output, a very long one, and various sizes around |
| 339 | // 256 (the size of the buffer) to ensure edge cases are correct. |
| 340 | static const size_t kLengths[] = {5, 250, 251, 252, 253, 254, 1023}; |
| 341 |
| 342 | bssl::UniquePtr<BIO> bio(BIO_new(BIO_s_mem())); |
| 343 | ASSERT_TRUE(bio); |
| 344 |
| 345 | for (size_t length : kLengths) { |
| 346 | SCOPED_TRACE(length); |
| 347 |
| 348 | std::string in(length, 'a'); |
| 349 |
| 350 | int ret = BIO_printf(bio.get(), "test %s", in.c_str()); |
| 351 | ASSERT_GE(ret, 0); |
| 352 | EXPECT_EQ(5 + length, static_cast<size_t>(ret)); |
| 353 |
| 354 | const uint8_t *contents; |
| 355 | size_t len; |
| 356 | ASSERT_TRUE(BIO_mem_contents(bio.get(), &contents, &len)); |
| 357 | EXPECT_EQ("test " + in, bssl::BytesAsStringView(bssl::Span(contents, len))); |
| 358 |
| 359 | ASSERT_TRUE(BIO_reset(bio.get())); |
| 360 | } |
| 361 | } |
| 362 |
| 363 | TEST(BIOTest, ReadASN1) { |
| 364 | static const size_t kLargeASN1PayloadLen = 8000; |
| 365 |
| 366 | struct ASN1Test { |
| 367 | bool should_succeed; |
| 368 | std::vector<uint8_t> input; |
| 369 | // suffix_len is the number of zeros to append to |input|. |
| 370 | size_t suffix_len; |
| 371 | // expected_len, if |should_succeed| is true, is the expected length of the |
| 372 | // ASN.1 element. |
| 373 | size_t expected_len; |
| 374 | size_t max_len; |
| 375 | } kASN1Tests[] = { |
| 376 | {true, {0x30, 2, 1, 2, 0, 0}, 0, 4, 100}, |
| 377 | {false /* truncated */, {0x30, 3, 1, 2}, 0, 0, 100}, |
| 378 | {false /* should be short len */, {0x30, 0x81, 1, 1}, 0, 0, 100}, |
| 379 | {false /* zero padded */, {0x30, 0x82, 0, 1, 1}, 0, 0, 100}, |
| 380 |
| 381 | // Test a large payload. |
| 382 | {true, |
| 383 | {0x30, 0x82, kLargeASN1PayloadLen >> 8, kLargeASN1PayloadLen & 0xff}, |
| 384 | kLargeASN1PayloadLen, |
| 385 | 4 + kLargeASN1PayloadLen, |
| 386 | kLargeASN1PayloadLen * 2}, |
| 387 | {false /* max_len too short */, |
| 388 | {0x30, 0x82, kLargeASN1PayloadLen >> 8, kLargeASN1PayloadLen & 0xff}, |
| 389 | kLargeASN1PayloadLen, |
| 390 | 4 + kLargeASN1PayloadLen, |
| 391 | 3 + kLargeASN1PayloadLen}, |
| 392 |
| 393 | // Test an indefinite-length input. |
| 394 | {true, |
| 395 | {0x30, 0x80}, |
| 396 | kLargeASN1PayloadLen + 2, |
| 397 | 2 + kLargeASN1PayloadLen + 2, |
| 398 | kLargeASN1PayloadLen * 2}, |
| 399 | {false /* max_len too short */, |
| 400 | {0x30, 0x80}, |
| 401 | kLargeASN1PayloadLen + 2, |
| 402 | 2 + kLargeASN1PayloadLen + 2, |
| 403 | 2 + kLargeASN1PayloadLen + 1}, |
| 404 | }; |
| 405 |
| 406 | for (const auto &t : kASN1Tests) { |
| 407 | std::vector<uint8_t> input = t.input; |
| 408 | input.resize(input.size() + t.suffix_len, 0); |
| 409 |
| 410 | bssl::UniquePtr<BIO> bio(BIO_new_mem_buf(input.data(), input.size())); |
| 411 | ASSERT_TRUE(bio); |
| 412 |
| 413 | uint8_t *out; |
| 414 | size_t out_len; |
| 415 | int ok = BIO_read_asn1(bio.get(), &out, &out_len, t.max_len); |
| 416 | if (!ok) { |
| 417 | out = nullptr; |
| 418 | } |
| 419 | bssl::UniquePtr<uint8_t> out_storage(out); |
| 420 |
| 421 | ASSERT_EQ(t.should_succeed, (ok == 1)); |
| 422 | if (t.should_succeed) { |
| 423 | EXPECT_EQ(Bytes(input.data(), t.expected_len), Bytes(out, out_len)); |
| 424 | } |
| 425 | } |
| 426 | } |
| 427 |
| 428 | TEST(BIOTest, MemReadOnly) { |
| 429 | // A memory BIO created from |BIO_new_mem_buf| is a read-only buffer. |
| 430 | static const char kData[] = "abcdefghijklmno"; |
| 431 | bssl::UniquePtr<BIO> bio(BIO_new_mem_buf(kData, strlen(kData))); |
| 432 | ASSERT_TRUE(bio); |
| 433 |
| 434 | // Writing to read-only buffers should fail. |
| 435 | EXPECT_EQ(BIO_write(bio.get(), kData, strlen(kData)), -1); |
| 436 |
| 437 | const uint8_t *contents; |
| 438 | size_t len; |
| 439 | ASSERT_TRUE(BIO_mem_contents(bio.get(), &contents, &len)); |
| 440 | EXPECT_EQ(Bytes(contents, len), Bytes(kData)); |
| 441 | EXPECT_EQ(BIO_eof(bio.get()), 0); |
| 442 |
| 443 | // Read less than the whole buffer. |
| 444 | char buf[6]; |
| 445 | int ret = BIO_read(bio.get(), buf, sizeof(buf)); |
| 446 | ASSERT_GT(ret, 0); |
| 447 | EXPECT_EQ(Bytes(buf, ret), Bytes("abcdef")); |
| 448 |
| 449 | ASSERT_TRUE(BIO_mem_contents(bio.get(), &contents, &len)); |
| 450 | EXPECT_EQ(Bytes(contents, len), Bytes("ghijklmno")); |
| 451 | EXPECT_EQ(BIO_eof(bio.get()), 0); |
| 452 |
| 453 | ret = BIO_read(bio.get(), buf, sizeof(buf)); |
| 454 | ASSERT_GT(ret, 0); |
| 455 | EXPECT_EQ(Bytes(buf, ret), Bytes("ghijkl")); |
| 456 |
| 457 | ASSERT_TRUE(BIO_mem_contents(bio.get(), &contents, &len)); |
| 458 | EXPECT_EQ(Bytes(contents, len), Bytes("mno")); |
| 459 | EXPECT_EQ(BIO_eof(bio.get()), 0); |
| 460 |
| 461 | // Read the remainder of the buffer. |
| 462 | ret = BIO_read(bio.get(), buf, sizeof(buf)); |
| 463 | ASSERT_GT(ret, 0); |
| 464 | EXPECT_EQ(Bytes(buf, ret), Bytes("mno")); |
| 465 |
| 466 | ASSERT_TRUE(BIO_mem_contents(bio.get(), &contents, &len)); |
| 467 | EXPECT_EQ(Bytes(contents, len), Bytes("")); |
| 468 | EXPECT_EQ(BIO_eof(bio.get()), 1); |
| 469 |
| 470 | // By default, reading from a consumed read-only buffer returns EOF. |
| 471 | EXPECT_EQ(BIO_read(bio.get(), buf, sizeof(buf)), 0); |
| 472 | EXPECT_FALSE(BIO_should_read(bio.get())); |
| 473 |
| 474 | // A memory BIO can be configured to return an error instead of EOF. This is |
| 475 | // error is returned as retryable. (This is not especially useful here. It |
| 476 | // makes more sense for a writable BIO.) |
| 477 | EXPECT_EQ(BIO_set_mem_eof_return(bio.get(), -1), 1); |
| 478 | EXPECT_EQ(BIO_read(bio.get(), buf, sizeof(buf)), -1); |
| 479 | EXPECT_TRUE(BIO_should_read(bio.get())); |
| 480 |
| 481 | // Read exactly the right number of bytes, to test the boundary condition is |
| 482 | // correct. |
| 483 | bio.reset(BIO_new_mem_buf("abc", 3)); |
| 484 | ASSERT_TRUE(bio); |
| 485 | ret = BIO_read(bio.get(), buf, 3); |
| 486 | ASSERT_GT(ret, 0); |
| 487 | EXPECT_EQ(Bytes(buf, ret), Bytes("abc")); |
| 488 | EXPECT_EQ(BIO_eof(bio.get()), 1); |
| 489 | } |
| 490 |
| 491 | TEST(BIOTest, MemWritable) { |
| 492 | // A memory BIO created from |BIO_new| is writable. |
| 493 | bssl::UniquePtr<BIO> bio(BIO_new(BIO_s_mem())); |
| 494 | ASSERT_TRUE(bio); |
| 495 |
| 496 | auto check_bio_contents = [&](Bytes b) { |
| 497 | const uint8_t *contents; |
| 498 | size_t len; |
| 499 | ASSERT_TRUE(BIO_mem_contents(bio.get(), &contents, &len)); |
| 500 | EXPECT_EQ(Bytes(contents, len), b); |
| 501 |
| 502 | char *contents_c; |
| 503 | long len_l = BIO_get_mem_data(bio.get(), &contents_c); |
| 504 | ASSERT_GE(len_l, 0); |
| 505 | EXPECT_EQ(Bytes(contents_c, len_l), b); |
| 506 |
| 507 | BUF_MEM *buf; |
| 508 | ASSERT_EQ(BIO_get_mem_ptr(bio.get(), &buf), 1); |
| 509 | EXPECT_EQ(Bytes(buf->data, buf->length), b); |
| 510 | }; |
| 511 |
| 512 | // It is initially empty. |
| 513 | check_bio_contents(Bytes("")); |
| 514 | EXPECT_EQ(BIO_eof(bio.get()), 1); |
| 515 |
| 516 | // Reading from it should default to returning a retryable error. |
| 517 | char buf[32]; |
| 518 | EXPECT_EQ(BIO_read(bio.get(), buf, sizeof(buf)), -1); |
| 519 | EXPECT_TRUE(BIO_should_read(bio.get())); |
| 520 |
| 521 | // This can be configured to return an EOF. |
| 522 | EXPECT_EQ(BIO_set_mem_eof_return(bio.get(), 0), 1); |
| 523 | EXPECT_EQ(BIO_read(bio.get(), buf, sizeof(buf)), 0); |
| 524 | EXPECT_FALSE(BIO_should_read(bio.get())); |
| 525 |
| 526 | // Restore the default. A writable memory |BIO| is typically used in this mode |
| 527 | // so additional data can be written when exhausted. |
| 528 | EXPECT_EQ(BIO_set_mem_eof_return(bio.get(), -1), 1); |
| 529 |
| 530 | // Writes append to the buffer. |
| 531 | ASSERT_EQ(BIO_write(bio.get(), "abcdef", 6), 6); |
| 532 | check_bio_contents(Bytes("abcdef")); |
| 533 | EXPECT_EQ(BIO_eof(bio.get()), 0); |
| 534 |
| 535 | // Writes can include embedded NULs. |
| 536 | ASSERT_EQ(BIO_write(bio.get(), "\0ghijk", 6), 6); |
| 537 | check_bio_contents(Bytes("abcdef\0ghijk", 12)); |
| 538 | EXPECT_EQ(BIO_eof(bio.get()), 0); |
| 539 |
| 540 | // Do a partial read. |
| 541 | int ret = BIO_read(bio.get(), buf, 4); |
| 542 | ASSERT_GT(ret, 0); |
| 543 | EXPECT_EQ(Bytes(buf, ret), Bytes("abcd")); |
| 544 | check_bio_contents(Bytes("ef\0ghijk", 8)); |
| 545 | EXPECT_EQ(BIO_eof(bio.get()), 0); |
| 546 |
| 547 | // Reads and writes may alternate. |
| 548 | ASSERT_EQ(BIO_write(bio.get(), "lmnopq", 6), 6); |
| 549 | check_bio_contents(Bytes("ef\0ghijklmnopq", 14)); |
| 550 | EXPECT_EQ(BIO_eof(bio.get()), 0); |
| 551 |
| 552 | // Reads may consume embedded NULs. |
| 553 | ret = BIO_read(bio.get(), buf, 4); |
| 554 | ASSERT_GT(ret, 0); |
| 555 | EXPECT_EQ(Bytes(buf, ret), Bytes("ef\0g", 4)); |
| 556 | check_bio_contents(Bytes("hijklmnopq")); |
| 557 | EXPECT_EQ(BIO_eof(bio.get()), 0); |
| 558 |
| 559 | // The read buffer exceeds the |BIO|, so we consume everything. |
| 560 | ret = BIO_read(bio.get(), buf, sizeof(buf)); |
| 561 | ASSERT_GT(ret, 0); |
| 562 | EXPECT_EQ(Bytes(buf, ret), Bytes("hijklmnopq")); |
| 563 | check_bio_contents(Bytes("")); |
| 564 | EXPECT_EQ(BIO_eof(bio.get()), 1); |
| 565 |
| 566 | // The |BIO| is now empty. |
| 567 | EXPECT_EQ(BIO_read(bio.get(), buf, sizeof(buf)), -1); |
| 568 | EXPECT_TRUE(BIO_should_read(bio.get())); |
| 569 |
| 570 | // Repeat the above, reading exactly the right number of bytes, to test the |
| 571 | // boundary condition is correct. |
| 572 | ASSERT_EQ(BIO_write(bio.get(), "abc", 3), 3); |
| 573 | ret = BIO_read(bio.get(), buf, 3); |
| 574 | EXPECT_EQ(Bytes(buf, ret), Bytes("abc")); |
| 575 | EXPECT_EQ(BIO_read(bio.get(), buf, sizeof(buf)), -1); |
| 576 | EXPECT_TRUE(BIO_should_read(bio.get())); |
| 577 | EXPECT_EQ(BIO_eof(bio.get()), 1); |
| 578 | } |
| 579 |
| 580 | TEST(BIOTest, Gets) { |
| 581 | const struct { |
| 582 | std::string bio; |
| 583 | int gets_len; |
| 584 | std::string gets_result; |
| 585 | } kGetsTests[] = { |
| 586 | // BIO_gets should stop at the first newline. If the buffer is too small, |
| 587 | // stop there instead. Note the buffer size |
| 588 | // includes a trailing NUL. |
| 589 | {"123456789\n123456789", 5, "1234"}, |
| 590 | {"123456789\n123456789", 9, "12345678"}, |
| 591 | {"123456789\n123456789", 10, "123456789"}, |
| 592 | {"123456789\n123456789", 11, "123456789\n"}, |
| 593 | {"123456789\n123456789", 12, "123456789\n"}, |
| 594 | {"123456789\n123456789", 256, "123456789\n"}, |
| 595 |
| 596 | // If we run out of buffer, read the whole buffer. |
| 597 | {"12345", 5, "1234"}, |
| 598 | {"12345", 6, "12345"}, |
| 599 | {"12345", 10, "12345"}, |
| 600 |
| 601 | // NUL bytes do not terminate gets. |
| 602 | {std::string("abc\0def\nghi", 11), 256, std::string("abc\0def\n", 8)}, |
| 603 |
| 604 | // An output size of one means we cannot read any bytes. Only the trailing |
| 605 | // NUL is included. |
| 606 | {"12345", 1, ""}, |
| 607 |
| 608 | // Empty line. |
| 609 | {"\nabcdef", 256, "\n"}, |
| 610 | // Empty BIO. |
| 611 | {"", 256, ""}, |
| 612 | }; |
| 613 | for (const auto &t : kGetsTests) { |
| 614 | SCOPED_TRACE(t.bio); |
| 615 | SCOPED_TRACE(t.gets_len); |
| 616 |
| 617 | auto check_bio_gets = [&](BIO *bio) { |
| 618 | std::vector<char> buf(t.gets_len, 'a'); |
| 619 | int ret = BIO_gets(bio, buf.data(), t.gets_len); |
| 620 | ASSERT_GE(ret, 0); |
| 621 | // |BIO_gets| should write a NUL terminator, not counted in the return |
| 622 | // value. |
| 623 | EXPECT_EQ(Bytes(buf.data(), ret + 1), |
| 624 | Bytes(t.gets_result.data(), t.gets_result.size() + 1)); |
| 625 |
| 626 | // The remaining data should still be in the BIO. |
| 627 | buf.resize(t.bio.size() + 1); |
| 628 | ret = BIO_read(bio, buf.data(), static_cast<int>(buf.size())); |
| 629 | ASSERT_GE(ret, 0); |
| 630 | EXPECT_EQ(Bytes(buf.data(), ret), |
| 631 | Bytes(t.bio.substr(t.gets_result.size()))); |
| 632 | }; |
| 633 |
| 634 | { |
| 635 | SCOPED_TRACE("memory"); |
| 636 | bssl::UniquePtr<BIO> bio(BIO_new_mem_buf(t.bio.data(), t.bio.size())); |
| 637 | ASSERT_TRUE(bio); |
| 638 | check_bio_gets(bio.get()); |
| 639 | } |
| 640 |
| 641 | if (!bssl::SkipTempFileTests()) { |
| 642 | bssl::TemporaryFile file; |
| 643 | ASSERT_TRUE(file.Init(t.bio)); |
| 644 |
| 645 | // TODO(crbug.com/boringssl/585): If the line has an embedded NUL, file |
| 646 | // BIOs do not currently report the answer correctly. |
| 647 | if (t.bio.find('\0') == std::string::npos) { |
| 648 | SCOPED_TRACE("file"); |
| 649 |
| 650 | // Test |BIO_new_file|. |
| 651 | bssl::UniquePtr<BIO> bio(BIO_new_file(file.path().c_str(), "rb")); |
| 652 | ASSERT_TRUE(bio); |
| 653 | check_bio_gets(bio.get()); |
| 654 |
| 655 | // Test |BIO_read_filename|. |
| 656 | bio.reset(BIO_new(BIO_s_file())); |
| 657 | ASSERT_TRUE(bio); |
| 658 | ASSERT_TRUE(BIO_read_filename(bio.get(), file.path().c_str())); |
| 659 | check_bio_gets(bio.get()); |
| 660 |
| 661 | // Test |BIO_NOCLOSE|. |
| 662 | bssl::ScopedFILE file_obj = file.Open("rb"); |
| 663 | ASSERT_TRUE(file_obj); |
| 664 | bio.reset(BIO_new_fp(file_obj.get(), BIO_NOCLOSE)); |
| 665 | ASSERT_TRUE(bio); |
| 666 | check_bio_gets(bio.get()); |
| 667 |
| 668 | // Test |BIO_CLOSE|. |
| 669 | file_obj = file.Open("rb"); |
| 670 | ASSERT_TRUE(file_obj); |
| 671 | bio.reset(BIO_new_fp(file_obj.get(), BIO_CLOSE)); |
| 672 | ASSERT_TRUE(bio); |
| 673 | file_obj.release(); // |BIO_new_fp| took ownership on success. |
| 674 | check_bio_gets(bio.get()); |
| 675 | } |
| 676 |
| 677 | { |
| 678 | SCOPED_TRACE("fd"); |
| 679 |
| 680 | // Test |BIO_NOCLOSE|. |
| 681 | bssl::ScopedFD fd = file.OpenFD(kOpenReadOnlyBinary); |
| 682 | ASSERT_TRUE(fd.is_valid()); |
| 683 | bssl::UniquePtr<BIO> bio(BIO_new_fd(fd.get(), BIO_NOCLOSE)); |
| 684 | ASSERT_TRUE(bio); |
| 685 | check_bio_gets(bio.get()); |
| 686 |
| 687 | // Test |BIO_CLOSE|. |
| 688 | fd = file.OpenFD(kOpenReadOnlyBinary); |
| 689 | ASSERT_TRUE(fd.is_valid()); |
| 690 | bio.reset(BIO_new_fd(fd.get(), BIO_CLOSE)); |
| 691 | ASSERT_TRUE(bio); |
| 692 | fd.release(); // |BIO_new_fd| took ownership on success. |
| 693 | check_bio_gets(bio.get()); |
| 694 | } |
| 695 | } |
| 696 | } |
| 697 |
| 698 | // Negative and zero lengths should not output anything, even a trailing NUL. |
| 699 | bssl::UniquePtr<BIO> bio(BIO_new_mem_buf("12345", -1)); |
| 700 | ASSERT_TRUE(bio); |
| 701 | char c = 'a'; |
| 702 | EXPECT_EQ(0, BIO_gets(bio.get(), &c, -1)); |
| 703 | EXPECT_EQ(0, BIO_gets(bio.get(), &c, 0)); |
| 704 | EXPECT_EQ(c, 'a'); |
| 705 | } |
| 706 |
| 707 | // Test that, on Windows, file BIOs correctly handle text vs binary mode. |
| 708 | TEST(BIOTest, FileMode) { |
| 709 | if (bssl::SkipTempFileTests()) { |
| 710 | GTEST_SKIP(); |
| 711 | } |
| 712 |
| 713 | bssl::TemporaryFile temp; |
| 714 | ASSERT_TRUE(temp.Init("hello\r\nworld")); |
| 715 |
| 716 | auto expect_file_contents = [](BIO *bio, const std::string &str) { |
| 717 | // Read more than expected, to make sure we've reached the end of the file. |
| 718 | std::vector<char> buf(str.size() + 100); |
| 719 | int len = BIO_read(bio, buf.data(), static_cast<int>(buf.size())); |
| 720 | ASSERT_GT(len, 0); |
| 721 | EXPECT_EQ(Bytes(buf.data(), len), Bytes(str)); |
| 722 | }; |
| 723 | auto expect_binary_mode = [&](BIO *bio) { |
| 724 | expect_file_contents(bio, "hello\r\nworld"); |
| 725 | }; |
| 726 | auto expect_text_mode = [&](BIO *bio) { |
| 727 | #if defined(OPENSSL_WINDOWS) |
| 728 | expect_file_contents(bio, "hello\nworld"); |
| 729 | #else |
| 730 | expect_file_contents(bio, "hello\r\nworld"); |
| 731 | #endif |
| 732 | }; |
| 733 |
| 734 | // |BIO_read_filename| should open in binary mode. |
| 735 | bssl::UniquePtr<BIO> bio(BIO_new(BIO_s_file())); |
| 736 | ASSERT_TRUE(bio); |
| 737 | ASSERT_TRUE(BIO_read_filename(bio.get(), temp.path().c_str())); |
| 738 | expect_binary_mode(bio.get()); |
| 739 |
| 740 | // |BIO_new_file| should use the specified mode. |
| 741 | bio.reset(BIO_new_file(temp.path().c_str(), "rb")); |
| 742 | ASSERT_TRUE(bio); |
| 743 | expect_binary_mode(bio.get()); |
| 744 |
| 745 | bio.reset(BIO_new_file(temp.path().c_str(), "r")); |
| 746 | ASSERT_TRUE(bio); |
| 747 | expect_text_mode(bio.get()); |
| 748 |
| 749 | // |BIO_new_fp| inherits the file's existing mode by default. |
| 750 | bssl::ScopedFILE file = temp.Open("rb"); |
| 751 | ASSERT_TRUE(file); |
| 752 | bio.reset(BIO_new_fp(file.get(), BIO_NOCLOSE)); |
| 753 | ASSERT_TRUE(bio); |
| 754 | expect_binary_mode(bio.get()); |
| 755 |
| 756 | file = temp.Open("r"); |
| 757 | ASSERT_TRUE(file); |
| 758 | bio.reset(BIO_new_fp(file.get(), BIO_NOCLOSE)); |
| 759 | ASSERT_TRUE(bio); |
| 760 | expect_text_mode(bio.get()); |
| 761 |
| 762 | // However, |BIO_FP_TEXT| changes the file to be text mode, no matter how it |
| 763 | // was opened. |
| 764 | file = temp.Open("rb"); |
| 765 | ASSERT_TRUE(file); |
| 766 | bio.reset(BIO_new_fp(file.get(), BIO_NOCLOSE | BIO_FP_TEXT)); |
| 767 | ASSERT_TRUE(bio); |
| 768 | expect_text_mode(bio.get()); |
| 769 |
| 770 | file = temp.Open("r"); |
| 771 | ASSERT_TRUE(file); |
| 772 | bio.reset(BIO_new_fp(file.get(), BIO_NOCLOSE | BIO_FP_TEXT)); |
| 773 | ASSERT_TRUE(bio); |
| 774 | expect_text_mode(bio.get()); |
| 775 |
| 776 | // |BIO_new_fd| inherits the FD's existing mode. |
| 777 | bssl::ScopedFD fd = temp.OpenFD(kOpenReadOnlyBinary); |
| 778 | ASSERT_TRUE(fd.is_valid()); |
| 779 | bio.reset(BIO_new_fd(fd.get(), BIO_NOCLOSE)); |
| 780 | ASSERT_TRUE(bio); |
| 781 | expect_binary_mode(bio.get()); |
| 782 |
| 783 | fd = temp.OpenFD(kOpenReadOnlyText); |
| 784 | ASSERT_TRUE(fd.is_valid()); |
| 785 | bio.reset(BIO_new_fd(fd.get(), BIO_NOCLOSE)); |
| 786 | ASSERT_TRUE(bio); |
| 787 | expect_text_mode(bio.get()); |
| 788 | } |
| 789 |
| 790 | // Run through the tests twice, swapping |bio1| and |bio2|, for symmetry. |
| 791 | class BIOPairTest : public testing::TestWithParam<bool> {}; |
| 792 |
| 793 | TEST_P(BIOPairTest, TestPair) { |
| 794 | BIO *bio1, *bio2; |
| 795 | ASSERT_TRUE(BIO_new_bio_pair(&bio1, 10, &bio2, 10)); |
| 796 | bssl::UniquePtr<BIO> free_bio1(bio1), free_bio2(bio2); |
| 797 |
| 798 | if (GetParam()) { |
| 799 | std::swap(bio1, bio2); |
| 800 | } |
| 801 |
| 802 | // Check initial states. |
| 803 | EXPECT_EQ(10u, BIO_ctrl_get_write_guarantee(bio1)); |
| 804 | EXPECT_EQ(0u, BIO_ctrl_get_read_request(bio1)); |
| 805 |
| 806 | // Data written in one end may be read out the other. |
| 807 | uint8_t buf[20]; |
| 808 | EXPECT_EQ(5, BIO_write(bio1, "12345", 5)); |
| 809 | EXPECT_EQ(5u, BIO_ctrl_get_write_guarantee(bio1)); |
| 810 | ASSERT_EQ(5, BIO_read(bio2, buf, sizeof(buf))); |
| 811 | EXPECT_EQ(Bytes("12345"), Bytes(buf, 5)); |
| 812 | EXPECT_EQ(10u, BIO_ctrl_get_write_guarantee(bio1)); |
| 813 |
| 814 | // Attempting to write more than 10 bytes will write partially. |
| 815 | EXPECT_EQ(10, BIO_write(bio1, "1234567890___", 13)); |
| 816 | EXPECT_EQ(0u, BIO_ctrl_get_write_guarantee(bio1)); |
| 817 | EXPECT_EQ(-1, BIO_write(bio1, "z", 1)); |
| 818 | EXPECT_TRUE(BIO_should_write(bio1)); |
| 819 | ASSERT_EQ(10, BIO_read(bio2, buf, sizeof(buf))); |
| 820 | EXPECT_EQ(Bytes("1234567890"), Bytes(buf, 10)); |
| 821 | EXPECT_EQ(10u, BIO_ctrl_get_write_guarantee(bio1)); |
| 822 |
| 823 | // Unsuccessful reads update the read request. |
| 824 | EXPECT_EQ(-1, BIO_read(bio2, buf, 5)); |
| 825 | EXPECT_TRUE(BIO_should_read(bio2)); |
| 826 | EXPECT_EQ(5u, BIO_ctrl_get_read_request(bio1)); |
| 827 |
| 828 | // The read request is clamped to the size of the buffer. |
| 829 | EXPECT_EQ(-1, BIO_read(bio2, buf, 20)); |
| 830 | EXPECT_TRUE(BIO_should_read(bio2)); |
| 831 | EXPECT_EQ(10u, BIO_ctrl_get_read_request(bio1)); |
| 832 |
| 833 | // Data may be written and read in chunks. |
| 834 | EXPECT_EQ(5, BIO_write(bio1, "12345", 5)); |
| 835 | EXPECT_EQ(5u, BIO_ctrl_get_write_guarantee(bio1)); |
| 836 | EXPECT_EQ(5, BIO_write(bio1, "67890___", 8)); |
| 837 | EXPECT_EQ(0u, BIO_ctrl_get_write_guarantee(bio1)); |
| 838 | ASSERT_EQ(3, BIO_read(bio2, buf, 3)); |
| 839 | EXPECT_EQ(Bytes("123"), Bytes(buf, 3)); |
| 840 | EXPECT_EQ(3u, BIO_ctrl_get_write_guarantee(bio1)); |
| 841 | ASSERT_EQ(7, BIO_read(bio2, buf, sizeof(buf))); |
| 842 | EXPECT_EQ(Bytes("4567890"), Bytes(buf, 7)); |
| 843 | EXPECT_EQ(10u, BIO_ctrl_get_write_guarantee(bio1)); |
| 844 |
| 845 | // Successful reads reset the read request. |
| 846 | EXPECT_EQ(0u, BIO_ctrl_get_read_request(bio1)); |
| 847 |
| 848 | // Test writes and reads starting in the middle of the ring buffer and |
| 849 | // wrapping to front. |
| 850 | EXPECT_EQ(8, BIO_write(bio1, "abcdefgh", 8)); |
| 851 | EXPECT_EQ(2u, BIO_ctrl_get_write_guarantee(bio1)); |
| 852 | ASSERT_EQ(3, BIO_read(bio2, buf, 3)); |
| 853 | EXPECT_EQ(Bytes("abc"), Bytes(buf, 3)); |
| 854 | EXPECT_EQ(5u, BIO_ctrl_get_write_guarantee(bio1)); |
| 855 | EXPECT_EQ(5, BIO_write(bio1, "ijklm___", 8)); |
| 856 | EXPECT_EQ(0u, BIO_ctrl_get_write_guarantee(bio1)); |
| 857 | ASSERT_EQ(10, BIO_read(bio2, buf, sizeof(buf))); |
| 858 | EXPECT_EQ(Bytes("defghijklm"), Bytes(buf, 10)); |
| 859 | EXPECT_EQ(10u, BIO_ctrl_get_write_guarantee(bio1)); |
| 860 |
| 861 | // Data may flow from both ends in parallel. |
| 862 | EXPECT_EQ(5, BIO_write(bio1, "12345", 5)); |
| 863 | EXPECT_EQ(5, BIO_write(bio2, "67890", 5)); |
| 864 | ASSERT_EQ(5, BIO_read(bio2, buf, sizeof(buf))); |
| 865 | EXPECT_EQ(Bytes("12345"), Bytes(buf, 5)); |
| 866 | ASSERT_EQ(5, BIO_read(bio1, buf, sizeof(buf))); |
| 867 | EXPECT_EQ(Bytes("67890"), Bytes(buf, 5)); |
| 868 |
| 869 | // Closing the write end causes an EOF on the read half, after draining. |
| 870 | EXPECT_EQ(5, BIO_write(bio1, "12345", 5)); |
| 871 | EXPECT_TRUE(BIO_shutdown_wr(bio1)); |
| 872 | ASSERT_EQ(5, BIO_read(bio2, buf, sizeof(buf))); |
| 873 | EXPECT_EQ(Bytes("12345"), Bytes(buf, 5)); |
| 874 | EXPECT_EQ(0, BIO_read(bio2, buf, sizeof(buf))); |
| 875 |
| 876 | // A closed write end may not be written to. |
| 877 | EXPECT_EQ(0u, BIO_ctrl_get_write_guarantee(bio1)); |
| 878 | EXPECT_EQ(-1, BIO_write(bio1, "_____", 5)); |
| 879 | EXPECT_TRUE(ErrorEquals(ERR_get_error(), ERR_LIB_BIO, BIO_R_BROKEN_PIPE)); |
| 880 |
| 881 | // The other end is still functional. |
| 882 | EXPECT_EQ(5, BIO_write(bio2, "12345", 5)); |
| 883 | ASSERT_EQ(5, BIO_read(bio1, buf, sizeof(buf))); |
| 884 | EXPECT_EQ(Bytes("12345"), Bytes(buf, 5)); |
| 885 | } |
| 886 |
| 887 | INSTANTIATE_TEST_SUITE_P(All, BIOPairTest, testing::Values(false, true)); |
| 888 |
| 889 | } // namespace |
| 890 |