diff options
author | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
---|---|---|
committer | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
commit | b9c1b51e45b845debb76d8658edabca70ca56079 (patch) | |
tree | dfcb5a13ef2b014202340f47036da383eaee74aa /lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp | |
parent | d5aa73376966339caad04013510626ec2e42c760 (diff) | |
download | llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.bz2 |
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
Diffstat (limited to 'lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp')
-rw-r--r-- | lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp | 603 |
1 files changed, 293 insertions, 310 deletions
diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp index 6b56e5c..6039794 100644 --- a/lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp +++ b/lldb/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp @@ -8,7 +8,8 @@ //===----------------------------------------------------------------------===// #if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0) -// Workaround for MSVC standard library bug, which fails to include <thread> when +// Workaround for MSVC standard library bug, which fails to include <thread> +// when // exceptions are disabled. #include <eh.h> #endif @@ -28,338 +29,320 @@ using namespace lldb_private; using namespace lldb; typedef GDBRemoteCommunication::PacketResult PacketResult; -namespace -{ - -struct MockDelegate : public GDBRemoteClientBase::ContinueDelegate -{ - std::string output; - std::string misc_data; - unsigned stop_reply_called = 0; - - void - HandleAsyncStdout(llvm::StringRef out) - { - output += out; - } - void - HandleAsyncMisc(llvm::StringRef data) - { - misc_data += data; - } - void - HandleStopReply() - { - ++stop_reply_called; - } - - bool - HandleAsyncStructuredData(const StructuredData::ObjectSP - &object_sp) - { - // TODO work in a test here after I fix the gtest breakage. - return true; - } +namespace { +struct MockDelegate : public GDBRemoteClientBase::ContinueDelegate { + std::string output; + std::string misc_data; + unsigned stop_reply_called = 0; + + void HandleAsyncStdout(llvm::StringRef out) { output += out; } + void HandleAsyncMisc(llvm::StringRef data) { misc_data += data; } + void HandleStopReply() { ++stop_reply_called; } + + bool HandleAsyncStructuredData(const StructuredData::ObjectSP &object_sp) { + // TODO work in a test here after I fix the gtest breakage. + return true; + } }; -struct TestClient : public GDBRemoteClientBase -{ - TestClient() : GDBRemoteClientBase("test.client", "test.client.listener") { m_send_acks = false; } +struct TestClient : public GDBRemoteClientBase { + TestClient() : GDBRemoteClientBase("test.client", "test.client.listener") { + m_send_acks = false; + } }; -struct ContinueFixture -{ - MockDelegate delegate; - TestClient client; - MockServer server; - ListenerSP listener_sp; - - ContinueFixture(); - - StateType - SendCPacket(StringExtractorGDBRemote &response) - { - return client.SendContinuePacketAndWaitForResponse(delegate, LinuxSignals(), "c", response); - } - - void - WaitForRunEvent() - { - EventSP event_sp; - listener_sp->WaitForEventForBroadcasterWithType(std::chrono::microseconds(0), &client, - TestClient::eBroadcastBitRunPacketSent, event_sp); - } +struct ContinueFixture { + MockDelegate delegate; + TestClient client; + MockServer server; + ListenerSP listener_sp; + + ContinueFixture(); + + StateType SendCPacket(StringExtractorGDBRemote &response) { + return client.SendContinuePacketAndWaitForResponse(delegate, LinuxSignals(), + "c", response); + } + + void WaitForRunEvent() { + EventSP event_sp; + listener_sp->WaitForEventForBroadcasterWithType( + std::chrono::microseconds(0), &client, + TestClient::eBroadcastBitRunPacketSent, event_sp); + } }; -ContinueFixture::ContinueFixture() : listener_sp(Listener::MakeListener("listener")) -{ - Connect(client, server); - listener_sp->StartListeningForEvents(&client, TestClient::eBroadcastBitRunPacketSent); +ContinueFixture::ContinueFixture() + : listener_sp(Listener::MakeListener("listener")) { + Connect(client, server); + listener_sp->StartListeningForEvents(&client, + TestClient::eBroadcastBitRunPacketSent); } } // end anonymous namespace -class GDBRemoteClientBaseTest : public GDBRemoteTest -{ -}; - -TEST_F(GDBRemoteClientBaseTest, SendContinueAndWait) -{ - StringExtractorGDBRemote response; - ContinueFixture fix; - if (HasFailure()) - return; - - // Continue. The inferior will stop with a signal. - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T01")); - ASSERT_EQ(eStateStopped, fix.SendCPacket(response)); - ASSERT_EQ("T01", response.GetStringRef()); - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("c", response.GetStringRef()); - - // Continue. The inferior will exit. - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("W01")); - ASSERT_EQ(eStateExited, fix.SendCPacket(response)); - ASSERT_EQ("W01", response.GetStringRef()); - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("c", response.GetStringRef()); - - // Continue. The inferior will get killed. - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("X01")); - ASSERT_EQ(eStateExited, fix.SendCPacket(response)); - ASSERT_EQ("X01", response.GetStringRef()); - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("c", response.GetStringRef()); +class GDBRemoteClientBaseTest : public GDBRemoteTest {}; + +TEST_F(GDBRemoteClientBaseTest, SendContinueAndWait) { + StringExtractorGDBRemote response; + ContinueFixture fix; + if (HasFailure()) + return; + + // Continue. The inferior will stop with a signal. + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T01")); + ASSERT_EQ(eStateStopped, fix.SendCPacket(response)); + ASSERT_EQ("T01", response.GetStringRef()); + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("c", response.GetStringRef()); + + // Continue. The inferior will exit. + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("W01")); + ASSERT_EQ(eStateExited, fix.SendCPacket(response)); + ASSERT_EQ("W01", response.GetStringRef()); + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("c", response.GetStringRef()); + + // Continue. The inferior will get killed. + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("X01")); + ASSERT_EQ(eStateExited, fix.SendCPacket(response)); + ASSERT_EQ("X01", response.GetStringRef()); + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("c", response.GetStringRef()); } -TEST_F(GDBRemoteClientBaseTest, SendContinueAndAsyncSignal) -{ - StringExtractorGDBRemote continue_response, response; - ContinueFixture fix; - if (HasFailure()) - return; - - // SendAsyncSignal should do nothing when we are not running. - ASSERT_FALSE(fix.client.SendAsyncSignal(0x47)); - - // Continue. After the run packet is sent, send an async signal. - std::future<StateType> continue_state = - std::async(std::launch::async, [&] { return fix.SendCPacket(continue_response); }); - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("c", response.GetStringRef()); - fix.WaitForRunEvent(); - - std::future<bool> async_result = std::async(std::launch::async, [&] { return fix.client.SendAsyncSignal(0x47); }); - - // First we'll get interrupted. - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("\x03", response.GetStringRef()); - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T13")); - - // Then we get the signal packet. - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("C47", response.GetStringRef()); - ASSERT_TRUE(async_result.get()); - - // And we report back a signal stop. - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T47")); - ASSERT_EQ(eStateStopped, continue_state.get()); - ASSERT_EQ("T47", continue_response.GetStringRef()); +TEST_F(GDBRemoteClientBaseTest, SendContinueAndAsyncSignal) { + StringExtractorGDBRemote continue_response, response; + ContinueFixture fix; + if (HasFailure()) + return; + + // SendAsyncSignal should do nothing when we are not running. + ASSERT_FALSE(fix.client.SendAsyncSignal(0x47)); + + // Continue. After the run packet is sent, send an async signal. + std::future<StateType> continue_state = std::async( + std::launch::async, [&] { return fix.SendCPacket(continue_response); }); + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("c", response.GetStringRef()); + fix.WaitForRunEvent(); + + std::future<bool> async_result = std::async( + std::launch::async, [&] { return fix.client.SendAsyncSignal(0x47); }); + + // First we'll get interrupted. + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("\x03", response.GetStringRef()); + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T13")); + + // Then we get the signal packet. + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("C47", response.GetStringRef()); + ASSERT_TRUE(async_result.get()); + + // And we report back a signal stop. + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T47")); + ASSERT_EQ(eStateStopped, continue_state.get()); + ASSERT_EQ("T47", continue_response.GetStringRef()); } -TEST_F(GDBRemoteClientBaseTest, SendContinueAndAsyncPacket) -{ - StringExtractorGDBRemote continue_response, async_response, response; - const bool send_async = true; - ContinueFixture fix; - if (HasFailure()) - return; - - // Continue. After the run packet is sent, send an async packet. - std::future<StateType> continue_state = - std::async(std::launch::async, [&] { return fix.SendCPacket(continue_response); }); - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("c", response.GetStringRef()); - fix.WaitForRunEvent(); - - // Sending without async enabled should fail. - ASSERT_EQ(PacketResult::ErrorSendFailed, fix.client.SendPacketAndWaitForResponse("qTest1", response, !send_async)); - - std::future<PacketResult> async_result = std::async(std::launch::async, [&] { - return fix.client.SendPacketAndWaitForResponse("qTest2", async_response, send_async); - }); - - // First we'll get interrupted. - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("\x03", response.GetStringRef()); - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T13")); - - // Then we get the async packet. - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("qTest2", response.GetStringRef()); - - // Send the response and receive it. - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("QTest2")); - ASSERT_EQ(PacketResult::Success, async_result.get()); - ASSERT_EQ("QTest2", async_response.GetStringRef()); - - // And we get resumed again. - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("c", response.GetStringRef()); - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T01")); - ASSERT_EQ(eStateStopped, continue_state.get()); - ASSERT_EQ("T01", continue_response.GetStringRef()); +TEST_F(GDBRemoteClientBaseTest, SendContinueAndAsyncPacket) { + StringExtractorGDBRemote continue_response, async_response, response; + const bool send_async = true; + ContinueFixture fix; + if (HasFailure()) + return; + + // Continue. After the run packet is sent, send an async packet. + std::future<StateType> continue_state = std::async( + std::launch::async, [&] { return fix.SendCPacket(continue_response); }); + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("c", response.GetStringRef()); + fix.WaitForRunEvent(); + + // Sending without async enabled should fail. + ASSERT_EQ( + PacketResult::ErrorSendFailed, + fix.client.SendPacketAndWaitForResponse("qTest1", response, !send_async)); + + std::future<PacketResult> async_result = std::async(std::launch::async, [&] { + return fix.client.SendPacketAndWaitForResponse("qTest2", async_response, + send_async); + }); + + // First we'll get interrupted. + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("\x03", response.GetStringRef()); + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T13")); + + // Then we get the async packet. + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("qTest2", response.GetStringRef()); + + // Send the response and receive it. + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("QTest2")); + ASSERT_EQ(PacketResult::Success, async_result.get()); + ASSERT_EQ("QTest2", async_response.GetStringRef()); + + // And we get resumed again. + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("c", response.GetStringRef()); + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T01")); + ASSERT_EQ(eStateStopped, continue_state.get()); + ASSERT_EQ("T01", continue_response.GetStringRef()); } -TEST_F(GDBRemoteClientBaseTest, SendContinueAndInterrupt) -{ - StringExtractorGDBRemote continue_response, response; - ContinueFixture fix; - if (HasFailure()) - return; - - // Interrupt should do nothing when we're not running. - ASSERT_FALSE(fix.client.Interrupt()); - - // Continue. After the run packet is sent, send an interrupt. - std::future<StateType> continue_state = - std::async(std::launch::async, [&] { return fix.SendCPacket(continue_response); }); - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("c", response.GetStringRef()); - fix.WaitForRunEvent(); - - std::future<bool> async_result = std::async(std::launch::async, [&] { return fix.client.Interrupt(); }); - - // We get interrupted. - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("\x03", response.GetStringRef()); - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T13")); - - // And that's it. - ASSERT_EQ(eStateStopped, continue_state.get()); - ASSERT_EQ("T13", continue_response.GetStringRef()); - ASSERT_TRUE(async_result.get()); +TEST_F(GDBRemoteClientBaseTest, SendContinueAndInterrupt) { + StringExtractorGDBRemote continue_response, response; + ContinueFixture fix; + if (HasFailure()) + return; + + // Interrupt should do nothing when we're not running. + ASSERT_FALSE(fix.client.Interrupt()); + + // Continue. After the run packet is sent, send an interrupt. + std::future<StateType> continue_state = std::async( + std::launch::async, [&] { return fix.SendCPacket(continue_response); }); + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("c", response.GetStringRef()); + fix.WaitForRunEvent(); + + std::future<bool> async_result = + std::async(std::launch::async, [&] { return fix.client.Interrupt(); }); + + // We get interrupted. + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("\x03", response.GetStringRef()); + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T13")); + + // And that's it. + ASSERT_EQ(eStateStopped, continue_state.get()); + ASSERT_EQ("T13", continue_response.GetStringRef()); + ASSERT_TRUE(async_result.get()); } -TEST_F(GDBRemoteClientBaseTest, SendContinueAndLateInterrupt) -{ - StringExtractorGDBRemote continue_response, response; - ContinueFixture fix; - if (HasFailure()) - return; - - // Continue. After the run packet is sent, send an interrupt. - std::future<StateType> continue_state = - std::async(std::launch::async, [&] { return fix.SendCPacket(continue_response); }); - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("c", response.GetStringRef()); - fix.WaitForRunEvent(); - - std::future<bool> async_result = std::async(std::launch::async, [&] { return fix.client.Interrupt(); }); - - // However, the target stops due to a different reason than the original interrupt. - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("\x03", response.GetStringRef()); - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T01")); - ASSERT_EQ(eStateStopped, continue_state.get()); - ASSERT_EQ("T01", continue_response.GetStringRef()); - ASSERT_TRUE(async_result.get()); - - // The subsequent continue packet should work normally. - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T01")); - ASSERT_EQ(eStateStopped, fix.SendCPacket(response)); - ASSERT_EQ("T01", response.GetStringRef()); - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("c", response.GetStringRef()); +TEST_F(GDBRemoteClientBaseTest, SendContinueAndLateInterrupt) { + StringExtractorGDBRemote continue_response, response; + ContinueFixture fix; + if (HasFailure()) + return; + + // Continue. After the run packet is sent, send an interrupt. + std::future<StateType> continue_state = std::async( + std::launch::async, [&] { return fix.SendCPacket(continue_response); }); + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("c", response.GetStringRef()); + fix.WaitForRunEvent(); + + std::future<bool> async_result = + std::async(std::launch::async, [&] { return fix.client.Interrupt(); }); + + // However, the target stops due to a different reason than the original + // interrupt. + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("\x03", response.GetStringRef()); + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T01")); + ASSERT_EQ(eStateStopped, continue_state.get()); + ASSERT_EQ("T01", continue_response.GetStringRef()); + ASSERT_TRUE(async_result.get()); + + // The subsequent continue packet should work normally. + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T01")); + ASSERT_EQ(eStateStopped, fix.SendCPacket(response)); + ASSERT_EQ("T01", response.GetStringRef()); + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("c", response.GetStringRef()); } -TEST_F(GDBRemoteClientBaseTest, SendContinueAndInterrupt2PacketBug) -{ - StringExtractorGDBRemote continue_response, async_response, response; - const bool send_async = true; - ContinueFixture fix; - if (HasFailure()) - return; - - // Interrupt should do nothing when we're not running. - ASSERT_FALSE(fix.client.Interrupt()); - - // Continue. After the run packet is sent, send an async signal. - std::future<StateType> continue_state = - std::async(std::launch::async, [&] { return fix.SendCPacket(continue_response); }); - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("c", response.GetStringRef()); - fix.WaitForRunEvent(); - - std::future<bool> interrupt_result = std::async(std::launch::async, [&] { return fix.client.Interrupt(); }); - - // We get interrupted. We'll send two packets to simulate a buggy stub. - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("\x03", response.GetStringRef()); - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T13")); - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T13")); - - // We should stop. - ASSERT_EQ(eStateStopped, continue_state.get()); - ASSERT_EQ("T13", continue_response.GetStringRef()); - ASSERT_TRUE(interrupt_result.get()); - - // Packet stream should remain synchronized. - std::future<PacketResult> send_result = std::async(std::launch::async, [&] { - return fix.client.SendPacketAndWaitForResponse("qTest", async_response, !send_async); - }); - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("qTest", response.GetStringRef()); - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("QTest")); - ASSERT_EQ(PacketResult::Success, send_result.get()); - ASSERT_EQ("QTest", async_response.GetStringRef()); +TEST_F(GDBRemoteClientBaseTest, SendContinueAndInterrupt2PacketBug) { + StringExtractorGDBRemote continue_response, async_response, response; + const bool send_async = true; + ContinueFixture fix; + if (HasFailure()) + return; + + // Interrupt should do nothing when we're not running. + ASSERT_FALSE(fix.client.Interrupt()); + + // Continue. After the run packet is sent, send an async signal. + std::future<StateType> continue_state = std::async( + std::launch::async, [&] { return fix.SendCPacket(continue_response); }); + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("c", response.GetStringRef()); + fix.WaitForRunEvent(); + + std::future<bool> interrupt_result = + std::async(std::launch::async, [&] { return fix.client.Interrupt(); }); + + // We get interrupted. We'll send two packets to simulate a buggy stub. + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("\x03", response.GetStringRef()); + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T13")); + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T13")); + + // We should stop. + ASSERT_EQ(eStateStopped, continue_state.get()); + ASSERT_EQ("T13", continue_response.GetStringRef()); + ASSERT_TRUE(interrupt_result.get()); + + // Packet stream should remain synchronized. + std::future<PacketResult> send_result = std::async(std::launch::async, [&] { + return fix.client.SendPacketAndWaitForResponse("qTest", async_response, + !send_async); + }); + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("qTest", response.GetStringRef()); + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("QTest")); + ASSERT_EQ(PacketResult::Success, send_result.get()); + ASSERT_EQ("QTest", async_response.GetStringRef()); } -TEST_F(GDBRemoteClientBaseTest, SendContinueDelegateInterface) -{ - StringExtractorGDBRemote response; - ContinueFixture fix; - if (HasFailure()) - return; - - // Continue. We'll have the server send a bunch of async packets before it stops. - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("O4142")); - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("Apro")); - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("O4344")); - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("Afile")); - ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T01")); - ASSERT_EQ(eStateStopped, fix.SendCPacket(response)); - ASSERT_EQ("T01", response.GetStringRef()); - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("c", response.GetStringRef()); - - EXPECT_EQ("ABCD", fix.delegate.output); - EXPECT_EQ("profile", fix.delegate.misc_data); - EXPECT_EQ(1u, fix.delegate.stop_reply_called); +TEST_F(GDBRemoteClientBaseTest, SendContinueDelegateInterface) { + StringExtractorGDBRemote response; + ContinueFixture fix; + if (HasFailure()) + return; + + // Continue. We'll have the server send a bunch of async packets before it + // stops. + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("O4142")); + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("Apro")); + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("O4344")); + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("Afile")); + ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T01")); + ASSERT_EQ(eStateStopped, fix.SendCPacket(response)); + ASSERT_EQ("T01", response.GetStringRef()); + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("c", response.GetStringRef()); + + EXPECT_EQ("ABCD", fix.delegate.output); + EXPECT_EQ("profile", fix.delegate.misc_data); + EXPECT_EQ(1u, fix.delegate.stop_reply_called); } -TEST_F(GDBRemoteClientBaseTest, InterruptNoResponse) -{ - StringExtractorGDBRemote continue_response, response; - ContinueFixture fix; - if (HasFailure()) - return; - - // Continue. After the run packet is sent, send an interrupt. - std::future<StateType> continue_state = - std::async(std::launch::async, [&] { return fix.SendCPacket(continue_response); }); - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("c", response.GetStringRef()); - fix.WaitForRunEvent(); - - std::future<bool> async_result = std::async(std::launch::async, [&] { return fix.client.Interrupt(); }); - - // We get interrupted, but we don't send a stop packet. - ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); - ASSERT_EQ("\x03", response.GetStringRef()); - - // The functions should still terminate (after a timeout). - ASSERT_TRUE(async_result.get()); - ASSERT_EQ(eStateInvalid, continue_state.get()); +TEST_F(GDBRemoteClientBaseTest, InterruptNoResponse) { + StringExtractorGDBRemote continue_response, response; + ContinueFixture fix; + if (HasFailure()) + return; + + // Continue. After the run packet is sent, send an interrupt. + std::future<StateType> continue_state = std::async( + std::launch::async, [&] { return fix.SendCPacket(continue_response); }); + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("c", response.GetStringRef()); + fix.WaitForRunEvent(); + + std::future<bool> async_result = + std::async(std::launch::async, [&] { return fix.client.Interrupt(); }); + + // We get interrupted, but we don't send a stop packet. + ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response)); + ASSERT_EQ("\x03", response.GetStringRef()); + + // The functions should still terminate (after a timeout). + ASSERT_TRUE(async_result.get()); + ASSERT_EQ(eStateInvalid, continue_state.get()); } |