diff options
| author | Pavel Labath <labath@google.com> | 2018-01-30 12:19:34 +0000 |
|---|---|---|
| committer | Pavel Labath <labath@google.com> | 2018-01-30 12:19:34 +0000 |
| commit | c561a6a920dbf0a53203fafcc6e0c470c840c41a (patch) | |
| tree | b7670b0a1bfe766da1204c874853e2708c4428b5 /lldb/unittests/Utility/LogTest.cpp | |
| parent | eb07016156237790a9949338b6c0ecf33884605f (diff) | |
| download | bcm5719-llvm-c561a6a920dbf0a53203fafcc6e0c470c840c41a.tar.gz bcm5719-llvm-c561a6a920dbf0a53203fafcc6e0c470c840c41a.zip | |
Add LLDB_LOG_ERROR macro
Summary:
The difference between this and regular LLDB_LOG is that this one clears
the error object unconditionally. This was inspired by the
ObjectFileELF bug (r322664), where the error object was being cleared
only if logging was enabled.
Reviewers: davide, zturner, jingham, clayborg
Subscribers: lldb-commits, emaste
Differential Revision: https://reviews.llvm.org/D42182
llvm-svn: 323753
Diffstat (limited to 'lldb/unittests/Utility/LogTest.cpp')
| -rw-r--r-- | lldb/unittests/Utility/LogTest.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lldb/unittests/Utility/LogTest.cpp b/lldb/unittests/Utility/LogTest.cpp index f4c2ba90189..81fdce6efa3 100644 --- a/lldb/unittests/Utility/LogTest.cpp +++ b/lldb/unittests/Utility/LogTest.cpp @@ -240,6 +240,23 @@ TEST_F(LogChannelEnabledTest, log_options) { logAndTakeOutput("Hello World")); } +TEST_F(LogChannelEnabledTest, LLDB_LOG_ERROR) { + LLDB_LOG_ERROR(getLog(), llvm::Error::success(), "Foo failed: {0}"); + ASSERT_EQ("", takeOutput()); + + LLDB_LOG_ERROR(getLog(), + llvm::make_error<llvm::StringError>( + "My Error", llvm::inconvertibleErrorCode()), + "Foo failed: {0}"); + ASSERT_EQ("Foo failed: My Error\n", takeOutput()); + + // Doesn't log, but doesn't assert either + LLDB_LOG_ERROR(nullptr, + llvm::make_error<llvm::StringError>( + "My Error", llvm::inconvertibleErrorCode()), + "Foo failed: {0}"); +} + TEST_F(LogChannelEnabledTest, LogThread) { // Test that we are able to concurrently write to a log channel and disable // it. |

