1 //===-- PlatformMacOSXTest.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/PlatformMacOSX.h" 12 #include "TestingSupport/SubsystemRAII.h" 13 #include "lldb/Host/FileSystem.h" 14 #include "lldb/Host/HostInfo.h" 15 #include "lldb/Target/Platform.h" 16 17 using namespace lldb; 18 using namespace lldb_private; 19 20 class PlatformMacOSXTest : public ::testing::Test { 21 SubsystemRAII<FileSystem, HostInfo, PlatformMacOSX> subsystems; 22 }; 23 24 static bool containsArch(const std::vector<ArchSpec> &archs, 25 const ArchSpec &arch) { 26 return std::find_if(archs.begin(), archs.end(), [&](const ArchSpec &other) { 27 return arch.IsExactMatch(other); 28 }) != archs.end(); 29 } 30 31 TEST_F(PlatformMacOSXTest, TestGetSupportedArchitectures) { 32 PlatformMacOSX platform; 33 34 const ArchSpec x86_macosx_arch("x86_64-apple-macosx"); 35 36 EXPECT_TRUE(containsArch(platform.GetSupportedArchitectures(x86_macosx_arch), 37 x86_macosx_arch)); 38 EXPECT_TRUE( 39 containsArch(platform.GetSupportedArchitectures({}), x86_macosx_arch)); 40 41 #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__) 42 const ArchSpec arm64_macosx_arch("arm64-apple-macosx"); 43 const ArchSpec arm64_ios_arch("arm64-apple-ios"); 44 45 EXPECT_TRUE(containsArch( 46 platform.GetSupportedArchitectures(arm64_macosx_arch), arm64_ios_arch)); 47 EXPECT_TRUE( 48 containsArch(platform.GetSupportedArchitectures({}), arm64_ios_arch)); 49 EXPECT_FALSE(containsArch(platform.GetSupportedArchitectures(arm64_ios_arch), 50 arm64_ios_arch)); 51 #endif 52 } 53