| // Copyright 2023 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef LIB_LD_TEST_LD_REMOTE_PROCESS_TESTS_H_ |
| #define LIB_LD_TEST_LD_REMOTE_PROCESS_TESTS_H_ |
| |
| #include <lib/elfldltl/testing/get-test-data.h> |
| #include <lib/zx/thread.h> |
| #include <lib/zx/vmar.h> |
| #include <lib/zx/vmo.h> |
| |
| #include <initializer_list> |
| #include <optional> |
| #include <string_view> |
| |
| #include <gmock/gmock.h> |
| #include <gtest/gtest.h> |
| |
| #include "ld-load-zircon-process-tests-base.h" |
| |
| namespace ld::testing { |
| |
| class LdRemoteProcessTests : public ::testing::Test, public LdLoadZirconProcessTestsBase { |
| public: |
| LdRemoteProcessTests(); |
| ~LdRemoteProcessTests(); |
| |
| void SetUp() override; |
| |
| void Init(std::initializer_list<std::string_view> args = {}); |
| |
| void Needed(std::initializer_list<std::string_view> names); |
| |
| void Load(std::string_view executable_name); |
| |
| int64_t Run(); |
| |
| protected: |
| const zx::vmar& root_vmar() { return root_vmar_; } |
| |
| void set_entry(uintptr_t entry) { entry_ = entry; } |
| |
| void set_vdso_base(uintptr_t vdso_base) { vdso_base_ = vdso_base; } |
| |
| void set_stack_size(std::optional<size_t> stack_size) { stack_size_ = stack_size; } |
| |
| private: |
| class MockLoader; |
| |
| uintptr_t entry_ = 0; |
| uintptr_t vdso_base_ = 0; |
| std::optional<size_t> stack_size_; |
| zx::vmar root_vmar_; |
| zx::thread thread_; |
| |
| std::unique_ptr<MockLoader> mock_loader_; |
| }; |
| } // namespace ld::testing |
| |
| #endif // LIB_LD_TEST_LD_REMOTE_PROCESS_TESTS_H_ |