Add sort-into-previous-region emu test
This commit is contained in:
parent
13f70be87b
commit
b2d91391b3
@ -5,6 +5,7 @@ test_emu(flush-overhead.c DISABLED)
|
|||||||
test_emu(flush.c)
|
test_emu(flush.c)
|
||||||
test_emu(sort.c SORT)
|
test_emu(sort.c SORT)
|
||||||
test_emu(sort-flush.c SORT)
|
test_emu(sort-flush.c SORT)
|
||||||
|
test_emu(sort-into-previous-region.c SORT DRIVER "sort-into-previous-region.driver.sh")
|
||||||
test_emu(empty-sort.c SORT)
|
test_emu(empty-sort.c SORT)
|
||||||
test_emu(sort-first-and-full-ring.c SORT
|
test_emu(sort-first-and-full-ring.c SORT
|
||||||
SHOULD_FAIL REGEX "cannot find a event previous to clock")
|
SHOULD_FAIL REGEX "cannot find a event previous to clock")
|
||||||
|
74
test/emu/ovni/sort-into-previous-region.c
Normal file
74
test/emu/ovni/sort-into-previous-region.c
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/* Copyright (c) 2024 Barcelona Supercomputing Center (BSC)
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "compat.h"
|
||||||
|
#include "instr.h"
|
||||||
|
#include "ovni.h"
|
||||||
|
|
||||||
|
/* Test the case in which events from a secondary unsorted region are
|
||||||
|
* introduced before the previous unsorted region:
|
||||||
|
*
|
||||||
|
* [bbbb][BBbb]
|
||||||
|
* bbbbBB[]bb[]
|
||||||
|
*
|
||||||
|
* The events B contain 16 bytes of payload, so pointer to events in previous
|
||||||
|
* positions are now pointing to garbage.
|
||||||
|
*
|
||||||
|
* See: https://pm.bsc.es/gitlab/rarias/ovni/-/issues/199
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
emit(char *mcv, int64_t clock, int size)
|
||||||
|
{
|
||||||
|
struct ovni_ev ev = {0};
|
||||||
|
ovni_ev_set_mcv(&ev, mcv);
|
||||||
|
ovni_ev_set_clock(&ev, clock);
|
||||||
|
|
||||||
|
if (size) {
|
||||||
|
uint8_t buf[64] = { 0 };
|
||||||
|
ovni_payload_add(&ev, buf, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
ovni_ev_emit(&ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
instr_start(0, 1);
|
||||||
|
|
||||||
|
/* Leave some room to prevent clashes */
|
||||||
|
sleep_us(100); /* 100000 us */
|
||||||
|
int64_t t0 = ovni_clock_now();
|
||||||
|
sleep_us(100); /* 100000 us */
|
||||||
|
|
||||||
|
/* We want it to end like this:
|
||||||
|
*
|
||||||
|
* t0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11
|
||||||
|
* b b b b B B [ ] b b [ ]
|
||||||
|
*
|
||||||
|
* But we emit it like this:
|
||||||
|
*
|
||||||
|
* +6 +0 +1 +2 +3 +7 +10 +4 +5 +8 +9 +11
|
||||||
|
* [ b b b b ] [ B B b b ]
|
||||||
|
*/
|
||||||
|
|
||||||
|
emit("OU[", t0 + 6, 0);
|
||||||
|
emit("OB.", t0 + 0, 0);
|
||||||
|
emit("OB.", t0 + 1, 0);
|
||||||
|
emit("OB.", t0 + 2, 0);
|
||||||
|
emit("OB.", t0 + 3, 0);
|
||||||
|
emit("OU]", t0 + 7, 0);
|
||||||
|
|
||||||
|
emit("OU[", t0 + 10, 0);
|
||||||
|
emit("OB.", t0 + 4, 16);
|
||||||
|
emit("OB.", t0 + 5, 16);
|
||||||
|
emit("OB.", t0 + 8, 0);
|
||||||
|
emit("OB.", t0 + 9, 0);
|
||||||
|
emit("OU]", t0 + 11, 0);
|
||||||
|
|
||||||
|
instr_end();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
25
test/emu/ovni/sort-into-previous-region.driver.sh
Normal file
25
test/emu/ovni/sort-into-previous-region.driver.sh
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
cat > expected <<EOF
|
||||||
|
0 OB.
|
||||||
|
1 OB.
|
||||||
|
2 OB.
|
||||||
|
3 OB.
|
||||||
|
4 OB.
|
||||||
|
5 OB.
|
||||||
|
6 OU[
|
||||||
|
7 OU]
|
||||||
|
8 OB.
|
||||||
|
9 OB.
|
||||||
|
10 OU[
|
||||||
|
11 OU]
|
||||||
|
EOF
|
||||||
|
|
||||||
|
diff -s found expected
|
||||||
|
|
||||||
|
ovniemu ovni
|
Loading…
Reference in New Issue
Block a user