3 #![allow(unused_must_use)]
4 #![allow(unconditional_recursion)]
5 // ignore-android: FIXME (#20004)
6 // ignore-emscripten no processes
7 // ignore-sgx no processes
10 #![feature(rustc_private)]
16 use std::process::Command;
19 // lifted from the test module
20 // Inlining to avoid llvm turning the recursive functions into tail calls,
21 // which doesn't consume stack.
23 pub fn black_box<T>(dummy: T) { unsafe { llvm_asm!("" : : "r"(&dummy)) } }
26 let buf = [0u8; 1000];
34 black_box(()); // don't optimize this into a tail call. please.
38 fn check_status(status: std::process::ExitStatus)
40 use std::os::unix::process::ExitStatusExt;
42 assert!(!status.success());
43 assert_eq!(status.signal(), Some(libc::SIGABRT));
47 fn check_status(status: std::process::ExitStatus)
49 assert!(!status.success());
54 let args: Vec<String> = env::args().collect();
55 if args.len() > 1 && args[1] == "silent" {
57 } else if args.len() > 1 && args[1] == "loud" {
59 } else if args.len() > 1 && args[1] == "silent-thread" {
60 thread::spawn(silent_recurse).join();
61 } else if args.len() > 1 && args[1] == "loud-thread" {
62 thread::spawn(loud_recurse).join();
69 // On linux it looks like the main thread can sometimes grow its stack
70 // basically without bounds, so we only test the child thread cases
72 if !cfg!(target_os = "linux") {
77 println!("testing: {}", mode);
79 let silent = Command::new(&args[0]).arg(mode).output().unwrap();
81 check_status(silent.status);
83 let error = String::from_utf8_lossy(&silent.stderr);
84 assert!(error.contains("has overflowed its stack"),
85 "missing overflow message: {}", error);