aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cortex-m-rt/tests')
-rw-r--r--cortex-m-rt/tests/README.md7
-rw-r--r--cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-2.rs18
-rw-r--r--cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-3.rs18
-rw-r--r--cortex-m-rt/tests/compile-fail/hard-fault-twice-mixed-trampoline.rs26
-rw-r--r--cortex-m-rt/tests/compile-fail/hard-fault-twice.rs2
5 files changed, 70 insertions, 1 deletions
diff --git a/cortex-m-rt/tests/README.md b/cortex-m-rt/tests/README.md
new file mode 100644
index 0000000..1d879fc
--- /dev/null
+++ b/cortex-m-rt/tests/README.md
@@ -0,0 +1,7 @@
+# How to run
+
+To run the compile tests, use the following command on the root of the project:
+
+```
+cargo test --package cortex-m-rt --test compiletest --features device
+```
diff --git a/cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-2.rs b/cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-2.rs
new file mode 100644
index 0000000..d20d832
--- /dev/null
+++ b/cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-2.rs
@@ -0,0 +1,18 @@
+#![no_main]
+#![no_std]
+
+extern crate cortex_m_rt;
+extern crate panic_halt;
+
+use cortex_m_rt::{entry, exception, ExceptionFrame};
+
+#[entry]
+fn foo() -> ! {
+ loop {}
+}
+
+#[exception(trampoline = true)]
+unsafe fn HardFault() -> ! {
+ //~^ ERROR `HardFault` handler must have signature `unsafe fn(&ExceptionFrame) -> !`
+ loop {}
+}
diff --git a/cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-3.rs b/cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-3.rs
new file mode 100644
index 0000000..62c8439
--- /dev/null
+++ b/cortex-m-rt/tests/compile-fail/hard-fault-bad-signature-3.rs
@@ -0,0 +1,18 @@
+#![no_main]
+#![no_std]
+
+extern crate cortex_m_rt;
+extern crate panic_halt;
+
+use cortex_m_rt::{entry, exception, ExceptionFrame};
+
+#[entry]
+fn foo() -> ! {
+ loop {}
+}
+
+#[exception(trampoline = false)]
+unsafe fn HardFault(_ef: &ExceptionFrame) -> ! {
+ //~^ ERROR `HardFault` handler must have signature `unsafe fn() -> !`
+ loop {}
+}
diff --git a/cortex-m-rt/tests/compile-fail/hard-fault-twice-mixed-trampoline.rs b/cortex-m-rt/tests/compile-fail/hard-fault-twice-mixed-trampoline.rs
new file mode 100644
index 0000000..3610170
--- /dev/null
+++ b/cortex-m-rt/tests/compile-fail/hard-fault-twice-mixed-trampoline.rs
@@ -0,0 +1,26 @@
+#![no_main]
+#![no_std]
+
+extern crate cortex_m_rt;
+extern crate panic_halt;
+
+use cortex_m_rt::{entry, exception, ExceptionFrame};
+
+#[entry]
+fn foo() -> ! {
+ loop {}
+}
+
+#[exception(trampoline = false)]
+unsafe fn HardFault() -> ! {
+ loop {}
+}
+
+pub mod reachable {
+ use cortex_m_rt::{exception, ExceptionFrame};
+
+ #[exception] //~ ERROR symbol `_HardFault` is already defined
+ unsafe fn HardFault(_ef: &ExceptionFrame) -> ! {
+ loop {}
+ }
+}
diff --git a/cortex-m-rt/tests/compile-fail/hard-fault-twice.rs b/cortex-m-rt/tests/compile-fail/hard-fault-twice.rs
index 03b79a5..af80127 100644
--- a/cortex-m-rt/tests/compile-fail/hard-fault-twice.rs
+++ b/cortex-m-rt/tests/compile-fail/hard-fault-twice.rs
@@ -19,7 +19,7 @@ unsafe fn HardFault(_ef: &ExceptionFrame) -> ! {
pub mod reachable {
use cortex_m_rt::{exception, ExceptionFrame};
- #[exception] //~ ERROR symbol `HardFault` is already defined
+ #[exception] //~ ERROR symbol `_HardFault` is already defined
unsafe fn HardFault(_ef: &ExceptionFrame) -> ! {
loop {}
}