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