From b0df9a366adbf3524aff683a11129a6fed9de59b Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Mon, 16 Mar 2026 10:28:39 +1100 Subject: [PATCH] [orc-rt] Fix unittests after 53a1e056f38. (#186711) 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 ecf632d4eb4e..d4ff1a96f5c0 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 &DetachOpIdx, std::optional &ShutdownOpIdx, size_t &OpIdx, - move_only_function GenResult = alwaysSucceed) + move_only_function 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 &DetachOpIdx; std::optional &ShutdownOpIdx; size_t &OpIdx; - move_only_function GenResult; + move_only_function 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 0191c2e27cd2..cb9da7addedb 100644 --- a/orc-rt/unittests/SimpleNativeMemoryMapTest.cpp +++ b/orc-rt/unittests/SimpleNativeMemoryMapTest.cpp @@ -91,6 +91,12 @@ template move_only_function waitFor(std::future &F) { return [P = std::move(P)](T Val) mutable { P.set_value(std::move(Val)); }; } +move_only_function waitFor(std::future &F) { + std::promise 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 ShutdownResult; + std::future 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 DetachResult; + std::future DetachResult; SNMM->onDetach(waitFor(DetachResult)); - cantFail(DetachResult.get()); + DetachResult.get(); EXPECT_EQ(SentinelValue, 0); - std::future ShutdownResult; + std::future ShutdownResult; SNMM->onShutdown(waitFor(ShutdownResult)); - cantFail(ShutdownResult.get()); + ShutdownResult.get(); EXPECT_EQ(SentinelValue, 42); }