1 //===-- PlatformDarwinTest.cpp --------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "gtest/gtest.h" 10 11 #include "Plugins/Platform/MacOSX/PlatformDarwin.h" 12 13 #include "llvm/ADT/StringRef.h" 14 15 #include <tuple> 16 17 using namespace lldb; 18 using namespace lldb_private; 19 20 struct PlatformDarwinTester : public PlatformDarwin { 21 static bool SDKSupportsModules(SDKType desired_type, 22 const lldb_private::FileSpec &sdk_path) { 23 return PlatformDarwin::SDKSupportsModules(desired_type, sdk_path); 24 } 25 }; 26 27 TEST(PlatformDarwinTest, TestParseVersionBuildDir) { 28 llvm::VersionTuple V; 29 llvm::StringRef D; 30 31 std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("1.2.3 (test1)"); 32 EXPECT_EQ(llvm::VersionTuple(1, 2, 3), V); 33 EXPECT_EQ("test1", D); 34 35 std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("2.3 (test2)"); 36 EXPECT_EQ(llvm::VersionTuple(2, 3), V); 37 EXPECT_EQ("test2", D); 38 39 std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("3 (test3)"); 40 EXPECT_EQ(llvm::VersionTuple(3), V); 41 EXPECT_EQ("test3", D); 42 43 std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("1.2.3 (test"); 44 EXPECT_EQ(llvm::VersionTuple(1, 2, 3), V); 45 EXPECT_EQ("test", D); 46 47 std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("2.3.4 test"); 48 EXPECT_EQ(llvm::VersionTuple(2, 3, 4), V); 49 EXPECT_EQ("", D); 50 51 std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("3.4.5"); 52 EXPECT_EQ(llvm::VersionTuple(3, 4, 5), V); 53 54 std::string base = "/Applications/Xcode.app/Contents/Developer/Platforms/"; 55 EXPECT_TRUE(PlatformDarwinTester::SDKSupportsModules( 56 PlatformDarwin::SDKType::iPhoneSimulator, 57 FileSpec( 58 base + 59 "iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk"))); 60 EXPECT_FALSE(PlatformDarwinTester::SDKSupportsModules( 61 PlatformDarwin::SDKType::iPhoneSimulator, 62 FileSpec( 63 base + 64 "iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.2.sdk"))); 65 EXPECT_TRUE(PlatformDarwinTester::SDKSupportsModules( 66 PlatformDarwin::SDKType::MacOSX, 67 FileSpec(base + "MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk"))); 68 EXPECT_FALSE(PlatformDarwinTester::SDKSupportsModules( 69 PlatformDarwin::SDKType::MacOSX, 70 FileSpec(base + "MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk"))); 71 } 72