summaryrefslogtreecommitdiff
path: root/lldb/unittests/Platform
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2018-10-25 15:30:43 +0000
committerAdrian Prantl <aprantl@apple.com>2018-10-25 15:30:43 +0000
commitc6f1754ce7a29ecbfecf7c7898b29982fdd71e7e (patch)
treec2436add4b365d036b9b57e504b6e51897daf9ac /lldb/unittests/Platform
parentc63e4e713bf1c37c0b1dee749ba384800b9dd97d (diff)
Fix a bug PlatformDarwin::SDKSupportsModule.
This fixes a bug PlatformDarwin::SDKSupportsModule introduced by https://reviews.llvm.org/D47889. VersionTuple::tryParse() can deal with an optional third (micro) component, but the parse will fail when there are extra characters after the version number (e.g.: trying to parse the substring "12.0.sdk" out of "iPhoneSimulator12.0.sdk" fails after that patch). Fixed here by stripping the ".sdk" suffix first. (Part of) rdar://problem/45041492 Differential Revision https://reviews.llvm.org/D53677
Diffstat (limited to 'lldb/unittests/Platform')
-rw-r--r--lldb/unittests/Platform/PlatformDarwinTest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/lldb/unittests/Platform/PlatformDarwinTest.cpp b/lldb/unittests/Platform/PlatformDarwinTest.cpp
index 18cd1b76997..c0a9aef99ef 100644
--- a/lldb/unittests/Platform/PlatformDarwinTest.cpp
+++ b/lldb/unittests/Platform/PlatformDarwinTest.cpp
@@ -18,6 +18,13 @@
using namespace lldb;
using namespace lldb_private;
+struct PlatformDarwinTester : public PlatformDarwin {
+ static bool SDKSupportsModules(SDKType desired_type,
+ const lldb_private::FileSpec &sdk_path) {
+ return PlatformDarwin::SDKSupportsModules(desired_type, sdk_path);
+ }
+};
+
TEST(PlatformDarwinTest, TestParseVersionBuildDir) {
llvm::VersionTuple V;
llvm::StringRef D;
@@ -44,4 +51,23 @@ TEST(PlatformDarwinTest, TestParseVersionBuildDir) {
std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("3.4.5");
EXPECT_EQ(llvm::VersionTuple(3, 4, 5), V);
+
+ std::string base = "/Applications/Xcode.app/Contents/Developer/Platforms/";
+ EXPECT_TRUE(PlatformDarwinTester::SDKSupportsModules(
+ PlatformDarwin::SDKType::iPhoneSimulator,
+ FileSpec(base +
+ "iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk",
+ false)));
+ EXPECT_FALSE(PlatformDarwinTester::SDKSupportsModules(
+ PlatformDarwin::SDKType::iPhoneSimulator,
+ FileSpec(base +
+ "iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.2.sdk",
+ false)));
+ EXPECT_TRUE(PlatformDarwinTester::SDKSupportsModules(
+ PlatformDarwin::SDKType::MacOSX,
+ FileSpec(base + "MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk",
+ false)));
+ EXPECT_FALSE(PlatformDarwinTester::SDKSupportsModules(
+ PlatformDarwin::SDKType::MacOSX,
+ FileSpec(base + "MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk", false)));
}