mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Add test for extram becoming invalid while reading an "unterminated" buffer (slice)
This commit is contained in:
parent
d1eace7b93
commit
18d787a7b9
1 changed files with 28 additions and 0 deletions
|
|
@ -256,6 +256,34 @@ void test_extram_buf_terminated_rugpull(void) {
|
||||||
TEST_ASSERT_EQUAL(evt.data.err.errcode, UVM32_ERR_MEM_RD);
|
TEST_ASSERT_EQUAL(evt.data.err.errcode, UVM32_ERR_MEM_RD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_extram_buf_unterminated_rugpull(void) {
|
||||||
|
// run the vm
|
||||||
|
uvm32_run(&vmst, &evt, 100);
|
||||||
|
TEST_ASSERT_EQUAL(false, uvm32_extramDirty(&vmst));
|
||||||
|
|
||||||
|
// check for picktest syscall
|
||||||
|
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||||
|
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||||
|
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);
|
||||||
|
|
||||||
|
// remove extram
|
||||||
|
uvm32_extram(&vmst, NULL, 0);
|
||||||
|
|
||||||
|
uvm32_slice_t buf = uvm32_arg_getbuf(&vmst, &evt, ARG0, ARG1);
|
||||||
|
// check that reading from non-existent extram gives empty buffer and puts into err state
|
||||||
|
TEST_ASSERT_EQUAL(0, buf.len);
|
||||||
|
uvm32_run(&vmst, &evt, 100);
|
||||||
|
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_ERR);
|
||||||
|
TEST_ASSERT_EQUAL(evt.data.err.errcode, UVM32_ERR_MEM_RD);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void test_extram_buf_terminated_beyond_mem_end(void) {
|
void test_extram_buf_terminated_beyond_mem_end(void) {
|
||||||
// run the vm
|
// run the vm
|
||||||
uvm32_run(&vmst, &evt, 100);
|
uvm32_run(&vmst, &evt, 100);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue