Skip to content

Commit

Permalink
Add invalid syscall test
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasSte committed Oct 20, 2024
1 parent cc04cf8 commit 6768eb3
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4132,3 +4132,35 @@ fn test_invalid_exit_or_return() {
);
}
}

#[test]
fn test_unregistered_syscall() {
let prog = &[
0xbf, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // mov64 r0, 2
0x95, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // syscall 2
0x9d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // return
];

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

let loader = Arc::new(BuiltinProgram::new_loader_with_dense_registration(config));
let mut executable = Executable::<TestContextObject>::from_text_bytes(
prog,
loader,
SBPFVersion::V2,
FunctionRegistry::default(),
)
.unwrap();

test_interpreter_and_jit!(
false,
executable,
[],
TestContextObject::new(2),
ProgramResult::Err(EbpfError::UnsupportedInstruction),
);
}

0 comments on commit 6768eb3

Please sign in to comment.