summaryrefslogtreecommitdiffstats
path: root/vendor/addr2line/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/addr2line/tests
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/addr2line/tests')
-rw-r--r--vendor/addr2line/tests/correctness.rs56
-rw-r--r--vendor/addr2line/tests/output_equivalence.rs35
-rw-r--r--vendor/addr2line/tests/parse.rs12
3 files changed, 61 insertions, 42 deletions
diff --git a/vendor/addr2line/tests/correctness.rs b/vendor/addr2line/tests/correctness.rs
index 955e2b831..73ee462f8 100644
--- a/vendor/addr2line/tests/correctness.rs
+++ b/vendor/addr2line/tests/correctness.rs
@@ -1,15 +1,10 @@
-extern crate addr2line;
-extern crate fallible_iterator;
-extern crate findshlibs;
-extern crate gimli;
-extern crate memmap2;
-extern crate object;
-
use addr2line::Context;
use fallible_iterator::FallibleIterator;
use findshlibs::{IterationControl, SharedLibrary, TargetSharedLibrary};
use object::Object;
+use std::borrow::Cow;
use std::fs::File;
+use std::sync::Arc;
fn find_debuginfo() -> memmap2::Mmap {
let path = std::env::current_exe().unwrap();
@@ -42,7 +37,37 @@ fn correctness() {
let map = find_debuginfo();
let file = &object::File::parse(&*map).unwrap();
let module_base = file.relative_address_base();
- let ctx = Context::new(file).unwrap();
+
+ let endian = if file.is_little_endian() {
+ gimli::RunTimeEndian::Little
+ } else {
+ gimli::RunTimeEndian::Big
+ };
+
+ fn load_section<'data: 'file, 'file, O, Endian>(
+ id: gimli::SectionId,
+ file: &'file O,
+ endian: Endian,
+ ) -> Result<gimli::EndianArcSlice<Endian>, gimli::Error>
+ where
+ O: object::Object<'data, 'file>,
+ Endian: gimli::Endianity,
+ {
+ use object::ObjectSection;
+
+ let data = file
+ .section_by_name(id.name())
+ .and_then(|section| section.uncompressed_data().ok())
+ .unwrap_or(Cow::Borrowed(&[]));
+ Ok(gimli::EndianArcSlice::new(Arc::from(&*data), endian))
+ }
+
+ let dwarf = gimli::Dwarf::load(|id| load_section(id, file, endian)).unwrap();
+ let ctx = Context::from_dwarf(dwarf).unwrap();
+ let mut split_dwarf_loader = addr2line::builtin_split_dwarf_loader::SplitDwarfLoader::new(
+ |data, endian| gimli::EndianArcSlice::new(Arc::from(&*data), endian),
+ None,
+ );
let mut bias = None;
TargetSharedLibrary::each(|lib| {
@@ -50,10 +75,12 @@ fn correctness() {
IterationControl::Break
});
- let test = |sym: u64, expected_prefix: &str| {
+ #[allow(unused_mut)]
+ let mut test = |sym: u64, expected_prefix: &str| {
let ip = sym.wrapping_sub(bias.unwrap());
- let frames = ctx.find_frames(ip).unwrap();
+ let frames = ctx.find_frames(ip);
+ let frames = split_dwarf_loader.run(frames).unwrap();
let frame = frames.last().unwrap().unwrap();
let name = frame.function.as_ref().unwrap().demangle().unwrap();
// Old rust versions generate DWARF with wrong linkage name,
@@ -87,6 +114,13 @@ fn zero_function() {
let file = &object::File::parse(&*map).unwrap();
let ctx = Context::new(file).unwrap();
for probe in 0..10 {
- assert!(ctx.find_frames(probe).unwrap().count().unwrap() < 10);
+ assert!(
+ ctx.find_frames(probe)
+ .skip_all_loads()
+ .unwrap()
+ .count()
+ .unwrap()
+ < 10
+ );
}
}
diff --git a/vendor/addr2line/tests/output_equivalence.rs b/vendor/addr2line/tests/output_equivalence.rs
index c0e1f8335..ef026e347 100644
--- a/vendor/addr2line/tests/output_equivalence.rs
+++ b/vendor/addr2line/tests/output_equivalence.rs
@@ -1,7 +1,3 @@
-extern crate backtrace;
-extern crate findshlibs;
-extern crate rustc_test as test;
-
use std::env;
use std::ffi::OsStr;
use std::path::Path;
@@ -9,7 +5,7 @@ use std::process::Command;
use backtrace::Backtrace;
use findshlibs::{IterationControl, SharedLibrary, TargetSharedLibrary};
-use test::{ShouldPanic, TestDesc, TestDescAndFn, TestFn, TestName};
+use libtest_mimic::{Arguments, Failed, Trial};
#[inline(never)]
fn make_trace() -> Vec<String> {
@@ -57,7 +53,7 @@ fn run_cmd<P: AsRef<OsStr>>(exe: P, me: &Path, flags: Option<&str>, trace: &str)
String::from_utf8(output.stdout).unwrap()
}
-fn run_test(flags: Option<&str>) {
+fn run_test(flags: Option<&str>) -> Result<(), Failed> {
let me = env::current_exe().unwrap();
let mut exe = me.clone();
assert!(exe.pop());
@@ -100,11 +96,12 @@ $ {3} {0} --exe {1} {2}
ours
);
}
+ Ok(())
}
-static FLAGS: &'static str = "aipsf";
+static FLAGS: &str = "aipsf";
-fn make_tests() -> Vec<TestDescAndFn> {
+fn make_tests() -> Vec<Trial> {
(0..(1 << FLAGS.len()))
.map(|bits| {
if bits == 0 {
@@ -120,19 +117,11 @@ fn make_tests() -> Vec<TestDescAndFn> {
Some(param)
}
})
- .map(|param| TestDescAndFn {
- desc: TestDesc {
- name: TestName::DynTestName(format!(
- "addr2line {}",
- param.as_ref().map_or("", String::as_str)
- )),
- ignore: false,
- should_panic: ShouldPanic::No,
- allow_fail: false,
- },
- testfn: TestFn::DynTestFn(Box::new(move || {
- run_test(param.as_ref().map(String::as_str))
- })),
+ .map(|param| {
+ Trial::test(
+ format!("addr2line {}", param.as_ref().map_or("", String::as_str)),
+ move || run_test(param.as_ref().map(String::as_str)),
+ )
})
.collect()
}
@@ -141,6 +130,6 @@ fn main() {
if !cfg!(target_os = "linux") {
return;
}
- let args: Vec<_> = env::args().collect();
- test::test_main(&args, make_tests());
+ let args = Arguments::from_args();
+ libtest_mimic::run(&args, make_tests()).exit();
}
diff --git a/vendor/addr2line/tests/parse.rs b/vendor/addr2line/tests/parse.rs
index 60b2300b5..4dafe385c 100644
--- a/vendor/addr2line/tests/parse.rs
+++ b/vendor/addr2line/tests/parse.rs
@@ -1,7 +1,3 @@
-extern crate addr2line;
-extern crate memmap2;
-extern crate object;
-
use std::borrow::Cow;
use std::env;
use std::fs::File;
@@ -23,7 +19,7 @@ fn release_fixture_path() -> PathBuf {
path
}
-fn with_file<F: FnOnce(&object::File)>(target: &path::Path, f: F) {
+fn with_file<F: FnOnce(&object::File<'_>)>(target: &path::Path, f: F) {
let file = File::open(target).unwrap();
let map = unsafe { memmap2::Mmap::map(&file).unwrap() };
let file = object::File::parse(&*map).unwrap();
@@ -44,12 +40,12 @@ fn dwarf_load<'a>(object: &object::File<'a>) -> gimli::Dwarf<Cow<'a, [u8]>> {
}
fn dwarf_borrow<'a>(
- dwarf: &'a gimli::Dwarf<Cow<[u8]>>,
+ dwarf: &'a gimli::Dwarf<Cow<'_, [u8]>>,
) -> gimli::Dwarf<gimli::EndianSlice<'a, gimli::LittleEndian>> {
let borrow_section: &dyn for<'b> Fn(
- &'b Cow<[u8]>,
+ &'b Cow<'_, [u8]>,
) -> gimli::EndianSlice<'b, gimli::LittleEndian> =
- &|section| gimli::EndianSlice::new(&*section, gimli::LittleEndian);
+ &|section| gimli::EndianSlice::new(section, gimli::LittleEndian);
dwarf.borrow(&borrow_section)
}