[Lldb-commits] [lldb] r310499 - Fix VASprintfTest.cpp for Darwin, add checks
Tim Hammerquist via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 9 10:27:02 PDT 2017
Author: penryu
Date: Wed Aug 9 10:27:02 2017
New Revision: 310499
URL: http://llvm.org/viewvc/llvm-project?rev=310499&view=rev
Log:
Fix VASprintfTest.cpp for Darwin, add checks
Summary:
The EncodingError test ensures that trying to encode a multibyte wchar
with a given codepage fails. If setlocale() fails, the encoding is
performed using the current locale, which may or may not fail.
This patch asserts that both setlocale() operations are successful, as
well as falling back to a widely available unibyte encoding for
non-Windows systems.
<rdar://problem/33782806>
Reviewers: zturner, labath, lhames
Reviewed By: zturner
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D36496
Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/unittests/Utility/VASprintfTest.cpp
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=310499&r1=310498&r2=310499&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Aug 9 10:27:02 2017
@@ -875,6 +875,7 @@
9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; };
9A1E595C1EB2B141002206A5 /* SBTrace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A1E59521EB2B0B9002206A5 /* SBTrace.cpp */; };
9A1E595D1EB2B141002206A5 /* SBTraceOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A1E59531EB2B0B9002206A5 /* SBTraceOptions.cpp */; };
+ 9A2057031F3A605200F6C293 /* VASprintfTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3D43C41F3150D200EB767C /* VASprintfTest.cpp */; };
9A22A161135E30370024DDC3 /* EmulateInstructionARM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A22A15D135E30370024DDC3 /* EmulateInstructionARM.cpp */; };
9A22A163135E30370024DDC3 /* EmulationStateARM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A22A15F135E30370024DDC3 /* EmulationStateARM.cpp */; };
9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A357582116CFDEE00E8ED2F /* SBValueList.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -7092,6 +7093,7 @@
AFEC5FD81D94F9380076A480 /* Testx86AssemblyInspectionEngine.cpp in Sources */,
23CB15401D66DA9300EDDDE1 /* TestClangASTContext.cpp in Sources */,
23CB15411D66DA9300EDDDE1 /* StringExtractorTest.cpp in Sources */,
+ 9A2057031F3A605200F6C293 /* VASprintfTest.cpp in Sources */,
23CB15421D66DA9300EDDDE1 /* TaskPoolTest.cpp in Sources */,
23CB15431D66DA9300EDDDE1 /* BroadcasterTest.cpp in Sources */,
9A3D43EE1F3237F900EB767C /* StreamCallbackTest.cpp in Sources */,
Modified: lldb/trunk/unittests/Utility/VASprintfTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/VASprintfTest.cpp?rev=310499&r1=310498&r2=310499&view=diff
==============================================================================
--- lldb/trunk/unittests/Utility/VASprintfTest.cpp (original)
+++ lldb/trunk/unittests/Utility/VASprintfTest.cpp Wed Aug 9 10:27:02 2017
@@ -14,6 +14,12 @@
#include <locale.h>
+#if defined (_WIN32)
+#define TEST_ENCODING ".932" // On Windows, test codepage 932
+#else
+#define TEST_ENCODING "C" // ...otherwise, any widely available uni-byte LC
+#endif
+
using namespace lldb_private;
using namespace llvm;
@@ -46,7 +52,8 @@ TEST(VASprintfTest, EncodingError) {
// Save the current locale first.
std::string Current(::setlocale(LC_ALL, nullptr));
- setlocale(LC_ALL, ".932");
+ // Ensure tested locale is successfully set
+ ASSERT_TRUE(setlocale(LC_ALL, TEST_ENCODING));
wchar_t Invalid[2];
Invalid[0] = 0x100;
@@ -55,5 +62,6 @@ TEST(VASprintfTest, EncodingError) {
EXPECT_FALSE(Sprintf(Buffer, "%ls", Invalid));
EXPECT_EQ("<Encoding error>", Buffer);
- setlocale(LC_ALL, Current.c_str());
+ // Ensure we've restored the original locale once tested
+ ASSERT_TRUE(setlocale(LC_ALL, Current.c_str()));
}
More information about the lldb-commits
mailing list