]> git.proxmox.com Git - cargo.git/blob - vendor/backtrace/tests/skip_inner_frames.rs
New upstream version 0.33.0
[cargo.git] / vendor / backtrace / tests / skip_inner_frames.rs
1 extern crate backtrace;
2
3 use backtrace::Backtrace;
4
5 const FRAME_RANGE: usize = 128; // should be close enough not to give false positives
6
7 #[test]
8 #[cfg_attr(any(not(any(feature = "libunwind", feature = "unix-backtrace", feature = "dbghelp")), all(target_os = "windows", target_arch = "x86")), ignore)]
9 fn backtrace_new_unresolved_should_start_with_call_site_trace() {
10 let mut b = Backtrace::new_unresolved();
11 b.resolve();
12 println!("{:?}", b);
13 println!("{:#?}", b);
14
15 assert!(!b.frames().is_empty());
16
17 let this_ip = backtrace_new_unresolved_should_start_with_call_site_trace as usize;
18 let frame_ip = b.frames().first().unwrap().ip() as usize;
19
20 assert!(frame_ip >= this_ip);
21 assert!(frame_ip <= this_ip + FRAME_RANGE);
22 }
23
24 #[test]
25 #[cfg_attr(any(not(any(feature = "libunwind", feature = "unix-backtrace", feature = "dbghelp")), all(target_os = "windows", target_arch = "x86")), ignore)]
26 fn backtrace_new_should_start_with_call_site_trace() {
27 let b = Backtrace::new();
28 println!("{:?}", b);
29
30 assert!(!b.frames().is_empty());
31
32 let this_ip = backtrace_new_should_start_with_call_site_trace as usize;
33 let frame_ip = b.frames().first().unwrap().ip() as usize;
34
35 assert!(frame_ip >= this_ip);
36 assert!(frame_ip <= this_ip + FRAME_RANGE);
37 }