llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp
Lang Hames 972c9575f0 [ORC] Temporarily adding some redundant asserts / debug output to aid in
debugging a tester failure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321920 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-06 01:06:07 +00:00

52 lines
1.5 KiB
C++

//===----------- CoreAPIsTest.cpp - Unit tests for Core ORC APIs ----------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "OrcTestCommon.h"
#include "gtest/gtest.h"
using namespace llvm;
using namespace llvm::orc;
namespace {
TEST(CoreAPIsTest, AsynchronousSymbolQuerySuccessfulResolutionOnly) {
SymbolStringPool SP;
auto Foo = SP.intern("foo");
constexpr JITTargetAddress FakeAddr = 0xdeadbeef;
SymbolNameSet Names({Foo});
bool OnResolutionRun = false;
bool OnReadyRun = false;
auto OnResolution =
[&](Expected<SymbolMap> Result) {
EXPECT_TRUE(!!Result) << "Resolution unexpectedly returned error";
auto I = Result->find(Foo);
EXPECT_NE(I, Result->end()) << "Could not find symbol definition";
EXPECT_EQ(cantFail(I->second.getAddress()), FakeAddr)
<< "Resolution returned incorrect result";
OnResolutionRun = true;
};
auto OnReady =
[&](Error Err) {
cantFail(std::move(Err));
OnReadyRun = true;
};
AsynchronousSymbolQuery Q(Names, OnResolution, OnReady);
Q.setDefinition(Foo, JITSymbol(FakeAddr, JITSymbolFlags::Exported));
EXPECT_TRUE(OnResolutionRun) << "OnResolutionCallback was not run";
EXPECT_FALSE(OnReadyRun) << "OnReady unexpectedly run";
errs() << "Exiting test\n";
}
}