From 4dfbee4abbb77f032a787a444b59c5abdb64a65a Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 1 Sep 2020 12:10:23 -0700 Subject: [PATCH] [ORC] Add unit test for HasMaterializationSideEffectsOnly failure behavior. --- .../ExecutionEngine/Orc/CoreAPIsTest.cpp | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp index 5a83e6a2b04..2c008dfdbd3 100644 --- a/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp +++ b/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp @@ -110,7 +110,7 @@ TEST_F(CoreAPIsStandardTest, ResolveUnrequestedSymbol) { EXPECT_TRUE(Result.count(Foo)) << "Expected result for \"Foo\""; } -TEST_F(CoreAPIsStandardTest, MaterializationSideEffctsOnlyTest) { +TEST_F(CoreAPIsStandardTest, MaterializationSideEffctsOnlyBasic) { // Test that basic materialization-side-effects-only symbols work as expected: // that they can be emitted without being resolved, that queries for them // don't return until they're emitted, and that they don't appear in query @@ -147,6 +147,24 @@ TEST_F(CoreAPIsStandardTest, MaterializationSideEffctsOnlyTest) { EXPECT_TRUE(Result->empty()) << "Lookup result contained unexpected value"; } +TEST_F(CoreAPIsStandardTest, MaterializationSideEffectsOnlyFailuresPersist) { + // Test that when a MaterializationSideEffectsOnly symbol is failed it + // remains in the failure state rather than vanishing. + + cantFail(JD.define(std::make_unique( + SymbolFlagsMap( + {{Foo, JITSymbolFlags::Exported | + JITSymbolFlags::MaterializationSideEffectsOnly}}), + [&](MaterializationResponsibility R) { R.failMaterialization(); }))); + + EXPECT_THAT_EXPECTED( + ES.lookup(makeJITDylibSearchOrder(&JD), SymbolLookupSet({Foo})), + Failed()); + EXPECT_THAT_EXPECTED( + ES.lookup(makeJITDylibSearchOrder(&JD), SymbolLookupSet({Foo})), + Failed()); +} + TEST_F(CoreAPIsStandardTest, RemoveSymbolsTest) { // Test that: // (1) Missing symbols generate a SymbolsNotFound error.