Skip to content

Commit

Permalink
Add more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasSte committed Nov 19, 2024
1 parent deec3ad commit ef72d90
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2364,6 +2364,46 @@ fn test_callx() {

#[test]
fn test_err_callx_unregistered() {
let config = Config {
enabled_sbpf_versions: SBPFVersion::V1..=SBPFVersion::V1,
..Config::default()
};

// Callx jumps to `mov64 r0, 0x2A`
test_interpreter_and_jit_asm!(
"
mov64 r0, 0x0
lddw r8, 0x100000028
callx r8
exit
mov64 r0, 0x2A
exit",
config,
[],
TestContextObject::new(6),
ProgramResult::Ok(42),
);

let config = Config {
enabled_sbpf_versions: SBPFVersion::V2..=SBPFVersion::V2,
..Config::default()
};

// Callx jumps to `mov64 r0, 0x2A`
test_interpreter_and_jit_asm!(
"
mov64 r0, 0x0
or64 r8, 0x28
callx r8
exit
mov64 r0, 0x2A
exit",
config,
[],
TestContextObject::new(3),
ProgramResult::Err(EbpfError::UnsupportedInstruction),
);

let versions = [SBPFVersion::V1, SBPFVersion::V2];
let expected_errors = [
EbpfError::CallOutsideTextSegment,
Expand All @@ -2377,6 +2417,7 @@ fn test_err_callx_unregistered() {
..Config::default()
};

// Callx jumps to a location outside text segment
test_interpreter_and_jit_asm!(
"
mov64 r0, 0x0
Expand Down

0 comments on commit ef72d90

Please sign in to comment.