From 3f410302449c24c4e7e354a5fc629a16f13a9cae Mon Sep 17 00:00:00 2001 From: Matan Breizman Date: Mon, 7 Apr 2025 09:50:35 +0000 Subject: [PATCH] test/crimson/test_errorator: ignore assert_all This came up during: https://tracker.ceph.com/issues/69406#note-25 Where an "assert_all" was called but didn't cause an abort. Added "ignore_assert_all" to showcase this scenario along with any other case where we are expected to abort. The tests could be used to verify errorator's aborting behavior. Signed-off-by: Matan Breizman --- src/test/crimson/CMakeLists.txt | 6 ++ src/test/crimson/test_errorator_abort.cc | 93 ++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 src/test/crimson/test_errorator_abort.cc diff --git a/src/test/crimson/CMakeLists.txt b/src/test/crimson/CMakeLists.txt index 3456514b5fd..986260f73c9 100644 --- a/src/test/crimson/CMakeLists.txt +++ b/src/test/crimson/CMakeLists.txt @@ -111,6 +111,12 @@ target_link_libraries( add_ceph_unittest(unittest-seastar-errorator --memory 256M --smp 1) +add_executable(unittest-seastar-errorator-abort + test_errorator_abort.cc) +target_link_libraries( + unittest-seastar-errorator-abort + crimson::gtest) + add_executable(unittest-crimson-coroutine test_crimson_coroutine.cc) target_link_libraries( diff --git a/src/test/crimson/test_errorator_abort.cc b/src/test/crimson/test_errorator_abort.cc new file mode 100644 index 00000000000..461662a58ce --- /dev/null +++ b/src/test/crimson/test_errorator_abort.cc @@ -0,0 +1,93 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*- +// vim: ts=8 sw=2 smarttab + +#include +#include + +#include "test/crimson/gtest_seastar.h" + +#include "crimson/common/errorator.h" +#include "crimson/common/errorator-loop.h" +#include "crimson/common/log.h" +#include "seastar/core/sleep.hh" + +struct errorator_abort_test_t : public seastar_test_suite_t { + using ertr = crimson::errorator; + + ertr::future<> invarg_foo() { + return crimson::ct_error::invarg::make(); + }; + + ertr::future<> clean_foo() { + return ertr::now(); + }; + + struct noncopyable_t { + constexpr noncopyable_t() = default; + ~noncopyable_t() = default; + noncopyable_t(noncopyable_t&&) = default; + private: + noncopyable_t(const noncopyable_t&) = delete; + noncopyable_t& operator=(const noncopyable_t&) = delete; + }; +}; + +// --- The following tests must abort --- + +/* +TEST_F(errorator_abort_test_t, abort_vanilla) +{ + run_async([this] { + abort(); + return seastar::now().get(); + }); +} +*/ + +/* +TEST_F(errorator_abort_test_t, abort_ignored) +{ + run_async([this] { + auto foo = []() -> seastar::future<> { + abort(); + return seastar::now(); + }; + + std::ignore = foo(); + return seastar::now().get(); + }); +} +*/ + +/* +TEST_F(errorator_abort_test_t, assert_all) +{ + run_async([this] { + return invarg_foo().handle_error( + crimson::ct_error::assert_all("unexpected error") + ).get(); + }); +} +*/ + +/* +TEST_F(errorator_abort_test_t, ignore_assert_all) +{ + run_async([this] { + std::ignore = invarg_foo().handle_error( + crimson::ct_error::assert_all("unexpected error") + ); + return seastar::now().get(); + }); +} + +TEST_F(errorator_abort_test_t, ignore_assert_failure) +{ + run_async([this] { + std::ignore = invarg_foo().handle_error( + crimson::ct_error::invarg::assert_failure{"unexpected invarg"} + ); + return seastar::now().get(); + }); +} +*/ -- 2.39.5