diff options
author | Anthony Ha <anthonyha96@gmail.com> | 2024-05-09 15:57:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-09 15:57:46 -0700 |
commit | 95f208f97e709139c3ecbce552bcf1e34b9fcf12 (patch) | |
tree | f39d0f3cccfb24b119e142f44832c37936d69e87 /lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp | |
parent | 1e97d114b5b2b522de7e0aa9c950199de0798d53 (diff) | |
download | llvm-95f208f97e709139c3ecbce552bcf1e34b9fcf12.zip llvm-95f208f97e709139c3ecbce552bcf1e34b9fcf12.tar.gz llvm-95f208f97e709139c3ecbce552bcf1e34b9fcf12.tar.bz2 |
[lldb] Unify CalculateMD5 return types (#91029)
This is a retake of https://github.com/llvm/llvm-project/pull/90921
which got reverted because I forgot to modify the CalculateMD5 unit test
I had added in https://github.com/llvm/llvm-project/pull/88812
The prior failing build is here:
https://lab.llvm.org/buildbot/#/builders/68/builds/73622
To make sure this error doesn't happen, I ran `ninja
ProcessGdbRemoteTests` and then executed the resulting test binary and
observed the `CalculateMD5` test passed.
# Overview
In my previous PR: https://github.com/llvm/llvm-project/pull/88812,
@JDevlieghere suggested to match return types of the various calculate
md5 functions.
This PR achieves that by changing the various calculate md5 functions to
return `llvm::ErrorOr<llvm::MD5::MD5Result>`.
The suggestion was to go for `std::optional<>` but I opted for
`llvm::ErrorOr<>` because local calculate md5 was already possibly
returning `ErrorOr`.
To make sure I didn't break the md5 calculation functionality, I ran
some tests for the gdb remote client, and things seem to work.
# Testing
1. Remote file doesn't exist

1. Remote file differs

1. Remote file matches

## Test gaps
Unfortunately, I had to modify
`lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp` and I
can't test the changes there. Hopefully, the existing test suite / code
review from whomever is reading this will catch any issues.
Diffstat (limited to 'lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp')
-rw-r--r-- | lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp index 6b11ec4..2411139 100644 --- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -595,10 +595,8 @@ TEST_F(GDBRemoteCommunicationClientTest, WriteMemoryTags) { TEST_F(GDBRemoteCommunicationClientTest, CalculateMD5) { FileSpec file_spec("/foo/bar", FileSpec::Style::posix); - uint64_t low, high; - std::future<bool> async_result = std::async(std::launch::async, [&] { - return client.CalculateMD5(file_spec, low, high); - }); + std::future<ErrorOr<MD5::MD5Result>> async_result = std::async( + std::launch::async, [&] { return client.CalculateMD5(file_spec); }); lldb_private::StreamString stream; stream.PutCString("vFile:MD5:"); @@ -607,11 +605,12 @@ TEST_F(GDBRemoteCommunicationClientTest, CalculateMD5) { "F," "deadbeef01020304" "05060708deadbeef"); - ASSERT_TRUE(async_result.get()); + auto result = async_result.get(); // Server and client puts/parses low, and then high const uint64_t expected_low = 0xdeadbeef01020304; const uint64_t expected_high = 0x05060708deadbeef; - EXPECT_EQ(expected_low, low); - EXPECT_EQ(expected_high, high); + ASSERT_TRUE(result); + EXPECT_EQ(expected_low, result->low()); + EXPECT_EQ(expected_high, result->high()); } |