From 49e473a45fb3e13fdd4588c6241b71bbac4fe5ab Mon Sep 17 00:00:00 2001 From: Eugene Ostroukhov Date: Mon, 8 Aug 2016 11:30:13 -0700 Subject: [PATCH] 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 Reviewed-By: bnoordhuis - Ben Noordhuis --- test/cctest/test_inspector_socket.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/cctest/test_inspector_socket.cc b/test/cctest/test_inspector_socket.cc index 771f4022acdf72..6f8cd25486a5bc 100644 --- a/test/cctest/test_inspector_socket.cc +++ b/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(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(&client_socket), - WriteBeforeHandshake_close_cb); - SPIN_WHILE(!flag); + inspector_closed = 0; + handshake_delegate = WriteBeforeHandshake_inspector_delegate; + really_close(reinterpret_cast(&client_socket)); + SPIN_WHILE(inspector_closed == 0); } static void CleanupSocketAfterEOF_close_cb(inspector_socket_t* inspector,