From 35e7d5660ff880de3b632cdefb01f5caa6b2a24c Mon Sep 17 00:00:00 2001 From: wokron Date: Mon, 16 Nov 2026 20:51:27 +0800 Subject: [PATCH] re-enable unprivileged del_dev_async tests --- tests/test_control.cpp | 28 ++++++++++++---------------- tests/test_raw.cpp | 41 +++++++++++++++++++---------------------- 2 files changed, 31 insertions(+), 38 deletions(-) diff --git a/tests/test_control.cpp b/tests/test_control.cpp index 7e67f59..f550c72 100644 --- a/tests/test_control.cpp +++ b/tests/test_control.cpp @@ -60,24 +60,20 @@ TEST_CASE("test control") { }); SUBCASE("del_dev_async") { - // TODO: Kernel bug - // https://lore.kernel.org/linux-block/20260901142438.237586-1-yi1tang.yang@gmail.com/ - if (!unprivileged) { - // Hold dev reference - auto ublkc_path = ublk::detail::dev_path(dev_id); - int ublkc_fd = open(ublkc_path.c_str(), O_RDWR); - auto d = - ublk::detail::defer([&]() noexcept { close(ublkc_fd); }); + // Hold dev reference + auto ublkc_path = ublk::detail::dev_path(dev_id); + int ublkc_fd = open(ublkc_path.c_str(), O_RDWR); + REQUIRE(ublkc_fd >= 0); + auto d = ublk::detail::defer([&]() noexcept { close(ublkc_fd); }); - try { - ex::sync_wait(ex::starts_on( - sched, ublk::del_dev_async(control_fd, dev_id))); - } catch (const std::system_error &e) { - if (e.code().value() != EOPNOTSUPP) { - throw; - } - MESSAGE("del_dev_async not supported, skipping"); + try { + ex::sync_wait(ex::starts_on( + sched, ublk::del_dev_async(control_fd, dev_id))); + } catch (const std::system_error &e) { + if (e.code().value() != EOPNOTSUPP) { + throw; } + MESSAGE("del_dev_async not supported, skipping"); } } diff --git a/tests/test_raw.cpp b/tests/test_raw.cpp index 4aa1b34..cebc68f 100644 --- a/tests/test_raw.cpp +++ b/tests/test_raw.cpp @@ -406,28 +406,25 @@ TEST_CASE("test raw - unprivileged") { ex::upon_error([](std::error_code) noexcept {}))); }); - // TODO: Kernel bug - // https://lore.kernel.org/linux-block/20260901142438.237586-1-yi1tang.yang@gmail.com/ - // SUBCASE("del_dev_async") { - // // Hold dev reference - // auto ublkc_path = ublk::detail::dev_path(dev_id); - // int ublkc_fd = open(ublkc_path.c_str(), O_RDWR); - // auto d = ublk::detail::defer([&]() noexcept { close(ublkc_fd); - // }); - - // try { - // ex::sync_wait(ex::starts_on( - // sched, - // ublk::raw::del_dev_async(control_fd, dev_id, dev_path, - // sizeof(dev_path)))); - // } catch (const std::system_error &e) { - // if (e.code().value() != EOPNOTSUPP) { - // throw; - // } - // MESSAGE("del_dev_async not supported, skipping"); - // return; - // } - // } + SUBCASE("del_dev_async") { + // Hold dev reference + auto ublkc_path = ublk::detail::dev_path(dev_id); + int ublkc_fd = open(ublkc_path.c_str(), O_RDWR); + REQUIRE(ublkc_fd >= 0); + auto d = ublk::detail::defer([&]() noexcept { close(ublkc_fd); }); + + try { + ex::sync_wait(ex::starts_on( + sched, + ublk::raw::del_dev_async(control_fd, dev_id, dev_path, + sizeof(dev_path)))); + } catch (const std::system_error &e) { + if (e.code().value() != EOPNOTSUPP) { + throw; + } + MESSAGE("del_dev_async not supported, skipping"); + } + } SUBCASE("get_queue_affinity") { ublk::detail::DevPathBuf aff_buf(dev_id);