about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2014-10-23 07:29:41 +0200
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2014-10-24 14:36:29 +0200
commit70cef9474a3307ec763efc01fe6969e542083823 (patch)
treed555ef3ddf5fb14c6e28ba10b61708f53c0721af /src/test
parent50e86c26e0aa292e5e0452abd1830741f5bb525e (diff)
downloadrust-70cef9474a3307ec763efc01fe6969e542083823.tar.gz
rust-70cef9474a3307ec763efc01fe6969e542083823.zip
Print stack overflow messages for Windows, Linux and OS X
Fixes #17562
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/out-of-stack-new-thread-no-split.rs48
-rw-r--r--src/test/run-pass/out-of-stack-no-split.rs47
-rw-r--r--src/test/run-pass/out-of-stack.rs10
-rw-r--r--src/test/run-pass/segfault-no-out-of-stack.rs25
4 files changed, 122 insertions, 8 deletions
diff --git a/src/test/run-pass/out-of-stack-new-thread-no-split.rs b/src/test/run-pass/out-of-stack-new-thread-no-split.rs
new file mode 100644
index 00000000000..e4a42161322
--- /dev/null
+++ b/src/test/run-pass/out-of-stack-new-thread-no-split.rs
@@ -0,0 +1,48 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//ignore-android
+//ignore-freebsd
+//ignore-ios
+//ignore-dragonfly
+
+#![feature(asm)]
+
+use std::io::process::Command;
+use std::os;
+
+// lifted from the test module
+// Inlining to avoid llvm turning the recursive functions into tail calls,
+// which doesn't consume stack.
+#[inline(always)]
+#[no_stack_check]
+pub fn black_box<T>(dummy: T) { unsafe { asm!("" : : "r"(&dummy)) } }
+
+#[no_stack_check]
+fn recurse() {
+    let buf = [0i, ..10];
+    black_box(buf);
+    recurse();
+}
+
+fn main() {
+    let args = os::args();
+    let args = args.as_slice();
+    if args.len() > 1 && args[1].as_slice() == "recurse" {
+        spawn(proc() {
+            recurse();
+        });
+    } else {
+        let recurse = Command::new(args[0].as_slice()).arg("recurse").output().unwrap();
+        assert!(!recurse.status.success());
+        let error = String::from_utf8_lossy(recurse.error.as_slice());
+        assert!(error.as_slice().contains("has overflowed its stack"));
+    }
+}
diff --git a/src/test/run-pass/out-of-stack-no-split.rs b/src/test/run-pass/out-of-stack-no-split.rs
new file mode 100644
index 00000000000..ecb93cc6f8c
--- /dev/null
+++ b/src/test/run-pass/out-of-stack-no-split.rs
@@ -0,0 +1,47 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//ignore-android
+//ignore-linux
+//ignore-freebsd
+//ignore-ios
+//ignore-dragonfly
+
+#![feature(asm)]
+
+use std::io::process::Command;
+use std::os;
+
+// lifted from the test module
+// Inlining to avoid llvm turning the recursive functions into tail calls,
+// which doesn't consume stack.
+#[inline(always)]
+#[no_stack_check]
+pub fn black_box<T>(dummy: T) { unsafe { asm!("" : : "r"(&dummy)) } }
+
+#[no_stack_check]
+fn recurse() {
+    let buf = [0i, ..10];
+    black_box(buf);
+    recurse();
+}
+
+fn main() {
+    let args = os::args();
+    let args = args.as_slice();
+    if args.len() > 1 && args[1].as_slice() == "recurse" {
+        recurse();
+    } else {
+        let recurse = Command::new(args[0].as_slice()).arg("recurse").output().unwrap();
+        assert!(!recurse.status.success());
+        let error = String::from_utf8_lossy(recurse.error.as_slice());
+        assert!(error.as_slice().contains("has overflowed its stack"));
+    }
+}
diff --git a/src/test/run-pass/out-of-stack.rs b/src/test/run-pass/out-of-stack.rs
index bbaa09bfac3..7f2f9f9ece8 100644
--- a/src/test/run-pass/out-of-stack.rs
+++ b/src/test/run-pass/out-of-stack.rs
@@ -42,17 +42,11 @@ fn main() {
         let silent = Command::new(args[0].as_slice()).arg("silent").output().unwrap();
         assert!(!silent.status.success());
         let error = String::from_utf8_lossy(silent.error.as_slice());
-        // FIXME #17562: Windows is using stack probes and isn't wired up to print an error
-        if !cfg!(windows) {
-            assert!(error.as_slice().contains("has overflowed its stack"));
-        }
+        assert!(error.as_slice().contains("has overflowed its stack"));
 
         let loud = Command::new(args[0].as_slice()).arg("loud").output().unwrap();
         assert!(!loud.status.success());
         let error = String::from_utf8_lossy(silent.error.as_slice());
-        // FIXME #17562: Windows is using stack probes and isn't wired up to print an error
-        if !cfg!(windows) {
-            assert!(error.as_slice().contains("has overflowed its stack"));
-        }
+        assert!(error.as_slice().contains("has overflowed its stack"));
     }
 }
diff --git a/src/test/run-pass/segfault-no-out-of-stack.rs b/src/test/run-pass/segfault-no-out-of-stack.rs
new file mode 100644
index 00000000000..6ef33c1a112
--- /dev/null
+++ b/src/test/run-pass/segfault-no-out-of-stack.rs
@@ -0,0 +1,25 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::io::process::Command;
+use std::os;
+
+fn main() {
+    let args = os::args();
+    let args = args.as_slice();
+    if args.len() > 1 && args[1].as_slice() == "segfault" {
+        unsafe { *(0 as *mut int) = 1 }; // trigger a segfault
+    } else {
+        let segfault = Command::new(args[0].as_slice()).arg("segfault").output().unwrap();
+        assert!(!segfault.status.success());
+        let error = String::from_utf8_lossy(segfault.error.as_slice());
+        assert!(!error.as_slice().contains("has overflowed its stack"));
+    }
+}