-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
compilerissues related to the compilerissues related to the compilerenhancementNew feature or requestNew feature or request
Description
Currently, to write a test for the AVR backend, it is a rather manual process,
compared to x86-64 where it's possible to just test using the (filename.exitcode) file.
Example:
void test_gen_tac_mdirect_case_variable_addr() {
status_test_codegen_tac("MDirect - variable Address");
//we need an address here which is small enough
//to fit into a register. 0xc7 is usable.
for (uint16_t address = 0xc7; address < 0xcb; address++) {
const int8_t value = 0x38;
char snippet[200];
sprintf(snippet, "fn main() -> int { int y = 3; int x = [y+%d, 1]; return x; }", address);
vmcu_system_t* system = prepare_vmcu_system_from_code_snippet(snippet);
//prepare a value in the location
vmcu_system_write_data(system, address + 3, value);
for (int i = 0; i < 40; i++) {
vmcu_system_step(system);
}
//return value in r0
int8_t actual = vmcu_system_read_gpr(system, 0);
assert(value == actual);
vmcu_system_dtor(system);
}
}
But what's happening is very similar across most testcases
- compile some code snippet
- prepare some data in memory using
vmcu_system_write_data(system, address, value); - run it with vmcu_system for n cycles
- read some data in memory using
vmcu_system_read_data(system, address); - read some registers, mostry r0 and r1
- assert on the value in registers or in memory.
All of that can be encapsulated by creating a directory with following files
- snippet.dg
- ncycles.txt
- prepare_memory.dg
- expect_registers.dg
- expect_memory.dg
This would enable writing more complicated testcases more easily.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
compilerissues related to the compilerissues related to the compilerenhancementNew feature or requestNew feature or request