Skip to content

Commit

Permalink
Moves test_err_unresolved_syscall_reloc_64_32.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Oct 7, 2024
1 parent c426bce commit 7b758a2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
16 changes: 16 additions & 0 deletions src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
19 changes: 0 additions & 19 deletions tests/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<TestContextObject>::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
Expand Down

0 comments on commit 7b758a2

Please sign in to comment.