Browse Source

test: fix failing inspector cctest

Test was updated to wait till the inspector processes socket closure.

Fixes: https://github.com/nodejs/node/pull/8006
PR-URL: https://github.com/nodejs/node/pull/8019
Reviewed-By: ofrobots - Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
v6.x
Eugene Ostroukhov 9 years ago
committed by cjihrig
parent
commit
554b0f9d91
  1. 16
      test/cctest/test_inspector_socket.cc

16
test/cctest/test_inspector_socket.cc

@ -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) {
@ -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,

Loading…
Cancel
Save