From 7b758a25577058e7c6fc0c0e0c42470b6707c54c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Mon, 7 Oct 2024 16:03:11 +0200 Subject: [PATCH] Moves test_err_unresolved_syscall_reloc_64_32. --- src/elf.rs | 16 ++++++++++++++++ tests/execution.rs | 19 ------------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/elf.rs b/src/elf.rs index b306a3790..375c80404 100644 --- a/src/elf.rs +++ b/src/elf.rs @@ -1916,6 +1916,22 @@ mod test { ElfExecutable::load(&elf_bytes, loader()).expect("validation failed"); } + #[test] + #[should_panic(expected = "validation failed: UnresolvedSymbol(\"log\", 39, 312)")] + fn test_err_unresolved_syscall_reloc_64_32() { + let loader = BuiltinProgram::new_loader( + Config { + enabled_sbpf_versions: SBPFVersion::V1..=SBPFVersion::V1, + reject_broken_elfs: true, + ..Config::default() + }, + FunctionRegistry::default(), + ); + let elf_bytes = std::fs::read("tests/elfs/syscall_reloc_64_32_sbpfv1.so") + .expect("failed to read elf file"); + ElfExecutable::load(&elf_bytes, Arc::new(loader)).expect("validation failed"); + } + #[test] fn test_long_section_name() { let elf_bytes = std::fs::read("tests/elfs/long_section_name.so").unwrap(); diff --git a/tests/execution.rs b/tests/execution.rs index 00259f110..3eea021aa 100644 --- a/tests/execution.rs +++ b/tests/execution.rs @@ -3035,25 +3035,6 @@ fn test_syscall_reloc_64_32() { ); } -#[test] -fn test_err_unresolved_syscall_reloc_64_32() { - let loader = BuiltinProgram::new_loader( - Config { - enabled_sbpf_versions: SBPFVersion::V1..=SBPFVersion::V1, - reject_broken_elfs: true, - ..Config::default() - }, - FunctionRegistry::default(), - ); - let mut file = File::open("tests/elfs/syscall_reloc_64_32_sbpfv1.so").unwrap(); - let mut elf = Vec::new(); - file.read_to_end(&mut elf).unwrap(); - assert_error!( - Executable::::from_elf(&elf, Arc::new(loader)), - "UnresolvedSymbol(\"log\", 39, 312)" - ); -} - #[test] fn test_reloc_64_64_sbpfv1() { // Tests the correctness of R_BPF_64_64 relocations. The program returns the