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