]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/crimson/test_errorator: ignore assert_all
authorMatan Breizman <mbreizma@redhat.com>
Mon, 7 Apr 2025 09:50:35 +0000 (09:50 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Tue, 22 Apr 2025 15:11:58 +0000 (15:11 +0000)
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 <mbreizma@redhat.com>
src/test/crimson/CMakeLists.txt
src/test/crimson/test_errorator_abort.cc [new file with mode: 0644]

index 3456514b5fda9ac41a7df2efac873555980dc020..986260f73c9e6937dd0dbb3e25e7c25d4d19aaf3 100644 (file)
@@ -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 (file)
index 0000000..461662a
--- /dev/null
@@ -0,0 +1,93 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*-
+// vim: ts=8 sw=2 smarttab
+
+#include <boost/iterator/counting_iterator.hpp>
+#include <numeric>
+
+#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<crimson::ct_error::invarg>;
+
+  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();
+  });
+}
+*/