mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Renaming and documentating header
This commit is contained in:
parent
9880eadf4f
commit
8158ac647c
19 changed files with 305 additions and 225 deletions
|
|
@ -22,31 +22,31 @@ void test_syscalls(void) {
|
|||
uvm32_run(&vmst, &evt, 1000);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINTLN);
|
||||
TEST_ASSERT_EQUAL(0, strcmp(uvm32_getcstr(&vmst, &evt, ARG0), "Hello world"));
|
||||
TEST_ASSERT_EQUAL(0, strcmp(uvm32_arg_getcstr(&vmst, &evt, ARG0), "Hello world"));
|
||||
|
||||
// check for print syscall
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINT);
|
||||
TEST_ASSERT_EQUAL(0, strcmp(uvm32_getcstr(&vmst, &evt, ARG0), "Hello world"));
|
||||
TEST_ASSERT_EQUAL(0, strcmp(uvm32_arg_getcstr(&vmst, &evt, ARG0), "Hello world"));
|
||||
|
||||
// check for printdec syscall
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINTDEC);
|
||||
TEST_ASSERT_EQUAL(42, uvm32_getval(&vmst, &evt, ARG0));
|
||||
TEST_ASSERT_EQUAL(42, uvm32_arg_getval(&vmst, &evt, ARG0));
|
||||
|
||||
// check for printhex syscall
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINTHEX);
|
||||
TEST_ASSERT_EQUAL(0xDEADBEEF, uvm32_getval(&vmst, &evt, ARG0));
|
||||
TEST_ASSERT_EQUAL(0xDEADBEEF, uvm32_arg_getval(&vmst, &evt, ARG0));
|
||||
|
||||
// check for putc syscall
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PUTC);
|
||||
TEST_ASSERT_EQUAL('G', uvm32_getval(&vmst, &evt, ARG0));
|
||||
TEST_ASSERT_EQUAL('G', uvm32_arg_getval(&vmst, &evt, ARG0));
|
||||
|
||||
// run vm to completion
|
||||
uvm32_run(&vmst, &evt, 10000);
|
||||
|
|
|
|||
|
|
@ -23,15 +23,15 @@ void test_custom_syscall_normal(void) {
|
|||
// check for custom syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, 0xDEADBEEF);
|
||||
TEST_ASSERT_EQUAL(0xABCD1234, uvm32_getval(&vmst, &evt, ARG0));
|
||||
TEST_ASSERT_EQUAL(0xDECAFBAD, uvm32_getval(&vmst, &evt, ARG1));
|
||||
uvm32_setval(&vmst, &evt, RET, 0xAABBCCDD);
|
||||
TEST_ASSERT_EQUAL(0xABCD1234, uvm32_arg_getval(&vmst, &evt, ARG0));
|
||||
TEST_ASSERT_EQUAL(0xDECAFBAD, uvm32_arg_getval(&vmst, &evt, ARG1));
|
||||
uvm32_arg_setval(&vmst, &evt, RET, 0xAABBCCDD);
|
||||
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
// check for print syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINT);
|
||||
const char *str = uvm32_getcstr(&vmst, &evt, ARG0);
|
||||
const char *str = uvm32_arg_getcstr(&vmst, &evt, ARG0);
|
||||
TEST_ASSERT_EQUAL(0, strcmp(str, "ok"));
|
||||
// run vm to completion
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
|
|
@ -44,15 +44,15 @@ void test_custom_syscall_badval(void) {
|
|||
// check for custom syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, 0xDEADBEEF);
|
||||
TEST_ASSERT_EQUAL(0xABCD1234, uvm32_getval(&vmst, &evt, ARG0));
|
||||
TEST_ASSERT_EQUAL(0xDECAFBAD, uvm32_getval(&vmst, &evt, ARG1));
|
||||
uvm32_setval(&vmst, &evt, RET, 0); // send value that is not being expected
|
||||
TEST_ASSERT_EQUAL(0xABCD1234, uvm32_arg_getval(&vmst, &evt, ARG0));
|
||||
TEST_ASSERT_EQUAL(0xDECAFBAD, uvm32_arg_getval(&vmst, &evt, ARG1));
|
||||
uvm32_arg_setval(&vmst, &evt, RET, 0); // send value that is not being expected
|
||||
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
// check for print syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINT);
|
||||
const char *str = uvm32_getcstr(&vmst, &evt, ARG0);
|
||||
const char *str = uvm32_arg_getcstr(&vmst, &evt, ARG0);
|
||||
TEST_ASSERT_EQUAL(0, strcmp(str, "fail"));
|
||||
// run vm to completion
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
|
|
|
|||
|
|
@ -33,13 +33,13 @@ void test_extram_access(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, TEST1);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, TEST1);
|
||||
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
// check for printdec of val
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINTDEC);
|
||||
TEST_ASSERT_EQUAL(1234, uvm32_getval(&vmst, &evt, ARG0));
|
||||
TEST_ASSERT_EQUAL(1234, uvm32_arg_getval(&vmst, &evt, ARG0));
|
||||
|
||||
// run vm to completion
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
|
|
@ -57,7 +57,7 @@ void test_extram_out_of_bounds_rd(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, TEST2);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, TEST2);
|
||||
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_ERR);
|
||||
|
|
@ -73,7 +73,7 @@ void test_extram_out_of_bounds_wr(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, TEST3);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, TEST3);
|
||||
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_ERR);
|
||||
|
|
@ -89,7 +89,7 @@ void test_extram_out_of_bounds_dirty_flag(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, TEST4);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, TEST4);
|
||||
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
TEST_ASSERT_EQUAL(true, uvm32_extramDirty(&vmst));
|
||||
|
|
@ -105,7 +105,7 @@ void test_extram_byte_write(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, TEST5);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, TEST5);
|
||||
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
TEST_ASSERT_EQUAL(true, uvm32_extramDirty(&vmst));
|
||||
|
|
@ -129,7 +129,7 @@ void test_extram_byte_read(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, TEST6);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, TEST6);
|
||||
|
||||
// set only byte 7 in extram
|
||||
uint8_t *p = (uint8_t *)extram;
|
||||
|
|
@ -140,7 +140,7 @@ void test_extram_byte_read(void) {
|
|||
// check for printdec of val
|
||||
TEST_ASSERT_EQUAL(UVM32_EVT_SYSCALL, evt.typ);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINTDEC);
|
||||
TEST_ASSERT_EQUAL(0xCD, uvm32_getval(&vmst, &evt, ARG0));
|
||||
TEST_ASSERT_EQUAL(0xCD, uvm32_arg_getval(&vmst, &evt, ARG0));
|
||||
}
|
||||
|
||||
void test_extram_short_write(void) {
|
||||
|
|
@ -151,7 +151,7 @@ void test_extram_short_write(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, TEST7);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, TEST7);
|
||||
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
TEST_ASSERT_EQUAL(true, uvm32_extramDirty(&vmst));
|
||||
|
|
@ -175,7 +175,7 @@ void test_extram_short_read(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, TEST8);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, TEST8);
|
||||
|
||||
// set only short 7 in extram
|
||||
uint16_t *p = (uint16_t *)extram;
|
||||
|
|
@ -186,7 +186,7 @@ void test_extram_short_read(void) {
|
|||
// check for printdec of val
|
||||
TEST_ASSERT_EQUAL(UVM32_EVT_SYSCALL, evt.typ);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINTDEC);
|
||||
TEST_ASSERT_EQUAL(0xCDEF, uvm32_getval(&vmst, &evt, ARG0));
|
||||
TEST_ASSERT_EQUAL(0xCDEF, uvm32_arg_getval(&vmst, &evt, ARG0));
|
||||
}
|
||||
|
||||
void test_extram_buf_unterminated(void) {
|
||||
|
|
@ -197,14 +197,14 @@ void test_extram_buf_unterminated(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, TEST9);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, TEST9);
|
||||
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
TEST_ASSERT_EQUAL(true, uvm32_extramDirty(&vmst));
|
||||
// check for printbuf of val
|
||||
TEST_ASSERT_EQUAL(UVM32_EVT_SYSCALL, evt.typ);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINTBUF);
|
||||
uvm32_evt_syscall_buf_t buf = uvm32_getbuf(&vmst, &evt, ARG0, ARG1);
|
||||
uvm32_slice_t buf = uvm32_arg_getbuf(&vmst, &evt, ARG0, ARG1);
|
||||
TEST_ASSERT_EQUAL(5, buf.len);
|
||||
TEST_ASSERT_EQUAL(0, memcmp(buf.ptr, "hello", 5));
|
||||
}
|
||||
|
|
@ -217,14 +217,14 @@ void test_extram_buf_terminated(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, TEST9);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, TEST9);
|
||||
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
TEST_ASSERT_EQUAL(true, uvm32_extramDirty(&vmst));
|
||||
// check for printbuf of val
|
||||
TEST_ASSERT_EQUAL(UVM32_EVT_SYSCALL, evt.typ);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINTBUF);
|
||||
const char *str = uvm32_getcstr(&vmst, &evt, ARG0);
|
||||
const char *str = uvm32_arg_getcstr(&vmst, &evt, ARG0);
|
||||
TEST_ASSERT_NOT_EQUAL(NULL, str);
|
||||
TEST_ASSERT_EQUAL(0, strcmp(str, "hello"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ uint32_t metered_run(uint32_t num_instr) {
|
|||
switch(evt.typ) {
|
||||
case UVM32_EVT_SYSCALL: {
|
||||
TEST_ASSERT_EQUAL(UVM32_SYSCALL_PRINTDEC, evt.data.syscall.code);
|
||||
uint32_t val = uvm32_getval(&vmst, &evt, ARG0);
|
||||
uint32_t val = uvm32_arg_getval(&vmst, &evt, ARG0);
|
||||
TEST_ASSERT_EQUAL(val, expected);
|
||||
expected++;
|
||||
} break;
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ void test_syscall_args_two_strings(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, SYSCALL_A);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, SYSCALL_A);
|
||||
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_A);
|
||||
TEST_ASSERT_EQUAL(0, strcmp(uvm32_getcstr(&vmst, &evt, ARG0), SYSCALL_A_DATA0));
|
||||
TEST_ASSERT_EQUAL(0, strcmp(uvm32_getcstr(&vmst, &evt, ARG1), SYSCALL_A_DATA1));
|
||||
TEST_ASSERT_EQUAL(0, strcmp(uvm32_arg_getcstr(&vmst, &evt, ARG0), SYSCALL_A_DATA0));
|
||||
TEST_ASSERT_EQUAL(0, strcmp(uvm32_arg_getcstr(&vmst, &evt, ARG1), SYSCALL_A_DATA1));
|
||||
// run vm to completion
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_END);
|
||||
|
|
@ -42,21 +42,21 @@ void test_syscall_args_bad_string(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, SYSCALL_B);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, SYSCALL_B);
|
||||
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_B);
|
||||
|
||||
// try to read C string from the first null ptr
|
||||
const char *s0 = uvm32_getcstr(&vmst, &evt, ARG0);
|
||||
const char *s0 = uvm32_arg_getcstr(&vmst, &evt, ARG0);
|
||||
TEST_ASSERT_EQUAL(0, strlen(s0)); // tried to read a null pointer, get back a zero length string (not a NULL we might read)
|
||||
// attempt to run vm, should be stuck in err
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_ERR);
|
||||
|
||||
// try to read C string from the second null ptr
|
||||
const char *s1 = uvm32_getcstr(&vmst, &evt, ARG1);
|
||||
const char *s1 = uvm32_arg_getcstr(&vmst, &evt, ARG1);
|
||||
TEST_ASSERT_EQUAL(0, strlen(s1)); // tried to read a null pointer, get back a zero length string (not a NULL we might read)
|
||||
// attempt to run vm, should be stuck in err
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
|
|
@ -69,14 +69,14 @@ void test_syscall_args_bufrd(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, SYSCALL_C);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, SYSCALL_C);
|
||||
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_C);
|
||||
|
||||
// get buffer described by ptr=ARG0,len=ARG1
|
||||
uvm32_evt_syscall_buf_t buf = uvm32_getbuf(&vmst, &evt, ARG0, ARG1);
|
||||
uvm32_slice_t buf = uvm32_arg_getbuf(&vmst, &evt, ARG0, ARG1);
|
||||
uint8_t expected[32];
|
||||
for (int i=0;i<32;i++) {
|
||||
expected[i] = i;
|
||||
|
|
@ -91,14 +91,14 @@ void test_syscall_args_bufrd_bad_addr(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, SYSCALL_D);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, SYSCALL_D);
|
||||
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_D);
|
||||
|
||||
// get buffer described by ptr=ARG0,len=ARG1
|
||||
uvm32_evt_syscall_buf_t buf = uvm32_getbuf(&vmst, &evt, ARG0, ARG1);
|
||||
uvm32_slice_t buf = uvm32_arg_getbuf(&vmst, &evt, ARG0, ARG1);
|
||||
TEST_ASSERT_EQUAL(0, buf.len); // it was invalid, should get a safe zero length buffer
|
||||
// attempt to run vm, should be stuck in err
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
|
|
@ -111,20 +111,20 @@ void test_syscall_args_bufrd_ptrs(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, SYSCALL_E);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, SYSCALL_E);
|
||||
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_E);
|
||||
|
||||
// get uint32_t buffer described by ptr=ARG0
|
||||
uvm32_evt_syscall_buf_t buf0 = uvm32_getbuf_fixed(&vmst, &evt, ARG0, 4);
|
||||
uvm32_slice_t buf0 = uvm32_arg_getbuf_fixed(&vmst, &evt, ARG0, 4);
|
||||
TEST_ASSERT_EQUAL(4, buf0.len); // check read ok
|
||||
uint32_t rspa = 0xABCD1234;
|
||||
memcpy(buf0.ptr, &rspa, 4); // send it back
|
||||
|
||||
// get uint32_t buffer described by ptr=ARG1
|
||||
uvm32_evt_syscall_buf_t buf1 = uvm32_getbuf_fixed(&vmst, &evt, ARG1, 4);
|
||||
uvm32_slice_t buf1 = uvm32_arg_getbuf_fixed(&vmst, &evt, ARG1, 4);
|
||||
TEST_ASSERT_EQUAL(4, buf1.len); // check read ok
|
||||
uint32_t rspb = 0x9876DECF;
|
||||
memcpy(buf1.ptr, &rspb, 4); // send it back
|
||||
|
|
@ -133,8 +133,8 @@ void test_syscall_args_bufrd_ptrs(void) {
|
|||
uvm32_run(&vmst, &evt, 1000);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_F);
|
||||
TEST_ASSERT_EQUAL(rspa, uvm32_getval(&vmst, &evt, ARG0));
|
||||
TEST_ASSERT_EQUAL(rspb, uvm32_getval(&vmst, &evt, ARG1));
|
||||
TEST_ASSERT_EQUAL(rspa, uvm32_arg_getval(&vmst, &evt, ARG0));
|
||||
TEST_ASSERT_EQUAL(rspb, uvm32_arg_getval(&vmst, &evt, ARG1));
|
||||
}
|
||||
|
||||
void test_syscall_args_buf_pass(void) {
|
||||
|
|
@ -143,14 +143,14 @@ void test_syscall_args_buf_pass(void) {
|
|||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_setval(&vmst, &evt, RET, SYSCALL_G);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, SYSCALL_G);
|
||||
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_G);
|
||||
|
||||
// get buffer described by ptr=ARG0,len=ARG1
|
||||
uvm32_evt_syscall_buf_t buf0 = uvm32_getbuf(&vmst, &evt, ARG0, ARG1);
|
||||
uvm32_slice_t buf0 = uvm32_arg_getbuf(&vmst, &evt, ARG0, ARG1);
|
||||
TEST_ASSERT_EQUAL(32, buf0.len);
|
||||
// fill with a pattern
|
||||
for (int i=0;i<32;i++) {
|
||||
|
|
@ -162,7 +162,7 @@ void test_syscall_args_buf_pass(void) {
|
|||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_H);
|
||||
|
||||
// get buffer described by ptr=ARG0,len=ARG1
|
||||
uvm32_evt_syscall_buf_t buf1 = uvm32_getbuf(&vmst, &evt, ARG0, ARG1);
|
||||
uvm32_slice_t buf1 = uvm32_arg_getbuf(&vmst, &evt, ARG0, ARG1);
|
||||
TEST_ASSERT_EQUAL(32, buf1.len);
|
||||
for (int i=0;i<32;i++) {
|
||||
TEST_ASSERT_EQUAL(i*2, buf1.ptr[i]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue