| ... | @@ -26,6 +26,10 @@ fn crash_child() { | ... | @@ -26,6 +26,10 @@ fn crash_child() { |
| 26 | crash_report::conceal("AI.one"); | 26 | crash_report::conceal("AI.one"); |
| 27 | let _ = std::panic::catch_unwind(|| panic!("Cannot read section AI")); | 27 | let _ = std::panic::catch_unwind(|| panic!("Cannot read section AI")); |
| 28 | } | 28 | } |
| | 29 | #[cfg(target_vendor = "apple")] |
| | 30 | if std::env::var_os("SNOWBOUND_TEST_TRAP").is_some() { |
| | 31 | unsafe { libc::raise(libc::SIGTRAP) }; |
| | 32 | } |
| 29 | std::process::abort(); | 33 | std::process::abort(); |
| 30 | } | 34 | } |
| 31 | | 35 | |
| ... | @@ -36,10 +40,13 @@ fn fatal_signals_leave_a_report_and_preserve_the_first_panic() { | ... | @@ -36,10 +40,13 @@ fn fatal_signals_leave_a_report_and_preserve_the_first_panic() { |
| 36 | process::{Command, Stdio}, | 40 | process::{Command, Stdio}, |
| 37 | }; | 41 | }; |
| 38 | let folder = tempfile::tempdir().unwrap(); | 42 | let folder = tempfile::tempdir().unwrap(); |
| 39 | for panic in [false, true] { | 43 | let trap = cfg!(target_vendor = "apple"); |
| 40 | let report = folder | 44 | for (panic, trap) in [(false, false), (true, false), (false, trap)] { |
| 41 | .path() | 45 | let report = folder.path().join(match (panic, trap) { |
| 42 | .join(if panic { "panic.txt" } else { "native.txt" }); | 46 | (true, _) => "panic.txt", |
| | 47 | (_, true) => "trap.txt", |
| | 48 | _ => "native.txt", |
| | 49 | }); |
| 43 | let mut child = Command::new(std::env::current_exe().unwrap()); | 50 | let mut child = Command::new(std::env::current_exe().unwrap()); |
| 44 | child | 51 | child |
| 45 | .args(["--exact", "crash_child", "--nocapture"]) | 52 | .args(["--exact", "crash_child", "--nocapture"]) |
| ... | @@ -49,7 +56,11 @@ fn fatal_signals_leave_a_report_and_preserve_the_first_panic() { | ... | @@ -49,7 +56,11 @@ fn fatal_signals_leave_a_report_and_preserve_the_first_panic() { |
| 49 | if panic { | 56 | if panic { |
| 50 | child.env("SNOWBOUND_TEST_PANIC", "1"); | 57 | child.env("SNOWBOUND_TEST_PANIC", "1"); |
| 51 | } | 58 | } |
| 52 | assert_eq!(child.status().unwrap().signal(), Some(libc::SIGABRT)); | 59 | if trap { |
| | 60 | child.env("SNOWBOUND_TEST_TRAP", "1"); |
| | 61 | } |
| | 62 | let signal = if trap { libc::SIGTRAP } else { libc::SIGABRT }; |
| | 63 | assert_eq!(child.status().unwrap().signal(), Some(signal)); |
| 53 | let saved = std::fs::read_to_string(report).unwrap(); | 64 | let saved = std::fs::read_to_string(report).unwrap(); |
| 54 | assert!( | 65 | assert!( |
| 55 | saved.starts_with("Snowbound test, native-test\nSystem: test system\n"), | 66 | saved.starts_with("Snowbound test, native-test\nSystem: test system\n"), |
| ... | @@ -62,7 +73,10 @@ fn fatal_signals_leave_a_report_and_preserve_the_first_panic() { | ... | @@ -62,7 +73,10 @@ fn fatal_signals_leave_a_report_and_preserve_the_first_panic() { |
| 62 | ); | 73 | ); |
| 63 | assert!(!saved.contains("Native signal"), "{saved}"); | 74 | assert!(!saved.contains("Native signal"), "{saved}"); |
| 64 | } else { | 75 | } else { |
| 65 | assert!(saved.contains("Native signal:"), "{saved}"); | 76 | assert!( |
| | 77 | saved.contains(&format!("Native signal: 0x{signal:016x}\n")), |
| | 78 | "{saved}" |
| | 79 | ); |
| 66 | assert!(!saved.contains("Fault address:"), "{saved}"); | 80 | assert!(!saved.contains("Fault address:"), "{saved}"); |
| 67 | } | 81 | } |
| 68 | } | 82 | } |