From e724f76288bfcb7b45218cb21d612428ca92623c 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 | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/tests/execution.rs b/tests/execution.rs index 3cacd0dc..681c0df0 100644 --- a/tests/execution.rs +++ b/tests/execution.rs @@ -2364,19 +2364,32 @@ fn test_callx() { #[test] fn test_err_callx_unregistered() { - // 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), - ); + let versions = [SBPFVersion::V1, SBPFVersion::V2]; + let expected_errors = [ + EbpfError::CallOutsideTextSegment, + 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]