[NFC][MLIR][Linalg] Refactor linalg.matmul tablegen ODS and related C++ code. (#116377)
[llvm-project.git] / llvm / unittests / ExecutionEngine / JITLink / MemoryManagerErrorTests.cpp
blob2b303f7a8c1a2985d7ad27e341bc62cfaea5fad9
1 //===---- MemoryManagerErrorTests.cpp - Test memory manager error paths ---===//
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 "JITLinkTestUtils.h"
10 #include "llvm/ExecutionEngine/JITLink/MachO_x86_64.h"
12 #include "llvm/Testing/Support/Error.h"
13 #include "gtest/gtest.h"
15 using namespace llvm;
16 using namespace llvm::orc;
17 using namespace llvm::jitlink;
19 TEST(MemoryManagerErrorTest, ErrorOnFirstAllocate) {
20 // Check that we can get addresses for blocks, symbols, and edges.
21 auto G = std::make_unique<LinkGraph>("foo", Triple("x86_64-apple-darwin"), 8,
22 llvm::endianness::little,
23 getGenericEdgeKindName);
25 ArrayRef<char> Content = "hello, world!";
26 auto &Sec =
27 G->createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
28 orc::ExecutorAddr B1Addr(0x1000);
29 auto &B = G->createContentBlock(Sec, Content, B1Addr, 8, 0);
30 G->addDefinedSymbol(B, 4, "S", 4, Linkage::Strong, Scope::Default, false,
31 false);
33 Error Err = Error::success();
34 auto Ctx = makeMockContext(
35 JoinErrorsInto(Err),
36 [](MockJITLinkMemoryManager &MemMgr) {
37 MemMgr.Allocate = [](const JITLinkDylib *JD, LinkGraph &G) {
38 return make_error<StringError>("Failed to allocate",
39 inconvertibleErrorCode());
42 defaultCtxSetup);
44 link_MachO_x86_64(std::move(G), std::move(Ctx));
46 EXPECT_THAT_ERROR(std::move(Err), Failed());