[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / unittests / ExecutionEngine / Orc / LookupAndRecordAddrsTest.cpp
blobaff356149f6670d91662ca1f05bc4656e207ff35
1 //===- LookupAndRecordAddrsTest.cpp - Unit tests for LookupAndRecordAddrs -===//
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 "OrcTestCommon.h"
11 #include "llvm/ExecutionEngine/Orc/LookupAndRecordAddrs.h"
12 #include "llvm/Support/MSVCErrorWorkarounds.h"
13 #include "llvm/Testing/Support/Error.h"
15 #include <future>
17 using namespace llvm;
18 using namespace llvm::orc;
20 class LookupAndRecordAddrsTest : public CoreAPIsBasedStandardTest {};
22 namespace {
24 TEST_F(LookupAndRecordAddrsTest, AsyncRequiredSuccess) {
25 cantFail(JD.define(absoluteSymbols({{Foo, FooSym}, {Bar, BarSym}})));
27 ExecutorAddress FooAddress, BarAddress;
28 std::promise<MSVCPError> ErrP;
30 lookupAndRecordAddrs([&](Error Err) { ErrP.set_value(std::move(Err)); }, ES,
31 LookupKind::Static, makeJITDylibSearchOrder(&JD),
32 {{Foo, &FooAddress}, {Bar, &BarAddress}});
34 Error Err = ErrP.get_future().get();
36 EXPECT_THAT_ERROR(std::move(Err), Succeeded());
37 EXPECT_EQ(FooAddress.getValue(), FooAddr);
38 EXPECT_EQ(BarAddress.getValue(), BarAddr);
41 TEST_F(LookupAndRecordAddrsTest, AsyncRequiredFailure) {
42 ExecutorAddress FooAddress, BarAddress;
43 std::promise<MSVCPError> ErrP;
45 lookupAndRecordAddrs([&](Error Err) { ErrP.set_value(std::move(Err)); }, ES,
46 LookupKind::Static, makeJITDylibSearchOrder(&JD),
47 {{Foo, &FooAddress}, {Bar, &BarAddress}});
49 Error Err = ErrP.get_future().get();
51 EXPECT_THAT_ERROR(std::move(Err), Failed());
54 TEST_F(LookupAndRecordAddrsTest, AsyncWeakReference) {
55 cantFail(JD.define(absoluteSymbols({{Foo, FooSym}})));
57 ExecutorAddress FooAddress, BarAddress;
58 std::promise<MSVCPError> ErrP;
60 lookupAndRecordAddrs([&](Error Err) { ErrP.set_value(std::move(Err)); }, ES,
61 LookupKind::Static, makeJITDylibSearchOrder(&JD),
62 {{Foo, &FooAddress}, {Bar, &BarAddress}},
63 SymbolLookupFlags::WeaklyReferencedSymbol);
65 Error Err = ErrP.get_future().get();
67 EXPECT_THAT_ERROR(std::move(Err), Succeeded());
68 EXPECT_EQ(FooAddress.getValue(), FooAddr);
69 EXPECT_EQ(BarAddress.getValue(), 0U);
72 TEST_F(LookupAndRecordAddrsTest, BlockingRequiredSuccess) {
73 cantFail(JD.define(absoluteSymbols({{Foo, FooSym}, {Bar, BarSym}})));
75 ExecutorAddress FooAddress, BarAddress;
76 auto Err =
77 lookupAndRecordAddrs(ES, LookupKind::Static, makeJITDylibSearchOrder(&JD),
78 {{Foo, &FooAddress}, {Bar, &BarAddress}});
80 EXPECT_THAT_ERROR(std::move(Err), Succeeded());
81 EXPECT_EQ(FooAddress.getValue(), FooAddr);
82 EXPECT_EQ(BarAddress.getValue(), BarAddr);
85 TEST_F(LookupAndRecordAddrsTest, BlockingRequiredFailure) {
86 ExecutorAddress FooAddress, BarAddress;
87 auto Err =
88 lookupAndRecordAddrs(ES, LookupKind::Static, makeJITDylibSearchOrder(&JD),
89 {{Foo, &FooAddress}, {Bar, &BarAddress}});
91 EXPECT_THAT_ERROR(std::move(Err), Failed());
94 TEST_F(LookupAndRecordAddrsTest, BlockingWeakReference) {
95 cantFail(JD.define(absoluteSymbols({{Foo, FooSym}})));
97 ExecutorAddress FooAddress, BarAddress;
98 auto Err =
99 lookupAndRecordAddrs(ES, LookupKind::Static, makeJITDylibSearchOrder(&JD),
100 {{Foo, &FooAddress}, {Bar, &BarAddress}},
101 SymbolLookupFlags::WeaklyReferencedSymbol);
103 EXPECT_THAT_ERROR(std::move(Err), Succeeded());
104 EXPECT_EQ(FooAddress.getValue(), FooAddr);
105 EXPECT_EQ(BarAddress.getValue(), 0U);
108 } // namespace