Skip to content

Commit 5650346

Browse files
committed
Fix test for Android
1 parent 8b821cc commit 5650346

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/test/ui/process/process-panic-after-fork.rs

+22
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,29 @@ unsafe impl<A:GlobalAlloc> GlobalAlloc for PidChecking<A> {
7878
fn expect_aborted(status: ExitStatus) {
7979
dbg!(status);
8080
let signal = status.signal().expect("expected child process to die of signal");
81+
82+
#[cfg(not(target_os = "android"))]
8183
assert!(signal == libc::SIGABRT || signal == libc::SIGILL || signal == libc::SIGTRAP);
84+
85+
#[cfg(target_os = "android")]
86+
{
87+
// Android signals an abort() call with SIGSEGV at address 0xdeadbaad
88+
// See e.g. https://groups.google.com/g/android-ndk/c/laW1CJc7Icc
89+
assert!(signal == libc::SIGSEGV);
90+
// Check if the crash occured at addres deadbaad to ensure it is not some undefined
91+
// behavior but actually an abort
92+
let tombstone = (0..100)
93+
.map(|n| format!("/data/tombstones/tombstone_{n:02}"))
94+
.filter(|f| std::path::Path::new(&f).exists())
95+
.last()
96+
.expect("no tombstone found");
97+
let tombstone =
98+
std::fs::read_to_string(&tombstone).expect("Cannot read tombstone file");
99+
// If the next assert fails sporadically we might have an issue with parallel crashing apps
100+
assert!(tombstone
101+
.contains(&std::env::current_exe().unwrap().into_os_string().into_string().unwrap()));
102+
assert!(tombstone.contains("signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad"));
103+
}
82104
}
83105

84106
fn main() {

0 commit comments

Comments
 (0)