aboutsummaryrefslogtreecommitdiff
path: root/tests/cfail
diff options
context:
space:
mode:
authorJorge Aparicio <jorge@japaric.io>2017-07-27 11:40:15 -0500
committerJorge Aparicio <jorge@japaric.io>2017-07-27 11:40:15 -0500
commitaa2249454975a203e459597005944f5370c1d200 (patch)
treeb6cf75b34302cf7681712c82bffa2841631ef998 /tests/cfail
parent0b5afce771cb9e5cc42c4fd4c5e18f020bf1ecad (diff)
update tests and examples
with task! gone 3 types of errors / gotchas have been eliminated :tada:
Diffstat (limited to 'tests/cfail')
-rw-r--r--tests/cfail/critical-section.rs16
-rw-r--r--tests/cfail/duplicated-handler-2.rs40
-rw-r--r--tests/cfail/duplicated-handler.rs36
-rw-r--r--tests/cfail/local-token.rs45
-rw-r--r--tests/cfail/lock.rs22
-rw-r--r--tests/cfail/priority-too-high.rs8
-rw-r--r--tests/cfail/priority-too-low.rs8
-rw-r--r--tests/cfail/token-outlive.rs7
-rw-r--r--tests/cfail/token-transfer.rs4
-rw-r--r--tests/cfail/wrong-threshold.rs7
10 files changed, 27 insertions, 166 deletions
diff --git a/tests/cfail/critical-section.rs b/tests/cfail/critical-section.rs
index 3c8f0a9..7e73fd3 100644
--- a/tests/cfail/critical-section.rs
+++ b/tests/cfail/critical-section.rs
@@ -3,7 +3,6 @@
#![feature(proc_macro)]
#![no_std]
-#[macro_use(task)]
extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx;
@@ -13,18 +12,19 @@ app! {
device: stm32f103xx,
resources: {
- static STATE: bool = false;
+ static ON: bool = false;
},
idle: {
- resources: [STATE],
+ resources: [ON],
},
tasks: {
EXTI0: {
enabled: true,
+ path: exti0,
priority: 1,
- resources: [STATE],
+ resources: [ON],
},
},
}
@@ -32,12 +32,12 @@ app! {
fn init(_p: init::Peripherals, _r: init::Resources) {}
fn idle(t: &mut Threshold, r: idle::Resources) -> ! {
- let state = rtfm::atomic(|cs| {
+ let state = rtfm::atomic(t, |t| {
// ERROR borrow can't escape this *global* critical section
- r.STATE.borrow(cs) //~ error cannot infer an appropriate lifetime
+ r.ON.borrow(t) //~ error cannot infer an appropriate lifetime
});
- let state = r.STATE.claim(t, |state, _t| {
+ let state = r.ON.claim(t, |state, _t| {
// ERROR borrow can't escape this critical section
state //~ error cannot infer an appropriate lifetime
});
@@ -45,6 +45,4 @@ fn idle(t: &mut Threshold, r: idle::Resources) -> ! {
loop {}
}
-task!(EXTI0, exti0);
-
fn exti0(_t: &mut Threshold, _r: EXTI0::Resources) {}
diff --git a/tests/cfail/duplicated-handler-2.rs b/tests/cfail/duplicated-handler-2.rs
deleted file mode 100644
index d02770c..0000000
--- a/tests/cfail/duplicated-handler-2.rs
+++ /dev/null
@@ -1,40 +0,0 @@
-#![deny(warnings)]
-#![feature(proc_macro)]
-#![no_std]
-
-#[macro_use(task)]
-extern crate cortex_m_rtfm as rtfm;
-extern crate stm32f103xx;
-
-use rtfm::{app, Threshold};
-
-app! {
- device: stm32f103xx,
-
- resources: {
- static ON: bool = false;
- },
-
- tasks: {
- EXTI0: {
- enabled: true,
- path: exti0,
- priority: 1,
- resources: [ON],
- },
- },
-}
-
-fn init(_p: init::Peripherals, _r: init::Resources) {}
-
-fn idle() -> ! {
- loop {}
-}
-
-fn exti0(_r: EXTI0::Resources) {}
-
-// ERROR can't override the task handler specified in `app!`
-task!(EXTI0, exti1);
-//~^ error cannot find value `EXTI0`
-
-fn exti1(_t: &mut Threshold, _r: EXTI0::Resources) {}
diff --git a/tests/cfail/duplicated-handler.rs b/tests/cfail/duplicated-handler.rs
deleted file mode 100644
index d7741b5..0000000
--- a/tests/cfail/duplicated-handler.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// error-pattern: the name `EXTI0` is defined multiple times
-
-#![deny(warnings)]
-#![feature(proc_macro)]
-#![no_std]
-
-#[macro_use(task)]
-extern crate cortex_m_rtfm as rtfm;
-extern crate stm32f103xx;
-
-use rtfm::{app, Threshold};
-
-app! {
- device: stm32f103xx,
-
- tasks: {
- EXTI0: {
- enabled: true,
- priority: 1,
- },
- },
-}
-
-fn init(_p: init::Peripherals) {}
-
-fn idle() -> ! {
- loop {}
-}
-
-task!(EXTI0, exti0);
-
-fn exti0(_t: &mut Threshold, _r: EXTI0::Resources) {}
-
-task!(EXTI0, exti1);
-
-fn exti1(_t: &mut Threshold, _r: EXTI0::Resources) {}
diff --git a/tests/cfail/local-token.rs b/tests/cfail/local-token.rs
deleted file mode 100644
index 90a9560..0000000
--- a/tests/cfail/local-token.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-#![deny(warnings)]
-#![feature(const_fn)]
-#![feature(proc_macro)]
-#![no_std]
-
-#[macro_use(task)]
-extern crate cortex_m_rtfm as rtfm;
-extern crate stm32f103xx;
-
-use rtfm::{app, Threshold};
-
-app! {
- device: stm32f103xx,
-
- tasks: {
- EXTI0: {
- enabled: true,
- priority: 1,
- },
- }
-}
-
-fn init(_p: init::Peripherals) {}
-
-fn idle() -> ! {
- loop {}
-}
-
-task!(EXTI0, exti0, Old {
- static TOKEN: Option<Threshold> = None;
-});
-
-fn exti0(nt: &mut Threshold, old: &mut Old, _r: EXTI0::Resources) {
- if let Some(ot) = old.TOKEN.take() {
- let _: (Threshold, Threshold) = (*nt, ot);
- //~^ error cannot move out of borrowed content
-
- return
- }
-
- // ERROR can't store a threshold token in a local variable, otherwise you
- // would end up with two threshold tokens in a task (see `if let` above)
- *old.TOKEN = Some(*nt);
- //~^ error cannot move out of borrowed content
-}
diff --git a/tests/cfail/lock.rs b/tests/cfail/lock.rs
index 77310dd..8e6da46 100644
--- a/tests/cfail/lock.rs
+++ b/tests/cfail/lock.rs
@@ -3,7 +3,6 @@
#![feature(proc_macro)]
#![no_std]
-#[macro_use(task)]
extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx;
@@ -13,25 +12,28 @@ app! {
device: stm32f103xx,
resources: {
- static STATE: bool = false;
+ static ON: bool = false;
static MAX: u8 = 0;
},
tasks: {
EXTI0: {
enabled: true,
+ path: exti0,
priority: 1,
- resources: [MAX, STATE],
+ resources: [MAX, ON],
},
EXTI1: {
enabled: true,
+ path: exti1,
priority: 2,
- resources: [STATE],
+ resources: [ON],
},
EXTI2: {
enabled: true,
+ path: exti2,
priority: 16,
resources: [MAX],
},
@@ -44,29 +46,23 @@ fn idle() -> ! {
loop {}
}
-task!(EXTI0, exti0);
-
fn exti0(mut t: &mut Threshold, mut r: EXTI0::Resources) {
// OK need to lock to access the resource
- if r.STATE.claim(&mut t, |state, _| **state) {}
+ if r.ON.claim(&mut t, |on, _| **on) {}
// OK can claim a resource with maximum ceiling
r.MAX.claim_mut(&mut t, |max, _| **max += 1);
}
-task!(EXTI1, exti1);
-
fn exti1(mut t: &mut Threshold, r: EXTI1::Resources) {
// ERROR no need to lock. Has direct access because priority == ceiling
- if (**r.STATE).claim(&mut t, |state, _| **state) {
+ if (**r.ON).claim(&mut t, |on, _| **on) {
//~^ error no method named `claim` found for type
}
- if **r.STATE {
+ if **r.ON {
// OK
}
}
-task!(EXTI2, exti2);
-
fn exti2(_t: &mut Threshold, _r: EXTI2::Resources) {}
diff --git a/tests/cfail/priority-too-high.rs b/tests/cfail/priority-too-high.rs
index 01ddc03..c139471 100644
--- a/tests/cfail/priority-too-high.rs
+++ b/tests/cfail/priority-too-high.rs
@@ -2,17 +2,17 @@
#![feature(proc_macro)]
#![no_std]
-#[macro_use(task)]
extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx;
-use rtfm::{app, Threshold};
+use rtfm::app;
app! { //~ error attempt to subtract with overflow
device: stm32f103xx,
tasks: {
SYS_TICK: {
+ path: sys_tick,
// ERROR priority must be in the range [1, 16]
priority: 17,
},
@@ -25,6 +25,4 @@ fn idle() -> ! {
loop {}
}
-task!(SYS_TICK, sys_tick);
-
-fn sys_tick(_: &mut Threshold, _: SYS_TICK::Resources) {}
+fn sys_tick() {}
diff --git a/tests/cfail/priority-too-low.rs b/tests/cfail/priority-too-low.rs
index d127c40..cefd342 100644
--- a/tests/cfail/priority-too-low.rs
+++ b/tests/cfail/priority-too-low.rs
@@ -2,17 +2,17 @@
#![feature(proc_macro)]
#![no_std]
-#[macro_use(task)]
extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx;
-use rtfm::{app, Threshold};
+use rtfm::app;
app! { //~ error attempt to subtract with overflow
device: stm32f103xx,
tasks: {
SYS_TICK: {
+ path: sys_tick,
// ERROR priority must be in the range [1, 16]
priority: 0,
},
@@ -25,6 +25,4 @@ fn idle() -> ! {
loop {}
}
-task!(SYS_TICK, sys_tick);
-
-fn sys_tick(_: &mut Threshold, _: SYS_TICK::Resources) {}
+fn sys_tick() {}
diff --git a/tests/cfail/token-outlive.rs b/tests/cfail/token-outlive.rs
index 777729a..dc9112e 100644
--- a/tests/cfail/token-outlive.rs
+++ b/tests/cfail/token-outlive.rs
@@ -3,7 +3,6 @@
#![feature(proc_macro)]
#![no_std]
-#[macro_use(task)]
extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx;
@@ -19,12 +18,14 @@ app! {
tasks: {
EXTI0: {
enabled: true,
+ path: exti0,
priority: 1,
resources: [STATE],
},
EXTI1: {
enabled: true,
+ path: exti1,
priority: 2,
resources: [STATE],
},
@@ -37,14 +38,10 @@ fn idle() -> ! {
loop {}
}
-task!(EXTI0, exti0);
-
fn exti0(mut t: &mut Threshold, r: EXTI0::Resources) {
// ERROR token should not outlive the critical section
let t = r.STATE.claim(&mut t, |_state, t| t);
//~^ error cannot infer an appropriate lifetime
}
-task!(EXTI1, exti1);
-
fn exti1(_t: &mut Threshold, _r: EXTI1::Resources) {}
diff --git a/tests/cfail/token-transfer.rs b/tests/cfail/token-transfer.rs
index 7bf4233..b8bcc00 100644
--- a/tests/cfail/token-transfer.rs
+++ b/tests/cfail/token-transfer.rs
@@ -3,7 +3,6 @@
#![feature(proc_macro)]
#![no_std]
-#[macro_use(task)]
extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx;
@@ -19,6 +18,7 @@ app! { //~ error bound `rtfm::Threshold: core::marker::Send` is not satisfied
tasks: {
EXTI0: {
enabled: true,
+ path: exti0,
priority: 1,
resources: [TOKEN],
},
@@ -31,6 +31,4 @@ fn idle() -> ! {
loop {}
}
-task!(EXTI0, exti0);
-
fn exti0(_t: &mut Threshold, _r: EXTI0::Resources) {}
diff --git a/tests/cfail/wrong-threshold.rs b/tests/cfail/wrong-threshold.rs
index 05ebb2f..57d6d30 100644
--- a/tests/cfail/wrong-threshold.rs
+++ b/tests/cfail/wrong-threshold.rs
@@ -3,7 +3,6 @@
#![feature(proc_macro)]
#![no_std]
-#[macro_use(task)]
extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx;
@@ -20,12 +19,14 @@ app! {
tasks: {
EXTI0: {
enabled: true,
+ path: exti0,
priority: 1,
resources: [A, B],
},
EXTI1: {
enabled: true,
+ path: exti1,
priority: 2,
resources: [A, B],
},
@@ -38,8 +39,6 @@ fn idle() -> ! {
loop {}
}
-task!(EXTI0, exti0);
-
fn exti0(mut ot: &mut Threshold, r: EXTI0::Resources) {
r.A.claim(&mut ot, |_a, mut _it| {
//~^ error cannot borrow `ot` as mutable more than once at a time
@@ -49,6 +48,4 @@ fn exti0(mut ot: &mut Threshold, r: EXTI0::Resources) {
});
}
-task!(EXTI1, exti1);
-
fn exti1(_t: &mut Threshold, r: EXTI1::Resources) {}