aboutsummaryrefslogtreecommitdiff
path: root/lldb/unittests/Platform/PlatformMacOSXTest.cpp
blob: 123fdbc39d672acd3273227d7c0d6a22ece59cb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//===-- PlatformMacOSXTest.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "gtest/gtest.h"

#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
#include "TestingSupport/SubsystemRAII.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/Platform.h"

using namespace lldb;
using namespace lldb_private;

class PlatformMacOSXTest : public ::testing::Test {
  SubsystemRAII<FileSystem, HostInfo, PlatformMacOSX> subsystems;
};

#ifdef __APPLE__
static bool containsArch(const std::vector<ArchSpec> &archs,
                         const ArchSpec &arch) {
  return std::find_if(archs.begin(), archs.end(), [&](const ArchSpec &other) {
           return arch.IsExactMatch(other);
         }) != archs.end();
}

TEST_F(PlatformMacOSXTest, TestGetSupportedArchitectures) {
  PlatformMacOSX platform;

  const ArchSpec x86_macosx_arch("x86_64-apple-macosx");

  EXPECT_TRUE(containsArch(platform.GetSupportedArchitectures(x86_macosx_arch),
                           x86_macosx_arch));
  EXPECT_TRUE(
      containsArch(platform.GetSupportedArchitectures({}), x86_macosx_arch));

#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
  const ArchSpec arm64_macosx_arch("arm64-apple-macosx");
  const ArchSpec arm64_ios_arch("arm64-apple-ios");

  EXPECT_TRUE(containsArch(
      platform.GetSupportedArchitectures(arm64_macosx_arch), arm64_ios_arch));
  EXPECT_TRUE(
      containsArch(platform.GetSupportedArchitectures({}), arm64_ios_arch));
  EXPECT_FALSE(containsArch(platform.GetSupportedArchitectures(arm64_ios_arch),
                            arm64_ios_arch));
#endif
}
#endif