From: Radoslaw Zarzynski Date: Thu, 20 May 2021 19:18:21 +0000 (+0000) Subject: test/crimson: verify the futurization in an errorated future. X-Git-Tag: v17.1.0~1886^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f18a9e4faea43231f0bcfca5bc3b3244101261fd;p=ceph.git test/crimson: verify the futurization in an errorated future. `seastar::future` allows a lambda passed to e.g. `then()` to return not only a future but also any non-future type like a plain integer: ```cpp seastar::now().then([] { return 42; }).then([] (int futurized_life) { // ... }); ``` In such case, the plain type is being wrapped in a future. This process is called _futurization_ and is performed by `seastar::futurize` called from the internals of `future`. In this commit we want to ensure analogous facility is offered by errorated futures. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/test/crimson/test_errorator.cc b/src/test/crimson/test_errorator.cc index 57dbc78cf9993..ad1223295a16d 100644 --- a/src/test/crimson/test_errorator.cc +++ b/src/test/crimson/test_errorator.cc @@ -31,6 +31,17 @@ struct errorator_test_t : public seastar_test_suite_t { return ertr::now(); }); } + ertr::future test_futurization() { + // we don't want to be enforced to always do `make_ready_future(...)`. + // as in seastar::future, the futurization should take care about + // turning non-future types (e.g. int) into futurized ones (e.g. + // ertr::future). + return ertr::now().safe_then([] { + return 42; + }).safe_then([](int life) { + return ertr::make_ready_future(life); + }); + } private: ertr::future create_noncopyable() { return ertr::make_ready_future(); @@ -50,3 +61,10 @@ TEST_F(errorator_test_t, non_copy_then) test_non_copy_then().unsafe_get0(); }); } + +TEST_F(errorator_test_t, test_futurization) +{ + run_async([this] { + test_futurization().unsafe_get0(); + }); +}