Skip to content

Commit

Permalink
test: fix failing inspector cctest
Browse files Browse the repository at this point in the history
Test was updated to wait till the inspector processes socket closure.

Fixes: #8006
PR-URL: #8019
Reviewed-By: ofrobots - Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
Eugene Ostroukhov authored and cjihrig committed Aug 10, 2016
1 parent 780395f commit 554b0f9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/cctest/test_inspector_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,11 @@ TEST_F(InspectorSocketTest, GetThenHandshake) {
manual_inspector_socket_cleanup();
}

static void WriteBeforeHandshake_close_cb(uv_handle_t* handle) {
*(static_cast<bool *>(handle->data)) = true;
static void WriteBeforeHandshake_inspector_delegate(inspector_handshake_event e,
const std::string& path,
bool* cont) {
if (e == kInspectorHandshakeFailed)
inspector_closed = 1;
}

TEST_F(InspectorSocketTest, WriteBeforeHandshake) {
Expand All @@ -743,11 +746,10 @@ TEST_F(InspectorSocketTest, WriteBeforeHandshake) {
inspector_write(&inspector, MESSAGE1, sizeof(MESSAGE1) - 1);
inspector_write(&inspector, MESSAGE2, sizeof(MESSAGE2) - 1);
expect_on_client(EXPECTED, sizeof(EXPECTED) - 1);
bool flag = false;
client_socket.data = &flag;
uv_close(reinterpret_cast<uv_handle_t*>(&client_socket),
WriteBeforeHandshake_close_cb);
SPIN_WHILE(!flag);
inspector_closed = 0;
handshake_delegate = WriteBeforeHandshake_inspector_delegate;
really_close(reinterpret_cast<uv_handle_t*>(&client_socket));
SPIN_WHILE(inspector_closed == 0);
}

static void CleanupSocketAfterEOF_close_cb(inspector_socket_t* inspector,
Expand Down

0 comments on commit 554b0f9

Please sign in to comment.