MCPcopy Create free account
hub / github.com/apache/impala / TEST_F

Function TEST_F

security/tls_socket-test.cc:218–254  ·  view source on GitHub ↗

Test for failures to handle EINTR during TLS connection negotiation and data send/receive.

Source from the content-addressed store, hash-verified

216// Test for failures to handle EINTR during TLS connection
217// negotiation and data send/receive.
218TEST_F(TlsSocketTest, TestTlsSocketInterrupted) {
219 // Set up a no-op signal handler for SIGUSR2.
220 struct sigaction sa, sa_old;
221 memset(&sa, 0, sizeof(sa));
222 sa.sa_handler = &handler;
223 sigaction(SIGUSR2, &sa, &sa_old);
224 SCOPED_CLEANUP({ sigaction(SIGUSR2, &sa_old, nullptr); });
225
226 EchoServer server;
227 NO_FATALS(server.Start());
228
229 // Start a thread to send signals to the server thread.
230 thread killer([&]() {
231 while (!server.stopped()) {
232 PCHECK(pthread_kill(server.pthread(), SIGUSR2) == 0);
233 SleepFor(MonoDelta::FromMicroseconds(rand() % 10));
234 }
235 });
236 SCOPED_CLEANUP({ killer.join(); });
237
238 unique_ptr<Socket> client_sock;
239 NO_FATALS(ConnectClient(server.listen_addr(), &client_sock));
240
241 unique_ptr<uint8_t[]> buf(new uint8_t[kEchoChunkSize]);
242 for (int i = 0; i < 10; i++) {
243 SleepFor(MonoDelta::FromMilliseconds(1));
244 size_t nwritten;
245 ASSERT_OK(client_sock->BlockingWrite(buf.get(), kEchoChunkSize, &nwritten,
246 MonoTime::Now() + kTimeout));
247 size_t n;
248 ASSERT_OK(client_sock->BlockingRecv(buf.get(), kEchoChunkSize, &n,
249 MonoTime::Now() + kTimeout));
250 }
251 server.Stop();
252 ASSERT_OK(client_sock->Close());
253 LOG(INFO) << "client done";
254}
255
256// Return an iovec containing the same data as the buffer 'buf' with the length 'len',
257// but split into random-sized chunks. The chunks are sized randomly between 1 and

Callers

nothing calls this directly

Calls 15

SleepForFunction · 0.85
GetRandomSeed32Function · 0.85
RandomStringFunction · 0.85
stoppedMethod · 0.80
BlockingWriteMethod · 0.80
BlockingRecvMethod · 0.80
GetFdMethod · 0.80
posix_codeMethod · 0.80
eraseMethod · 0.80
sigactionClass · 0.70
ChunkIOVecFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected