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 #ifdef __APPLE__ 25 static bool containsArch(const std::vector<ArchSpec> &archs, 26 const ArchSpec &arch) { 27 return std::find_if(archs.begin(), archs.end(), [&](const ArchSpec &other) { 28 return arch.IsExactMatch(other); 29 }) != archs.end(); 30 } 31 32 TEST_F(PlatformMacOSXTest, TestGetSupportedArchitectures) { 33 PlatformMacOSX platform; 34 35 const ArchSpec x86_macosx_arch("x86_64-apple-macosx"); 36 37 EXPECT_TRUE(containsArch(platform.GetSupportedArchitectures(x86_macosx_arch), 38 x86_macosx_arch)); 39 EXPECT_TRUE( 40 containsArch(platform.GetSupportedArchitectures({}), x86_macosx_arch)); 41 42 #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__) 43 const ArchSpec arm64_macosx_arch("arm64-apple-macosx"); 44 const ArchSpec arm64_ios_arch("arm64-apple-ios"); 45 46 EXPECT_TRUE(containsArch( 47 platform.GetSupportedArchitectures(arm64_macosx_arch), arm64_ios_arch)); 48 EXPECT_TRUE( 49 containsArch(platform.GetSupportedArchitectures({}), arm64_ios_arch)); 50 EXPECT_FALSE(containsArch(platform.GetSupportedArchitectures(arm64_ios_arch), 51 arm64_ios_arch)); 52 #endif 53 } 54 #endif 55