Skip to content

Commit

Permalink
add missing unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Enkelmann committed Dec 12, 2023
1 parent 698f0bb commit 374657b
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,22 @@ fn test_generation_of_nested_ids_and_access_patterns_on_load_and_store() {
AccessPattern::new().with_read_flag()
)));
}

#[test]
fn test_stack_param_loaded_but_not_accessed() {
// Regression test for the case that a stack parameter is loaded into a register but then not directly accessed.
// In such a case the stack parameter must still be proactively marked as read,
// because its later usage might simply be missed by the analysis
let project = Project::mock_arm32();
let graph = crate::analysis::graph::get_program_cfg(&project.program);
let context = Context::new(&project, &graph);
let state = State::mock_arm32();

let def = def!["r0:4 := Load from sp:4"];
let new_state = context.update_def(&state, &def).unwrap();
let fn_sig = new_state.get_params_of_current_function();
assert!(fn_sig.contains(&(
&AbstractLocation::mock("sp:4", &[0], 4),
AccessPattern::new().with_read_flag()
)));
}

0 comments on commit 374657b

Please sign in to comment.