Commit e798aa45 authored by Tristan Gingold's avatar Tristan Gingold

Adjust mock_turtle_core test: ensure rmq is ok.

parent a3c94bad
......@@ -143,11 +143,14 @@ module main;
endtask : check_debug_interface
task check_final_count (uint32_t expected);
#500us;
if (count != expected)
$fatal (1, "Simulation FAILED: incorrect final count (%0d, expected %0d)", count, expected);
uint32_t val;
#300us;
drv.smem_read (0, val);
if (val != expected)
$fatal (1, "Simulation FAILED: incorrect final count (%0d, expected %0d)", val, expected);
else
$display ("Simulation PASSED");
$display ("Simulation PASSED");
$finish;
endtask // check_final_result
......@@ -166,7 +169,7 @@ module main;
check_debug_interface(0);
fork
check_final_count(11);
check_final_count(240);
join_none
count = 0;
......
......@@ -85,12 +85,34 @@ test_hmq(void)
failed('k');
}
static char hex[] = "0123456789abcdef";
static void
put_hex(unsigned char c)
{
putchar(hex[c >> 4]);
putchar(hex[c & 0xf]);
}
unsigned
bswap32(unsigned v)
{
return ((v & 0xff) << 24) | ((v & 0xff00) << 8)
| ((v >> 8) & 0xff00) | ((v >> 24) & 0xff);
}
static void
test_rmq(void)
{
int i;
char *p;
unsigned *p32;
unsigned *hdr;
union
{
unsigned char b[sizeof(msg)];
unsigned int w[(sizeof(msg) + 3) / 4];
} buf;
puts("#4 rmq\n");
......@@ -111,11 +133,13 @@ test_rmq(void)
// Read answer
hdr = mq_map_in_header(TRTL_RMQ, 0);
if (hdr[1] != (sizeof (msg) + 3) / 4)
if (hdr[1] != ((sizeof (msg) + 3) / 4) * 4 - 2)
failed('R');
p = mq_map_in_buffer(TRTL_RMQ, 0);
p32 = mq_map_in_buffer(TRTL_RMQ, 0);
for (i = 0; i < (sizeof (msg) + 3) / 4; i++)
buf.w[i] = bswap32(p32[i]);
for (i = 0; i < sizeof (msg); i++)
if (p[i] != msg[i])
if (buf.b[i] != msg[i])
failed('r');
mq_discard(TRTL_RMQ, 0);
......@@ -140,6 +164,8 @@ main(void)
test_rmq();
counts[cpu] = 0xf0;
puts ("Done\n");
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment