mirror of
https://github.com/Icinga/icinga2.git
synced 2026-05-28 04:12:13 -04:00
Merge pull request #10776 from Icinga/give-windows-more-time
Some checks are pending
Container Image / Container Image (push) Waiting to run
Linux / alpine:bash (push) Waiting to run
Linux / amazonlinux:2 (push) Waiting to run
Linux / amazonlinux:2023 (push) Waiting to run
Linux / debian:11 (linux/386) (push) Waiting to run
Linux / debian:11 (push) Waiting to run
Linux / debian:12 (linux/386) (push) Waiting to run
Linux / debian:12 (push) Waiting to run
Linux / debian:13 (push) Waiting to run
Linux / fedora:41 (push) Waiting to run
Linux / fedora:42 (push) Waiting to run
Linux / fedora:43 (push) Waiting to run
Linux / opensuse/leap:15.6 (push) Waiting to run
Linux / opensuse/leap:16.0 (push) Waiting to run
Linux / registry.suse.com/bci/bci-base:16.0 (push) Waiting to run
Linux / registry.suse.com/suse/sle15:15.6 (push) Waiting to run
Linux / registry.suse.com/suse/sle15:15.7 (push) Waiting to run
Linux / rockylinux/rockylinux:10 (push) Waiting to run
Linux / rockylinux:8 (push) Waiting to run
Linux / rockylinux:9 (push) Waiting to run
Linux / ubuntu:22.04 (push) Waiting to run
Linux / ubuntu:24.04 (push) Waiting to run
Linux / ubuntu:25.04 (push) Waiting to run
Linux / ubuntu:25.10 (push) Waiting to run
Windows / Windows (push) Waiting to run
Some checks are pending
Container Image / Container Image (push) Waiting to run
Linux / alpine:bash (push) Waiting to run
Linux / amazonlinux:2 (push) Waiting to run
Linux / amazonlinux:2023 (push) Waiting to run
Linux / debian:11 (linux/386) (push) Waiting to run
Linux / debian:11 (push) Waiting to run
Linux / debian:12 (linux/386) (push) Waiting to run
Linux / debian:12 (push) Waiting to run
Linux / debian:13 (push) Waiting to run
Linux / fedora:41 (push) Waiting to run
Linux / fedora:42 (push) Waiting to run
Linux / fedora:43 (push) Waiting to run
Linux / opensuse/leap:15.6 (push) Waiting to run
Linux / opensuse/leap:16.0 (push) Waiting to run
Linux / registry.suse.com/bci/bci-base:16.0 (push) Waiting to run
Linux / registry.suse.com/suse/sle15:15.6 (push) Waiting to run
Linux / registry.suse.com/suse/sle15:15.7 (push) Waiting to run
Linux / rockylinux/rockylinux:10 (push) Waiting to run
Linux / rockylinux:8 (push) Waiting to run
Linux / rockylinux:9 (push) Waiting to run
Linux / ubuntu:22.04 (push) Waiting to run
Linux / ubuntu:24.04 (push) Waiting to run
Linux / ubuntu:25.04 (push) Waiting to run
Linux / ubuntu:25.10 (push) Waiting to run
Windows / Windows (push) Waiting to run
Fix sporadic fails in timer unit-tests on Windows
This commit is contained in:
commit
52dcf910b6
1 changed files with 14 additions and 5 deletions
|
|
@ -6,6 +6,15 @@
|
|||
#include "base/application.hpp"
|
||||
#include <BoostTestTargetConfig.h>
|
||||
|
||||
/**
|
||||
* Windows needs a special handicap to keep up with the other OSs.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
static constexpr double timeMultiplier = 10;
|
||||
#else //_WIN32
|
||||
static constexpr double timeMultiplier = 1;
|
||||
#endif //_WIN32
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(base_timer)
|
||||
|
|
@ -29,10 +38,10 @@ BOOST_AUTO_TEST_CASE(invoke)
|
|||
|
||||
Timer::Ptr timer = Timer::Create();
|
||||
timer->OnTimerExpired.connect([&counter](const Timer* const&) { counter++; });
|
||||
timer->SetInterval(.1);
|
||||
timer->SetInterval(.1 * timeMultiplier);
|
||||
|
||||
timer->Start();
|
||||
Utility::Sleep(.575);
|
||||
Utility::Sleep(.55 * timeMultiplier);
|
||||
timer->Stop();
|
||||
|
||||
// At this point, the timer should have fired exactly 5 times (0.5 / 0.1) and the sixth time
|
||||
|
|
@ -46,12 +55,12 @@ BOOST_AUTO_TEST_CASE(scope)
|
|||
|
||||
Timer::Ptr timer = Timer::Create();
|
||||
timer->OnTimerExpired.connect([&counter](const Timer* const&) { counter++; });
|
||||
timer->SetInterval(.1);
|
||||
timer->SetInterval(.1 * timeMultiplier);
|
||||
|
||||
timer->Start();
|
||||
Utility::Sleep(.575);
|
||||
Utility::Sleep(.55 * timeMultiplier);
|
||||
timer.reset();
|
||||
Utility::Sleep(.1);
|
||||
Utility::Sleep(.1 * timeMultiplier);
|
||||
|
||||
// At this point, the timer should have fired exactly 5 times (0.5 / 0.1) and the sixth time
|
||||
// should not have fired yet as we destroyed the timer after 0.55 seconds (0.6 would be needed),
|
||||
|
|
|
|||
Loading…
Reference in a new issue