[llvm] [orc-rt] Fix unittests after 53a1e056f38. (PR #186711)

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 15 15:51:51 PDT 2026


https://github.com/lhames created https://github.com/llvm/llvm-project/pull/186711

Updates unittests to reflect Service interface changes.

>From f2854aada98520313e4c59992acb62ec6bc8f3a8 Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Mon, 16 Mar 2026 09:49:16 +1100
Subject: [PATCH] [orc-rt] Fix unittests after 53a1e056f38.

Updates unittests to reflect Service interface changes.
---
 orc-rt/unittests/SessionTest.cpp              | 20 +++++++++----------
 .../unittests/SimpleNativeMemoryMapTest.cpp   | 18 +++++++++++------
 2 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/orc-rt/unittests/SessionTest.cpp b/orc-rt/unittests/SessionTest.cpp
index ecf632d4eb4e4..d4ff1a96f5c01 100644
--- a/orc-rt/unittests/SessionTest.cpp
+++ b/orc-rt/unittests/SessionTest.cpp
@@ -30,42 +30,40 @@ class MockService : public Service {
 public:
   enum class Op { Detach, Shutdown };
 
-  static Error alwaysSucceed(Op) { return Error::success(); }
+  static void noop(Op) {}
 
   MockService(std::optional<size_t> &DetachOpIdx,
               std::optional<size_t> &ShutdownOpIdx, size_t &OpIdx,
-              move_only_function<Error(Op)> GenResult = alwaysSucceed)
+              move_only_function<void(Op)> GenResult = noop)
       : DetachOpIdx(DetachOpIdx), ShutdownOpIdx(ShutdownOpIdx), OpIdx(OpIdx),
         GenResult(std::move(GenResult)) {}
 
   void onDetach(OnCompleteFn OnComplete) override {
     DetachOpIdx = OpIdx++;
-    OnComplete(GenResult(Op::Detach));
+    GenResult(Op::Detach);
+    OnComplete();
   }
 
   void onShutdown(OnCompleteFn OnComplete) override {
     ShutdownOpIdx = OpIdx++;
-    OnComplete(GenResult(Op::Shutdown));
+    GenResult(Op::Shutdown);
+    OnComplete();
   }
 
 private:
   std::optional<size_t> &DetachOpIdx;
   std::optional<size_t> &ShutdownOpIdx;
   size_t &OpIdx;
-  move_only_function<Error(Op)> GenResult;
+  move_only_function<void(Op)> GenResult;
 };
 
 class ConfigurableService : public Service {
 public:
   ConfigurableService(int ConstructorOption) {}
 
-  void onDetach(OnCompleteFn OnComplete) override {
-    OnComplete(Error::success());
-  }
+  void onDetach(OnCompleteFn OnComplete) override { OnComplete(); }
 
-  void onShutdown(OnCompleteFn OnComplete) override {
-    OnComplete(Error::success());
-  }
+  void onShutdown(OnCompleteFn OnComplete) override { OnComplete(); }
 
   void doMoreConfig(int) noexcept {}
 };
diff --git a/orc-rt/unittests/SimpleNativeMemoryMapTest.cpp b/orc-rt/unittests/SimpleNativeMemoryMapTest.cpp
index 0191c2e27cd21..cb9da7addedb2 100644
--- a/orc-rt/unittests/SimpleNativeMemoryMapTest.cpp
+++ b/orc-rt/unittests/SimpleNativeMemoryMapTest.cpp
@@ -91,6 +91,12 @@ template <typename T> move_only_function<void(T)> waitFor(std::future<T> &F) {
   return [P = std::move(P)](T Val) mutable { P.set_value(std::move(Val)); };
 }
 
+move_only_function<void()> waitFor(std::future<void> &F) {
+  std::promise<void> P;
+  F = P.get_future();
+  return [P = std::move(P)]() mutable { P.set_value(); };
+}
+
 TEST(SimpleNativeMemoryMapTest, CreateAndDestroy) {
   // Test that we can create and destroy a SimpleNativeMemoryMap instance as
   // expected.
@@ -288,9 +294,9 @@ TEST(SimpleNativeMemoryMap, ReserveInitializeShutdown) {
 
   EXPECT_EQ(SentinelValue, 0U);
 
-  std::future<Error> ShutdownResult;
+  std::future<void> ShutdownResult;
   SNMM->onShutdown(waitFor(ShutdownResult));
-  cantFail(ShutdownResult.get());
+  ShutdownResult.get();
 
   EXPECT_EQ(SentinelValue, 42);
 }
@@ -325,15 +331,15 @@ TEST(SimpleNativeMemoryMap, ReserveInitializeDetachShutdown) {
 
   EXPECT_EQ(SentinelValue, 0U);
 
-  std::future<Error> DetachResult;
+  std::future<void> DetachResult;
   SNMM->onDetach(waitFor(DetachResult));
-  cantFail(DetachResult.get());
+  DetachResult.get();
 
   EXPECT_EQ(SentinelValue, 0);
 
-  std::future<Error> ShutdownResult;
+  std::future<void> ShutdownResult;
   SNMM->onShutdown(waitFor(ShutdownResult));
-  cantFail(ShutdownResult.get());
+  ShutdownResult.get();
 
   EXPECT_EQ(SentinelValue, 42);
 }



More information about the llvm-commits mailing list