blob: fb6c38b4bae949cd650b1d770d254be5a713d625 [file] [edit]
//===-------------- EPCGenericDylibManagerTest.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 "OrcTestCommon.h"
#include "llvm/ExecutionEngine/Orc/EPCGenericDylibManagerSPS.h"
#include "llvm/ExecutionEngine/Orc/Shared/Mangler.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/Shared/SPSCI/NativeDylibManagerSPSCI.h"
#include "llvm/Testing/Support/Error.h"
using namespace llvm;
using namespace llvm::orc;
namespace {
TEST(EPCGenericDylibManagerTest, CreateFromExecutionSession) {
// Verify that Create(ExecutionSession&) looks up symbols in the bootstrap
// JITDylib using the default NativeDylibManager symbol names.
class EPCWithBootstrapSymbols : public UnsupportedExecutorProcessControl {
public:
EPCWithBootstrapSymbols(std::shared_ptr<SymbolStringPool> SSP,
StringMap<ExecutorAddr> BS)
: UnsupportedExecutorProcessControl(std::move(SSP), nullptr,
sys::getProcessTriple()) {
this->BootstrapSymbols = std::move(BS);
}
};
ExecutorAddr InstanceAddr(1), OpenAddr(2), ResolveAddr(3);
StringMap<ExecutorAddr> BootstrapSyms;
Mangler Mangle{Triple(sys::getProcessTriple())};
BootstrapSyms[Mangle.mangledCopy(
rt::sps_ci::NativeDylibManagerInstanceName)] = InstanceAddr;
BootstrapSyms[Mangle.mangledCopy(rt::sps_ci::DylibMgrOpen::Name)] = OpenAddr;
BootstrapSyms[Mangle.mangledCopy(rt::sps_ci::DylibMgrResolve::Name)] =
ResolveAddr;
auto SSP = std::make_shared<SymbolStringPool>();
auto EPC =
std::make_unique<EPCWithBootstrapSymbols>(SSP, std::move(BootstrapSyms));
ExecutionSession ES(std::move(EPC));
auto Result = sps::createEPCGenericDylibManager(ES);
EXPECT_THAT_EXPECTED(Result, Succeeded());
cantFail(ES.endSession());
}
} // namespace