Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions test/cctest/test_inspector_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ static void manual_inspector_socket_cleanup() {
inspector.buffer.clear();
}

static void assert_both_sockets_closed() {
SPIN_WHILE(uv_is_active(reinterpret_cast<uv_handle_t*>(&client_socket)));
SPIN_WHILE(uv_is_active(reinterpret_cast<uv_handle_t*>(&inspector.client)));
}

static void on_connection(uv_connect_t* connect, int status) {
GTEST_ASSERT_EQ(0, status);
connect->data = connect;
Expand Down Expand Up @@ -481,8 +486,7 @@ TEST_F(InspectorSocketTest, ExtraTextBeforeRequest) {
do_write(const_cast<char*>(HANDSHAKE_REQ), sizeof(HANDSHAKE_REQ) - 1);
SPIN_WHILE(last_event != kInspectorHandshakeFailed);
expect_handshake_failure();
EXPECT_EQ(uv_is_active(reinterpret_cast<uv_handle_t*>(&client_socket)), 0);
EXPECT_EQ(uv_is_active(reinterpret_cast<uv_handle_t*>(&socket)), 0);
assert_both_sockets_closed();
}

TEST_F(InspectorSocketTest, ExtraLettersBeforeRequest) {
Expand All @@ -493,8 +497,7 @@ TEST_F(InspectorSocketTest, ExtraLettersBeforeRequest) {
do_write(const_cast<char*>(HANDSHAKE_REQ), sizeof(HANDSHAKE_REQ) - 1);
SPIN_WHILE(last_event != kInspectorHandshakeFailed);
expect_handshake_failure();
EXPECT_EQ(uv_is_active(reinterpret_cast<uv_handle_t*>(&client_socket)), 0);
EXPECT_EQ(uv_is_active(reinterpret_cast<uv_handle_t*>(&socket)), 0);
assert_both_sockets_closed();
}

TEST_F(InspectorSocketTest, RequestWithoutKey) {
Expand All @@ -508,8 +511,7 @@ TEST_F(InspectorSocketTest, RequestWithoutKey) {
do_write(const_cast<char*>(BROKEN_REQUEST), sizeof(BROKEN_REQUEST) - 1);
SPIN_WHILE(last_event != kInspectorHandshakeFailed);
expect_handshake_failure();
EXPECT_EQ(uv_is_active(reinterpret_cast<uv_handle_t*>(&client_socket)), 0);
EXPECT_EQ(uv_is_active(reinterpret_cast<uv_handle_t*>(&socket)), 0);
assert_both_sockets_closed();
}

TEST_F(InspectorSocketTest, KillsConnectionOnProtocolViolation) {
Expand Down