diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:12:36 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:12:36 +0000 |
commit | ef5d0b5e97ec8e6fa395d377b09aa7755e345b4f (patch) | |
tree | 27916256fdeeb57d10d2f3d6948be5d71a703215 /unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp | |
parent | 76e0736e7fcfeb179779e49c05604464b1ccd704 (diff) |
Notes
Diffstat (limited to 'unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp')
-rw-r--r-- | unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp b/unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp index 961b0a3b3167c..6ff777bd17abf 100644 --- a/unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp +++ b/unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp @@ -7,38 +7,33 @@ // //===----------------------------------------------------------------------===// +#include "TestBase.h" #include "TestClient.h" +#include "llvm/Support/Path.h" +#include "llvm/Testing/Support/Error.h" #include "gtest/gtest.h" #include <string> using namespace llgs_tests; +using namespace llvm; -class ThreadsInJstopinfoTest : public ::testing::Test { -protected: - virtual void SetUp() { TestClient::Initialize(); } -}; +TEST_F(StandardStartupTest, TestStopReplyContainsThreadPcs) { + // This inferior spawns 4 threads, then forces a break. + ASSERT_THAT_ERROR( + Client->SetInferior({getInferiorPath("thread_inferior"), "4"}), + Succeeded()); -TEST_F(ThreadsInJstopinfoTest, TestStopReplyContainsThreadPcsLlgs) { - std::vector<std::string> inferior_args; - // This inferior spawns N threads, then forces a break. - inferior_args.push_back(THREAD_INFERIOR); - inferior_args.push_back("4"); - - auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); - - TestClient client(test_info->name(), test_info->test_case_name()); - ASSERT_TRUE(client.StartDebugger()); - ASSERT_TRUE(client.SetInferior(inferior_args)); - ASSERT_TRUE(client.ListThreadsInStopReply()); - ASSERT_TRUE(client.ContinueAll()); - unsigned int pc_reg = client.GetPcRegisterId(); + ASSERT_THAT_ERROR(Client->ListThreadsInStopReply(), Succeeded()); + ASSERT_THAT_ERROR(Client->ContinueAll(), Succeeded()); + unsigned int pc_reg = Client->GetPcRegisterId(); ASSERT_NE(pc_reg, UINT_MAX); - auto jthreads_info = client.GetJThreadsInfo(); + auto jthreads_info = Client->GetJThreadsInfo(); ASSERT_TRUE(jthreads_info); - auto stop_reply = client.GetLatestStopReply(); - auto stop_reply_pcs = stop_reply.GetThreadPcs(); + auto stop_reply = Client->GetLatestStopReplyAs<StopReplyStop>(); + ASSERT_THAT_EXPECTED(stop_reply, Succeeded()); + auto stop_reply_pcs = stop_reply->getThreadPcs(); auto thread_infos = jthreads_info->GetThreadInfos(); ASSERT_EQ(stop_reply_pcs.size(), thread_infos.size()) << "Thread count mismatch."; @@ -47,12 +42,9 @@ TEST_F(ThreadsInJstopinfoTest, TestStopReplyContainsThreadPcsLlgs) { unsigned long tid = stop_reply_pc.first; ASSERT_TRUE(thread_infos.find(tid) != thread_infos.end()) << "Thread ID: " << tid << " not in JThreadsInfo."; - uint64_t pc_value; - ASSERT_TRUE(thread_infos[tid].ReadRegisterAsUint64(pc_reg, pc_value)) - << "Failure reading ThreadInfo register " << pc_reg; - ASSERT_EQ(stop_reply_pcs[tid], pc_value) + auto pc_value = thread_infos[tid].ReadRegisterAsUint64(pc_reg); + ASSERT_THAT_EXPECTED(pc_value, Succeeded()); + ASSERT_EQ(stop_reply_pcs[tid], *pc_value) << "Mismatched PC for thread: " << tid; } - - ASSERT_TRUE(client.StopDebugger()); } |