From 180ac51aea36f3e5838cd2c1717a23b2d5eb6f8a Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Wed, 6 Nov 2024 11:35:12 +0100 Subject: [PATCH] Use fixed clock for sort-into-previous-region test With large values of clocks, awk starts to lose precision due handling the time as floating point values, which causes the test to fail. By always setting the clock of the events to a known value we can just compare the outcome as-is, without performing any arithmetic operation. Fixes: https://pm.bsc.es/gitlab/rarias/ovni/-/issues/205 --- test/emu/ovni/sort-into-previous-region.c | 6 ++-- .../ovni/sort-into-previous-region.driver.sh | 28 ++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/test/emu/ovni/sort-into-previous-region.c b/test/emu/ovni/sort-into-previous-region.c index 2f0942d..9056216 100644 --- a/test/emu/ovni/sort-into-previous-region.c +++ b/test/emu/ovni/sort-into-previous-region.c @@ -36,12 +36,11 @@ emit(char *mcv, uint64_t clock, int size) int main(void) { + set_clock(1); instr_start(0, 1); /* Leave some room to prevent clashes */ - sleep_us(100); /* 100000 us */ - uint64_t t0 = ovni_clock_now(); - sleep_us(100); /* 100000 us */ + uint64_t t0 = 100; /* We want it to end like this: * @@ -68,6 +67,7 @@ main(void) emit("OB.", t0 + 9, 0); emit("OU]", t0 + 11, 0); + set_clock(200); instr_end(); return 0; diff --git a/test/emu/ovni/sort-into-previous-region.driver.sh b/test/emu/ovni/sort-into-previous-region.driver.sh index 042f271..36a5be2 100644 --- a/test/emu/ovni/sort-into-previous-region.driver.sh +++ b/test/emu/ovni/sort-into-previous-region.driver.sh @@ -3,21 +3,23 @@ target=$OVNI_TEST_BIN $target ovnisort ovni ovnidump ovni -ovnidump ovni | awk 'NR == 1 {next} NR==2{t=$1} {print $1-t,$2} NR==13{exit}' > found +ovnidump ovni | awk '{print $1,$2}' > found cat > expected <