Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions tests/matron/clocks/clock_internal/test_clock_internal.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// tests for matron/src/clocks/clock_internal.c behavior
// covers thread loop, tempo publish, restarts

#include <chrono>
#include <doctest/doctest.h>
#include <thread>

extern "C" {
#include "clocks/clock_internal.h"
Expand Down Expand Up @@ -166,8 +168,8 @@ TEST_CASE("internal clock") {

// wait for the first publish
unsigned long long pub = clock_internal_test_get_published_ticks();
for (int i = 0; i < 200000 && clock_internal_test_get_published_ticks() == pub; ++i) {
;
for (int i = 0; i < 2000000 && clock_internal_test_get_published_ticks() == pub; ++i) {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
REQUIRE(clock_internal_get_tempo() == doctest::Approx(120.0));

Expand All @@ -176,17 +178,17 @@ TEST_CASE("internal clock") {
pub = clock_internal_test_get_published_ticks();
clock_internal_set_tempo(90.0);

for (int i = 0; i < 200000 && clock_internal_test_get_published_ticks() == pub; ++i) {
;
for (int i = 0; i < 2000000 && clock_internal_test_get_published_ticks() == pub; ++i) {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
CHECK(clock_internal_get_tempo() == doctest::Approx(90.0));

// jump time forward by hours; tempo change still publishes on the next tick
tests_set_now(6.0 * 3600.0);
pub = clock_internal_test_get_published_ticks();
clock_internal_set_tempo(60.0);
for (int i = 0; i < 400000 && clock_internal_test_get_published_ticks() == pub; ++i) {
;
for (int i = 0; i < 4000000 && clock_internal_test_get_published_ticks() == pub; ++i) {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
CHECK(clock_internal_get_tempo() == doctest::Approx(60.0));

Expand Down