OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2007 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2007 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 accepted->Close(); | 535 accepted->Close(); |
536 EXPECT_EQ(AsyncSocket::CS_CLOSED, accepted->GetState()); | 536 EXPECT_EQ(AsyncSocket::CS_CLOSED, accepted->GetState()); |
537 | 537 |
538 // Expect that the client is notified, and has not yet closed. | 538 // Expect that the client is notified, and has not yet closed. |
539 EXPECT_TRUE_WAIT(sink.Check(client.get(), testing::SSE_READ), kTimeout); | 539 EXPECT_TRUE_WAIT(sink.Check(client.get(), testing::SSE_READ), kTimeout); |
540 EXPECT_FALSE(sink.Check(client.get(), testing::SSE_CLOSE)); | 540 EXPECT_FALSE(sink.Check(client.get(), testing::SSE_CLOSE)); |
541 EXPECT_EQ(AsyncSocket::CS_CONNECTED, client->GetState()); | 541 EXPECT_EQ(AsyncSocket::CS_CONNECTED, client->GetState()); |
542 | 542 |
543 // Ensure the data can be read. | 543 // Ensure the data can be read. |
544 char buffer[10]; | 544 char buffer[10]; |
545 EXPECT_EQ(1, client->Recv(buffer, sizeof(buffer))); | 545 int64_t timestamp; |
| 546 EXPECT_EQ(1, client->Recv(buffer, sizeof(buffer), ×tamp)); |
546 EXPECT_EQ('a', buffer[0]); | 547 EXPECT_EQ('a', buffer[0]); |
547 | 548 |
548 // Now we should close, but the remote address will remain. | 549 // Now we should close, but the remote address will remain. |
549 EXPECT_EQ_WAIT(AsyncSocket::CS_CLOSED, client->GetState(), kTimeout); | 550 EXPECT_EQ_WAIT(AsyncSocket::CS_CLOSED, client->GetState(), kTimeout); |
550 EXPECT_TRUE(sink.Check(client.get(), testing::SSE_CLOSE)); | 551 EXPECT_TRUE(sink.Check(client.get(), testing::SSE_CLOSE)); |
551 EXPECT_FALSE(client->GetRemoteAddress().IsAnyIP()); | 552 EXPECT_FALSE(client->GetRemoteAddress().IsAnyIP()); |
552 | 553 |
553 // The closer should not get a close signal. | 554 // The closer should not get a close signal. |
554 EXPECT_FALSE(sink.Check(accepted.get(), testing::SSE_CLOSE)); | 555 EXPECT_FALSE(sink.Check(accepted.get(), testing::SSE_CLOSE)); |
555 EXPECT_TRUE(accepted->GetRemoteAddress().IsNil()); | 556 EXPECT_TRUE(accepted->GetRemoteAddress().IsNil()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 // Shouldn't signal when blocked in a thread Send, where process_io is false. | 668 // Shouldn't signal when blocked in a thread Send, where process_io is false. |
668 std::unique_ptr<Thread> thread(new Thread()); | 669 std::unique_ptr<Thread> thread(new Thread()); |
669 thread->Start(); | 670 thread->Start(); |
670 Sleeper sleeper; | 671 Sleeper sleeper; |
671 TypedMessageData<AsyncSocket*> data(client.get()); | 672 TypedMessageData<AsyncSocket*> data(client.get()); |
672 thread->Send(&sleeper, 0, &data); | 673 thread->Send(&sleeper, 0, &data); |
673 EXPECT_FALSE(sink.Check(accepted.get(), testing::SSE_READ)); | 674 EXPECT_FALSE(sink.Check(accepted.get(), testing::SSE_READ)); |
674 | 675 |
675 // But should signal when process_io is true. | 676 // But should signal when process_io is true. |
676 EXPECT_TRUE_WAIT((sink.Check(accepted.get(), testing::SSE_READ)), kTimeout); | 677 EXPECT_TRUE_WAIT((sink.Check(accepted.get(), testing::SSE_READ)), kTimeout); |
677 EXPECT_LT(0, accepted->Recv(buf, 1024)); | 678 int64_t timestamp; |
| 679 EXPECT_LT(0, accepted->Recv(buf, 1024, ×tamp)); |
678 } | 680 } |
679 | 681 |
680 void SocketTest::TcpInternal(const IPAddress& loopback, size_t data_size, | 682 void SocketTest::TcpInternal(const IPAddress& loopback, size_t data_size, |
681 ssize_t max_send_size) { | 683 ssize_t max_send_size) { |
682 testing::StreamSink sink; | 684 testing::StreamSink sink; |
683 SocketAddress accept_addr; | 685 SocketAddress accept_addr; |
684 | 686 |
685 // Create receiving client. | 687 // Create receiving client. |
686 std::unique_ptr<AsyncSocket> receiver( | 688 std::unique_ptr<AsyncSocket> receiver( |
687 ss_->CreateAsyncSocket(loopback.family(), SOCK_STREAM)); | 689 ss_->CreateAsyncSocket(loopback.family(), SOCK_STREAM)); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 if (!readable) { | 759 if (!readable) { |
758 // Wait until data is available. | 760 // Wait until data is available. |
759 EXPECT_TRUE_WAIT(sink.Check(receiver.get(), testing::SSE_READ), | 761 EXPECT_TRUE_WAIT(sink.Check(receiver.get(), testing::SSE_READ), |
760 kTimeout); | 762 kTimeout); |
761 readable = true; | 763 readable = true; |
762 recv_called = false; | 764 recv_called = false; |
763 } | 765 } |
764 | 766 |
765 // Receive as much as we can get in a single recv call. | 767 // Receive as much as we can get in a single recv call. |
766 char recved_data[data_size]; | 768 char recved_data[data_size]; |
767 int recved_size = receiver->Recv(recved_data, data_size); | 769 int64_t timestamp; |
| 770 int recved_size = receiver->Recv(recved_data, data_size, ×tamp); |
768 | 771 |
769 if (!recv_called) { | 772 if (!recv_called) { |
770 // The first Recv() after getting readability should succeed and receive | 773 // The first Recv() after getting readability should succeed and receive |
771 // some data. | 774 // some data. |
772 // TODO: The following line is disabled due to flakey pulse | 775 // TODO: The following line is disabled due to flakey pulse |
773 // builds. Re-enable if/when possible. | 776 // builds. Re-enable if/when possible. |
774 // EXPECT_GT(recved_size, 0); | 777 // EXPECT_GT(recved_size, 0); |
775 recv_called = true; | 778 recv_called = true; |
776 } | 779 } |
777 if (recved_size >= 0) { | 780 if (recved_size >= 0) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 char buf[1024 * 16] = {0}; | 847 char buf[1024 * 16] = {0}; |
845 int sends = 0; | 848 int sends = 0; |
846 while (++sends && accepted->Send(&buf, arraysize(buf)) != -1) {} | 849 while (++sends && accepted->Send(&buf, arraysize(buf)) != -1) {} |
847 EXPECT_TRUE(accepted->IsBlocking()); | 850 EXPECT_TRUE(accepted->IsBlocking()); |
848 | 851 |
849 // Wait until data is available. | 852 // Wait until data is available. |
850 EXPECT_TRUE_WAIT(sink.Check(client.get(), testing::SSE_READ), kTimeout); | 853 EXPECT_TRUE_WAIT(sink.Check(client.get(), testing::SSE_READ), kTimeout); |
851 | 854 |
852 // Pull data. | 855 // Pull data. |
853 for (int i = 0; i < sends; ++i) { | 856 for (int i = 0; i < sends; ++i) { |
854 client->Recv(buf, arraysize(buf)); | 857 int64_t timestamp; |
| 858 client->Recv(buf, arraysize(buf), ×tamp); |
855 } | 859 } |
856 | 860 |
857 // Expect at least one additional writable callback. | 861 // Expect at least one additional writable callback. |
858 EXPECT_TRUE_WAIT(sink.Check(accepted.get(), testing::SSE_WRITE), kTimeout); | 862 EXPECT_TRUE_WAIT(sink.Check(accepted.get(), testing::SSE_WRITE), kTimeout); |
859 | 863 |
860 // Adding data in response to the writeable callback shouldn't cause infinite | 864 // Adding data in response to the writeable callback shouldn't cause infinite |
861 // callbacks. | 865 // callbacks. |
862 int extras = 0; | 866 int extras = 0; |
863 for (int i = 0; i < 100; ++i) { | 867 for (int i = 0; i < 100; ++i) { |
864 accepted->Send(&buf, arraysize(buf)); | 868 accepted->Send(&buf, arraysize(buf)); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 ASSERT_EQ(-1, mtu_socket->EstimateMTU(&mtu)); | 1022 ASSERT_EQ(-1, mtu_socket->EstimateMTU(&mtu)); |
1019 #else | 1023 #else |
1020 // and the behavior seems unpredictable on Linux, | 1024 // and the behavior seems unpredictable on Linux, |
1021 // failing on the build machine | 1025 // failing on the build machine |
1022 // but succeeding on my Ubiquity instance. | 1026 // but succeeding on my Ubiquity instance. |
1023 #endif | 1027 #endif |
1024 } | 1028 } |
1025 } | 1029 } |
1026 | 1030 |
1027 } // namespace rtc | 1031 } // namespace rtc |
OLD | NEW |