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; ...@@ -143,11 +143,14 @@ module main;
endtask : check_debug_interface endtask : check_debug_interface
task check_final_count (uint32_t expected); task check_final_count (uint32_t expected);
#500us; uint32_t val;
if (count != expected) #300us;
$fatal (1, "Simulation FAILED: incorrect final count (%0d, expected %0d)", count, expected);
drv.smem_read (0, val);
if (val != expected)
$fatal (1, "Simulation FAILED: incorrect final count (%0d, expected %0d)", val, expected);
else else
$display ("Simulation PASSED"); $display ("Simulation PASSED");
$finish; $finish;
endtask // check_final_result endtask // check_final_result
...@@ -166,7 +169,7 @@ module main; ...@@ -166,7 +169,7 @@ module main;
check_debug_interface(0); check_debug_interface(0);
fork fork
check_final_count(11); check_final_count(240);
join_none join_none
count = 0; count = 0;
......
...@@ -85,12 +85,34 @@ test_hmq(void) ...@@ -85,12 +85,34 @@ test_hmq(void)
failed('k'); 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 static void
test_rmq(void) test_rmq(void)
{ {
int i; int i;
char *p; char *p;
unsigned *p32;
unsigned *hdr; unsigned *hdr;
union
{
unsigned char b[sizeof(msg)];
unsigned int w[(sizeof(msg) + 3) / 4];
} buf;
puts("#4 rmq\n"); puts("#4 rmq\n");
...@@ -111,11 +133,13 @@ test_rmq(void) ...@@ -111,11 +133,13 @@ test_rmq(void)
// Read answer // Read answer
hdr = mq_map_in_header(TRTL_RMQ, 0); 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'); 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++) for (i = 0; i < sizeof (msg); i++)
if (p[i] != msg[i]) if (buf.b[i] != msg[i])
failed('r'); failed('r');
mq_discard(TRTL_RMQ, 0); mq_discard(TRTL_RMQ, 0);
...@@ -140,6 +164,8 @@ main(void) ...@@ -140,6 +164,8 @@ main(void)
test_rmq(); test_rmq();
counts[cpu] = 0xf0;
puts ("Done\n"); puts ("Done\n");
return 0; 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