1c22c7a61SJonas Devlieghere //===-- PlatformMacOSXTest.cpp ------------------------------------===//
2c22c7a61SJonas Devlieghere //
3c22c7a61SJonas Devlieghere // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4c22c7a61SJonas Devlieghere // See https://llvm.org/LICENSE.txt for license information.
5c22c7a61SJonas Devlieghere // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6c22c7a61SJonas Devlieghere //
7c22c7a61SJonas Devlieghere //===----------------------------------------------------------------------===//
8c22c7a61SJonas Devlieghere
9c22c7a61SJonas Devlieghere #include "gtest/gtest.h"
10c22c7a61SJonas Devlieghere
11c22c7a61SJonas Devlieghere #include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
12c22c7a61SJonas Devlieghere #include "TestingSupport/SubsystemRAII.h"
13c22c7a61SJonas Devlieghere #include "lldb/Host/FileSystem.h"
14c22c7a61SJonas Devlieghere #include "lldb/Host/HostInfo.h"
15c22c7a61SJonas Devlieghere #include "lldb/Target/Platform.h"
16c22c7a61SJonas Devlieghere
17c22c7a61SJonas Devlieghere using namespace lldb;
18c22c7a61SJonas Devlieghere using namespace lldb_private;
19c22c7a61SJonas Devlieghere
20c22c7a61SJonas Devlieghere class PlatformMacOSXTest : public ::testing::Test {
21c22c7a61SJonas Devlieghere SubsystemRAII<FileSystem, HostInfo, PlatformMacOSX> subsystems;
22c22c7a61SJonas Devlieghere };
23c22c7a61SJonas Devlieghere
24*b783e5c2SJonas Devlieghere #ifdef __APPLE__
containsArch(const std::vector<ArchSpec> & archs,const ArchSpec & arch)25c22c7a61SJonas Devlieghere static bool containsArch(const std::vector<ArchSpec> &archs,
26c22c7a61SJonas Devlieghere const ArchSpec &arch) {
27c22c7a61SJonas Devlieghere return std::find_if(archs.begin(), archs.end(), [&](const ArchSpec &other) {
28c22c7a61SJonas Devlieghere return arch.IsExactMatch(other);
29c22c7a61SJonas Devlieghere }) != archs.end();
30c22c7a61SJonas Devlieghere }
31c22c7a61SJonas Devlieghere
TEST_F(PlatformMacOSXTest,TestGetSupportedArchitectures)32c22c7a61SJonas Devlieghere TEST_F(PlatformMacOSXTest, TestGetSupportedArchitectures) {
33c22c7a61SJonas Devlieghere PlatformMacOSX platform;
34c22c7a61SJonas Devlieghere
35c22c7a61SJonas Devlieghere const ArchSpec x86_macosx_arch("x86_64-apple-macosx");
36c22c7a61SJonas Devlieghere
37c22c7a61SJonas Devlieghere EXPECT_TRUE(containsArch(platform.GetSupportedArchitectures(x86_macosx_arch),
38c22c7a61SJonas Devlieghere x86_macosx_arch));
39c22c7a61SJonas Devlieghere EXPECT_TRUE(
40c22c7a61SJonas Devlieghere containsArch(platform.GetSupportedArchitectures({}), x86_macosx_arch));
41c22c7a61SJonas Devlieghere
42c22c7a61SJonas Devlieghere #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
43c22c7a61SJonas Devlieghere const ArchSpec arm64_macosx_arch("arm64-apple-macosx");
44c22c7a61SJonas Devlieghere const ArchSpec arm64_ios_arch("arm64-apple-ios");
45c22c7a61SJonas Devlieghere
46c22c7a61SJonas Devlieghere EXPECT_TRUE(containsArch(
47c22c7a61SJonas Devlieghere platform.GetSupportedArchitectures(arm64_macosx_arch), arm64_ios_arch));
48c22c7a61SJonas Devlieghere EXPECT_TRUE(
49c22c7a61SJonas Devlieghere containsArch(platform.GetSupportedArchitectures({}), arm64_ios_arch));
50c22c7a61SJonas Devlieghere EXPECT_FALSE(containsArch(platform.GetSupportedArchitectures(arm64_ios_arch),
51c22c7a61SJonas Devlieghere arm64_ios_arch));
52c22c7a61SJonas Devlieghere #endif
53c22c7a61SJonas Devlieghere }
54*b783e5c2SJonas Devlieghere #endif
55