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)
17 use std::process::Command;
20 // lifted from the test module
21 // Inlining to avoid llvm turning the recursive functions into tail calls,
22 // which doesn't consume stack.
24 pub fn black_box<T>(dummy: T) { unsafe { asm!("" : : "r"(&dummy)) } }
27 let buf = [0u8; 1000];
35 black_box(()); // don't optimize this into a tail call. please.
39 let args: Vec<String> = env::args().collect();
40 if args.len() > 1 && args[1] == "silent" {
42 } else if args.len() > 1 && args[1] == "loud" {
44 } else if args.len() > 1 && args[1] == "silent-thread" {
45 thread::spawn(silent_recurse).join();
46 } else if args.len() > 1 && args[1] == "loud-thread" {
47 thread::spawn(loud_recurse).join();
54 // On linux it looks like the main thread can sometimes grow its stack
55 // basically without bounds, so we only test the child thread cases
57 if !cfg!(target_os = "linux") {
62 println!("testing: {}", mode);
64 let silent = Command::new(&args[0]).arg(mode).output().unwrap();
65 assert!(!silent.status.success());
66 let error = String::from_utf8_lossy(&silent.stderr);
67 assert!(error.contains("has overflowed its stack"),
68 "missing overflow message: {}", error);