1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // ignore-android: FIXME (#20004)
22 use std::process::Command;
25 // lifted from the test module
26 // Inlining to avoid llvm turning the recursive functions into tail calls,
27 // which doesn't consume stack.
29 pub fn black_box<T>(dummy: T) { unsafe { asm!("" : : "r"(&dummy)) } }
32 let buf = [0u8; 1000];
40 black_box(()); // don't optimize this into a tail call. please.
44 fn check_status(status: std::process::ExitStatus)
47 use std::os::unix::process::ExitStatusExt;
49 assert!(!status.success());
50 assert_eq!(status.signal(), Some(libc::SIGABRT));
54 fn check_status(status: std::process::ExitStatus)
56 assert!(!status.success());
61 let args: Vec<String> = env::args().collect();
62 if args.len() > 1 && args[1] == "silent" {
64 } else if args.len() > 1 && args[1] == "loud" {
66 } else if args.len() > 1 && args[1] == "silent-thread" {
67 thread::spawn(silent_recurse).join();
68 } else if args.len() > 1 && args[1] == "loud-thread" {
69 thread::spawn(loud_recurse).join();
76 // On linux it looks like the main thread can sometimes grow its stack
77 // basically without bounds, so we only test the child thread cases
79 if !cfg!(target_os = "linux") {
84 println!("testing: {}", mode);
86 let silent = Command::new(&args[0]).arg(mode).output().unwrap();
88 check_status(silent.status);
90 let error = String::from_utf8_lossy(&silent.stderr);
91 assert!(error.contains("has overflowed its stack"),
92 "missing overflow message: {}", error);