#include #include #include #include #include SCENARIO("irq_lock remote unlock protection", "[kapi][interrupts]") { GIVEN("a simple irq_lock") { auto lock = kapi::interrupts::irq_lock{}; WHEN("it is locked on the main core") { auto guard = std::lock_guard{lock}; THEN("unlocking it on a different core panics") { auto unlocker = [&] { try { lock.unlock(); return false; } catch (kernel::tests::cpu::halt const &) { return true; } }; auto result = std::async(std::launch::async, unlocker); REQUIRE(result.get()); } } } GIVEN("A heap allocated irq_lock") { // We use plain new-delete here, since the destruction path of std::shared_ptr is fully noexcept. auto lock = new kapi::interrupts::irq_lock<>{}; THEN("destroying it on a different core panics") { auto destroyer = [&] { try { delete lock; return false; } catch (kernel::tests::cpu::halt const &) { return true; } }; auto result = std::async(std::launch::async, destroyer); REQUIRE(result.get()); } } }