[flang] Fix length handling in character kind implicit conversion (#74586)
[llvm-project.git] / lldb / unittests / Target / RemoteAwarePlatformTest.cpp
blobc36bd35c819dd9d623eee213f832f897f27ea473
1 //===-- RemoteAwarePlatformTest.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 //===----------------------------------------------------------------------===//
9 #include "lldb/Target/RemoteAwarePlatform.h"
10 #include "lldb/Core/Debugger.h"
11 #include "lldb/Core/Module.h"
12 #include "lldb/Core/ModuleSpec.h"
13 #include "lldb/Host/FileSystem.h"
14 #include "lldb/Target/Platform.h"
15 #include "lldb/Target/Process.h"
16 #include "gmock/gmock.h"
17 #include "gtest/gtest.h"
19 using namespace lldb_private;
20 using namespace lldb;
21 using namespace testing;
23 class RemoteAwarePlatformTester : public RemoteAwarePlatform {
24 public:
25 using RemoteAwarePlatform::RemoteAwarePlatform;
27 MOCK_METHOD0(GetDescription, llvm::StringRef());
28 MOCK_METHOD0(GetPluginName, llvm::StringRef());
29 MOCK_METHOD1(GetSupportedArchitectures,
30 std::vector<ArchSpec>(const ArchSpec &process_host_arch));
31 MOCK_METHOD4(Attach,
32 ProcessSP(ProcessAttachInfo &, Debugger &, Target *, Status &));
33 MOCK_METHOD0(CalculateTrapHandlerSymbolNames, void());
35 MOCK_METHOD2(ResolveRemoteExecutable,
36 std::pair<Status, ModuleSP>(const ModuleSpec &,
37 const FileSpecList *));
38 Status ResolveRemoteExecutable(
39 const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
40 const FileSpecList *module_search_paths_ptr) /*override*/
41 { // NOLINT(modernize-use-override)
42 auto pair = ResolveRemoteExecutable(module_spec, module_search_paths_ptr);
43 exe_module_sp = pair.second;
44 return pair.first;
47 void SetRemotePlatform(lldb::PlatformSP platform) {
48 m_remote_platform_sp = platform;
52 class TargetPlatformTester : public Platform {
53 public:
54 using Platform::Platform;
56 MOCK_METHOD0(GetDescription, llvm::StringRef());
57 MOCK_METHOD0(GetPluginName, llvm::StringRef());
58 MOCK_METHOD1(GetSupportedArchitectures,
59 std::vector<ArchSpec>(const ArchSpec &process_host_arch));
60 MOCK_METHOD4(Attach,
61 ProcessSP(ProcessAttachInfo &, Debugger &, Target *, Status &));
62 MOCK_METHOD0(CalculateTrapHandlerSymbolNames, void());
63 MOCK_METHOD0(GetUserIDResolver, UserIDResolver &());
66 namespace {
67 class RemoteAwarePlatformTest : public testing::Test {
68 public:
69 static void SetUpTestCase() { FileSystem::Initialize(); }
70 static void TearDownTestCase() { FileSystem::Terminate(); }
72 } // namespace
74 TEST_F(RemoteAwarePlatformTest, TestResolveExecutabelOnClientByPlatform) {
75 ModuleSpec executable_spec;
76 ModuleSP expected_executable(new Module(executable_spec));
78 RemoteAwarePlatformTester platform(false);
79 static const ArchSpec process_host_arch;
80 EXPECT_CALL(platform, GetSupportedArchitectures(process_host_arch))
81 .WillRepeatedly(Return(std::vector<ArchSpec>()));
82 EXPECT_CALL(platform, ResolveRemoteExecutable(_, _))
83 .WillRepeatedly(Return(std::make_pair(Status(), expected_executable)));
85 platform.SetRemotePlatform(std::make_shared<TargetPlatformTester>(false));
87 ModuleSP resolved_sp;
88 lldb_private::Status status =
89 platform.ResolveExecutable(executable_spec, resolved_sp, nullptr);
91 ASSERT_TRUE(status.Success());
92 EXPECT_EQ(expected_executable.get(), resolved_sp.get());