mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 16:21:29 +00:00
Tests: Add coverage for sys$alarm() canceling a stale timer
This is a regression test to validate the functionality that was reported broken in #9071, where the kernel would spin attempting to cancel a stale timer.
This commit is contained in:
parent
fc91eb365d
commit
ea401fb3c3
Notes:
sideshowbarker
2024-07-18 07:32:22 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/ea401fb3c33 Pull-request: https://github.com/SerenityOS/serenity/pull/9145 Reviewed-by: https://github.com/tomuta ✅
29
Tests/Kernel/TestKernelAlarm.cpp
Normal file
29
Tests/Kernel/TestKernelAlarm.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Brian Gianforcaro <bgianf@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Time.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// Regression test for issues #9071
|
||||
// See: https://github.com/SerenityOS/serenity/issues/9071
|
||||
TEST_CASE(regression_inifinite_loop)
|
||||
{
|
||||
constexpr auto hour_long_timer_value = Time::from_seconds(60 * 60);
|
||||
|
||||
// Create an alarm timer significantly far into the future.
|
||||
auto previous_time = alarm(hour_long_timer_value.to_seconds());
|
||||
EXPECT_EQ(previous_time, 0u);
|
||||
|
||||
// Update the alarm with a zero value before the previous timer expires.
|
||||
previous_time = alarm(0);
|
||||
EXPECT_EQ(previous_time, hour_long_timer_value.to_seconds());
|
||||
|
||||
// Update the alarm with a zero value again, this shouldn't get stuck
|
||||
// in an infinite loop trying to cancel the previous timer in the kernel.
|
||||
previous_time = alarm(0);
|
||||
EXPECT_EQ(previous_time, 0u);
|
||||
}
|
Loading…
Reference in a new issue