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
This commit is contained in:
Rodrigo Arias 2024-11-06 11:35:12 +01:00
parent 73b19ca1c4
commit 180ac51aea
2 changed files with 18 additions and 16 deletions

View File

@ -36,12 +36,11 @@ emit(char *mcv, uint64_t clock, int size)
int int
main(void) main(void)
{ {
set_clock(1);
instr_start(0, 1); instr_start(0, 1);
/* Leave some room to prevent clashes */ /* Leave some room to prevent clashes */
sleep_us(100); /* 100000 us */ uint64_t t0 = 100;
uint64_t t0 = ovni_clock_now();
sleep_us(100); /* 100000 us */
/* We want it to end like this: /* We want it to end like this:
* *
@ -68,6 +67,7 @@ main(void)
emit("OB.", t0 + 9, 0); emit("OB.", t0 + 9, 0);
emit("OU]", t0 + 11, 0); emit("OU]", t0 + 11, 0);
set_clock(200);
instr_end(); instr_end();
return 0; return 0;

View File

@ -3,21 +3,23 @@ target=$OVNI_TEST_BIN
$target $target
ovnisort ovni ovnisort ovni
ovnidump 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 <<EOF cat > expected <<EOF
0 OB. 1 OHx
1 OB. 100 OB.
2 OB. 101 OB.
3 OB. 102 OB.
4 OB. 103 OB.
5 OB. 104 OB.
6 OU[ 105 OB.
7 OU] 106 OU[
8 OB. 107 OU]
9 OB. 108 OB.
10 OU[ 109 OB.
11 OU] 110 OU[
111 OU]
200 OHe
EOF EOF
diff -s found expected diff -s found expected