From c561a6a920dbf0a53203fafcc6e0c470c840c41a Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 30 Jan 2018 12:19:34 +0000 Subject: 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 --- lldb/unittests/Utility/LogTest.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lldb/unittests/Utility/LogTest.cpp') 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( + "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( + "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. -- cgit v1.2.3