From 08cac7fd75651dbe18545d36ae96556ba17bb485 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 18 Nov 2024 17:29:33 -0300 Subject: [PATCH] Test unregistered callx in both versions --- tests/execution.rs | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/tests/execution.rs b/tests/execution.rs index 3cacd0dc..23d6a9a4 100644 --- a/tests/execution.rs +++ b/tests/execution.rs @@ -2364,19 +2364,33 @@ fn test_callx() { #[test] fn test_err_callx_unregistered() { + let versions = [SBPFVersion::V1, SBPFVersion::V2]; + let expected_errors = [ + EbpfError::CallOutsideTextSegment, + EbpfError::UnsupportedInstruction, + ]; + // We execute three instructions when callx errors out. - test_interpreter_and_jit_asm!( - " - mov64 r0, 0x0 - or64 r8, 0x20 - callx r8 - exit - mov64 r0, 0x2A - exit", - [], - TestContextObject::new(3), - ProgramResult::Err(EbpfError::UnsupportedInstruction), - ); + for (version, error) in versions.iter().zip(expected_errors) { + let config = Config { + enabled_sbpf_versions: *version..=*version, + ..Config::default() + }; + + test_interpreter_and_jit_asm!( + " + mov64 r0, 0x0 + or64 r8, 0x20 + callx r8 + exit + mov64 r0, 0x2A + exit", + config, + [], + TestContextObject::new(3), + ProgramResult::Err(error), + ); + } } #[test]