summaryrefslogtreecommitdiff
path: root/kernel/tests/stack_overflow.rs
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/tests/stack_overflow.rs')
-rw-r--r--kernel/tests/stack_overflow.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/kernel/tests/stack_overflow.rs b/kernel/tests/stack_overflow.rs
new file mode 100644
index 0000000..677a9e1
--- /dev/null
+++ b/kernel/tests/stack_overflow.rs
@@ -0,0 +1,37 @@
+#![no_main]
+#![feature(compiler_builtins_lib)]
+#![feature(custom_test_frameworks)]
+#![feature(abi_x86_interrupt)]
+#![feature(panic_info_message)]
+#![test_runner(kernel::testing::serial_test_runner_panic)]
+#![no_std]
+
+use core::fmt::Write;
+use kernel;
+use kernel::io::qemu;
+
+#[no_mangle]
+extern "C" fn _start() -> ! {
+ kernel::init();
+ _loop(0);
+
+ loop {}
+}
+
+fn _loop(i: u128) -> u128 {
+ if i > 1u128 << 83 {
+ return i;
+ }
+ let n = i;
+ let mut stdout = kernel::OStream::new();
+ write!(&mut stdout, "{:x}", &n as *const u128 as u128).unwrap();
+ _loop(i + 1)
+}
+
+#[cfg(test)]
+#[panic_handler]
+#[no_mangle]
+extern "C" fn panic_handler(info: &core::panic::PanicInfo) -> ! {
+ kernel::testing::serial_should_panic(info);
+ loop {}
+}