diff options
author | 2019-06-13 23:56:59 +0200 | |
---|---|---|
committer | 2019-06-13 23:56:59 +0200 | |
commit | 81275bfa4f41e2066770087f3a33cad4227eab41 (patch) | |
tree | c779a68e7cecf4c2613c7593376f980cea5dbc05 /tests | |
parent | fafeeb27270ef24fc3852711c6032f65aa7dbcc0 (diff) | |
download | rtic-81275bfa4f41e2066770087f3a33cad4227eab41.tar.gz rtic-81275bfa4f41e2066770087f3a33cad4227eab41.tar.zst rtic-81275bfa4f41e2066770087f3a33cad4227eab41.zip |
rtfm-syntax refactor + heterogeneous multi-core support
Diffstat (limited to 'tests')
50 files changed, 33 insertions, 1284 deletions
diff --git a/tests/cfail/cfg-resources.rs b/tests/cfail/cfg-resources.rs deleted file mode 100644 index 5e20c4de..00000000 --- a/tests/cfail/cfg-resources.rs +++ /dev/null @@ -1,64 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[cfg(never)] - static mut O1: u32 = 0; // init - #[cfg(never)] - static mut O2: u32 = 0; // idle - #[cfg(never)] - static mut O3: u32 = 0; // EXTI0 - #[cfg(never)] - static O4: u32 = 0; // idle - #[cfg(never)] - static O5: u32 = 0; // EXTI1 - #[cfg(never)] - static O6: u32 = 0; // init - - #[cfg(never)] - static mut S1: u32 = 0; // idle & EXTI0 - #[cfg(never)] - static mut S2: u32 = 0; // EXTI0 & EXTI1 - #[cfg(never)] - static S3: u32 = 0; - - #[init(resources = [O1, O4, O5, O6, S3])] - fn init(c: init::Context) { - c.resources.O1; //~ ERROR no field `O1` - c.resources.O4; //~ ERROR no field `O4` - c.resources.O5; //~ ERROR no field `O5` - c.resources.O6; //~ ERROR no field `O6` - c.resources.S3; //~ ERROR no field `S3` - } - - #[idle(resources = [O2, O4, S1, S3])] - fn idle(c: idle::Context) -> ! { - c.resources.O2; //~ ERROR no field `O2` - c.resources.O4; //~ ERROR no field `O4` - c.resources.S1; //~ ERROR no field `S1` - c.resources.S3; //~ ERROR no field `S3` - - loop {} - } - - #[interrupt(resources = [O3, S1, S2, S3])] - fn UART0(c: UART0::Context) { - c.resources.O3; //~ ERROR no field `O3` - c.resources.S1; //~ ERROR no field `S1` - c.resources.S2; //~ ERROR no field `S2` - c.resources.S3; //~ ERROR no field `S3` - } - - #[interrupt(resources = [S2, O5])] - fn UART1(c: UART1::Context) { - c.resources.S2; //~ ERROR no field `S2` - c.resources.O5; //~ ERROR no field `O5` - } -}; diff --git a/tests/cfail/cfg-static.rs b/tests/cfail/cfg-static.rs deleted file mode 100644 index 91465a1e..00000000 --- a/tests/cfail/cfg-static.rs +++ /dev/null @@ -1,57 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) { - #[cfg(never)] - static mut FOO: u32 = 0; - - FOO; //~ ERROR cannot find value `FOO` in this scope - } - - #[idle] - fn idle(_: idle::Context) -> ! { - #[cfg(never)] - static mut FOO: u32 = 0; - - FOO; //~ ERROR cannot find value `FOO` in this scope - - loop {} - } - - #[exception] - fn SVCall(_: SVCall::Context) { - #[cfg(never)] - static mut FOO: u32 = 0; - - FOO; //~ ERROR cannot find value `FOO` in this scope - } - - #[interrupt] - fn UART0(_: UART0::Context) { - #[cfg(never)] - static mut FOO: u32 = 0; - - FOO; //~ ERROR cannot find value `FOO` in this scope - } - - #[task] - fn foo(_: foo::Context) { - #[cfg(never)] - static mut FOO: u32 = 0; - - FOO; //~ ERROR cannot find value `FOO` in this scope - } - - extern "C" { - fn UART1(); - } -}; diff --git a/tests/cfail/duplicate-args-2.rs b/tests/cfail/duplicate-args-2.rs deleted file mode 100644 index 5bef79b5..00000000 --- a/tests/cfail/duplicate-args-2.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[task( - priority = 1, - priority = 2, //~ ERROR argument appears more than once - )] - fn foo(_: foo::Context) {} - - extern "C" { - fn UART0(); - } -}; diff --git a/tests/cfail/duplicate-args.rs b/tests/cfail/duplicate-args.rs deleted file mode 100644 index 6938cd0d..00000000 --- a/tests/cfail/duplicate-args.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[task( - capacity = 1, - capacity = 2, //~ ERROR argument appears more than once - )] - fn foo(_: foo::Context) {} - - extern "C" { - fn UART0(); - } -}; diff --git a/tests/cfail/exception-divergent.rs b/tests/cfail/exception-divergent.rs deleted file mode 100644 index 3fe9a365..00000000 --- a/tests/cfail/exception-divergent.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[exception] - fn SVCall(_: SVCall::Context) -> ! { - //~^ ERROR this `exception` handler must have type signature `fn(SVCall::Context)` - loop {} - } -}; diff --git a/tests/cfail/exception-input.rs b/tests/cfail/exception-input.rs deleted file mode 100644 index d1363fe5..00000000 --- a/tests/cfail/exception-input.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[exception] - fn SVCall(_: SVCall::Context, undef: u32) { - //~^ ERROR this `exception` handler must have type signature `fn(SVCall::Context)` - } -}; diff --git a/tests/cfail/exception-invalid.rs b/tests/cfail/exception-invalid.rs deleted file mode 100644 index 4bb8f1ec..00000000 --- a/tests/cfail/exception-invalid.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[exception] - fn NonMaskableInt(_: NonMaskableInt::Context) { - //~^ ERROR only exceptions with configurable priority can be used as hardware tasks - } -}; diff --git a/tests/cfail/exception-output.rs b/tests/cfail/exception-output.rs deleted file mode 100644 index 8f672985..00000000 --- a/tests/cfail/exception-output.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[exception] - fn SVCall(_: SVCall::Context) -> u32 { - //~^ ERROR this `exception` handler must have type signature `fn(SVCall::Context)` - 0 - } -}; diff --git a/tests/cfail/exception-sys-tick.rs b/tests/cfail/exception-sys-tick.rs deleted file mode 100644 index d5eae20b..00000000 --- a/tests/cfail/exception-sys-tick.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[exception] - fn SysTick(_: SysTick::Context) { - //~^ ERROR the `SysTick` exception can't be used because it's used by the runtime - } -}; diff --git a/tests/cfail/idle-input.rs b/tests/cfail/idle-input.rs deleted file mode 100644 index feb83e8b..00000000 --- a/tests/cfail/idle-input.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[idle] - fn idle(_: idle::Context, undef: u32) { - //~^ ERROR `idle` must have type signature `fn(idle::Context) -> !` - } -}; diff --git a/tests/cfail/idle-not-divergent.rs b/tests/cfail/idle-not-divergent.rs deleted file mode 100644 index 505fba14..00000000 --- a/tests/cfail/idle-not-divergent.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[idle] - fn idle(_: idle::Context) { - //~^ ERROR `idle` must have type signature `fn(idle::Context) -> !` - } -}; diff --git a/tests/cfail/init-divergent.rs b/tests/cfail/init-divergent.rs deleted file mode 100644 index 0e779ffc..00000000 --- a/tests/cfail/init-divergent.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) -> ! { - //~^ ERROR `init` must have type signature `fn(init::Context) [-> init::LateResources]` - loop {} - } -}; diff --git a/tests/cfail/init-extra-late-resources.rs b/tests/cfail/init-extra-late-resources.rs deleted file mode 100644 index d2d4a6d7..00000000 --- a/tests/cfail/init-extra-late-resources.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) -> init::LateResources {} - //~^ error: `init` signature must be `fn(init::Context)` if there are no late resources -}; diff --git a/tests/cfail/init-input.rs b/tests/cfail/init-input.rs deleted file mode 100644 index 9063efe3..00000000 --- a/tests/cfail/init-input.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context, undef: u32) { - //~^ ERROR `init` must have type signature `fn(init::Context) [-> init::LateResources]` - } -}; diff --git a/tests/cfail/init-missing-late-resources.rs b/tests/cfail/init-missing-late-resources.rs deleted file mode 100644 index cec18bab..00000000 --- a/tests/cfail/init-missing-late-resources.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - static mut X: i32 = (); - - #[init] - fn init(_: init::Context) {} - //~^ error: late resources have been specified so `init` must return `init::LateResources` -}; diff --git a/tests/cfail/init-not-send.rs b/tests/cfail/init-not-send.rs deleted file mode 100644 index 5a33fac7..00000000 --- a/tests/cfail/init-not-send.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! This is equivalent to the `late-not-send` cfail test - -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use core::marker::PhantomData; - -use rtfm::app; - -pub struct NotSend { - _0: PhantomData<*const ()>, -} - -#[app(device = lm3s6965)] //~ ERROR `*const ()` cannot be sent between threads safely -const APP: () = { - static mut X: Option<NotSend> = None; - - #[init(resources = [X])] - fn init(c: init::Context) { - *c.resources.X = Some(NotSend { _0: PhantomData }) - } - - #[interrupt(resources = [X])] - fn UART0(_: UART0::Context) {} -}; diff --git a/tests/cfail/init-output.rs b/tests/cfail/init-output.rs deleted file mode 100644 index f88d5340..00000000 --- a/tests/cfail/init-output.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) -> u32 { - //~^ ERROR `init` must have type signature `fn(init::Context) [-> init::LateResources]` - 0 - } -}; diff --git a/tests/cfail/insufficient-free-interrupts.rs b/tests/cfail/insufficient-free-interrupts.rs deleted file mode 100644 index 7148fbf3..00000000 --- a/tests/cfail/insufficient-free-interrupts.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] //~ ERROR 1 free interrupt (`extern { .. }`) is required -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[task] - fn foo(_: foo::Context) {} -}; diff --git a/tests/cfail/interrupt-divergent.rs b/tests/cfail/interrupt-divergent.rs deleted file mode 100644 index b67601ee..00000000 --- a/tests/cfail/interrupt-divergent.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[interrupt] - fn UART0(_: UART0::Context) -> ! { - //~^ ERROR this `interrupt` handler must have type signature `fn(UART0::Context)` - loop {} - } -}; diff --git a/tests/cfail/interrupt-input.rs b/tests/cfail/interrupt-input.rs deleted file mode 100644 index f11b2d39..00000000 --- a/tests/cfail/interrupt-input.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[interrupt] - fn UART0(_: UART0::Context, undef: u32) { - //~^ ERROR this `interrupt` handler must have type signature `fn(UART0::Context)` - } -}; diff --git a/tests/cfail/interrupt-output.rs b/tests/cfail/interrupt-output.rs deleted file mode 100644 index 69e4957f..00000000 --- a/tests/cfail/interrupt-output.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[interrupt] - fn UART0(_: UART0::Context) -> u32 { - //~^ ERROR this `interrupt` handler must have type signature `fn(UART0::Context)` - 0 - } -}; diff --git a/tests/cfail/late-assigned-to-init.rs b/tests/cfail/late-assigned-to-init.rs deleted file mode 100644 index 00d6c8ce..00000000 --- a/tests/cfail/late-assigned-to-init.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - static mut X: u32 = (); - - #[init(resources = [X])] //~ ERROR late resources can NOT be assigned to `init` - fn init(_: init::Context) {} -}; diff --git a/tests/cfail/late-not-send.rs b/tests/cfail/late-not-send.rs deleted file mode 100644 index 04a4af15..00000000 --- a/tests/cfail/late-not-send.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! `init` has a static priority of `0`. Initializing resources from it is equivalent to sending a -//! message to the task that will own the resource - -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use core::marker::PhantomData; - -use rtfm::app; - -struct NotSend { - _0: PhantomData<*const ()>, -} - -#[app(device = lm3s6965)] //~ ERROR `*const ()` cannot be sent between threads safely -const APP: () = { - static mut X: NotSend = (); - - #[init] - fn init(_: init::Context) -> init::LateResources { - init::LateResources { - X: NotSend { _0: PhantomData }, - } - } - - #[interrupt(resources = [X])] - fn UART0(_: UART0::Context) {} -}; diff --git a/tests/cfail/needs-send.rs b/tests/cfail/needs-send.rs deleted file mode 100644 index 8dc9707f..00000000 --- a/tests/cfail/needs-send.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use core::marker::PhantomData; - -use rtfm::app; - -pub struct NotSend { - _0: PhantomData<*const ()>, -} - -unsafe impl Sync for NotSend {} - -#[app(device = lm3s6965)] //~ ERROR cannot be sent between threads safely -const APP: () = { - #[init(spawn = [foo])] - fn init(_: init::Context) {} - - #[task] - fn foo(_: foo::Context, _x: NotSend) {} - - extern "C" { - fn UART0(); - } -}; diff --git a/tests/cfail/needs-sync.rs b/tests/cfail/needs-sync.rs deleted file mode 100644 index 6025e7d5..00000000 --- a/tests/cfail/needs-sync.rs +++ /dev/null @@ -1,35 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use core::marker::PhantomData; - -use rtfm::app; - -pub struct NotSync { - _0: PhantomData<*const ()>, -} - -unsafe impl Send for NotSync {} - -#[app(device = lm3s6965)] //~ ERROR cannot be shared between threads safely -const APP: () = { - static X: NotSync = NotSync { _0: PhantomData }; - - #[init(spawn = [foo])] - fn init(_: init::Context) {} - - #[task(priority = 1, resources = [X])] - fn foo(_: foo::Context) {} - - #[task(priority = 2, resources = [X])] - fn bar(_: bar::Context) {} - - extern "C" { - fn UART0(); - fn UART1(); - } -}; diff --git a/tests/cfail/priority-too-high.rs b/tests/cfail/priority-too-high.rs deleted file mode 100644 index 817462a3..00000000 --- a/tests/cfail/priority-too-high.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] //~ error evaluation of constant value failed -const APP: () = { - #[init] - fn init(_: init::Context) {} - - // OK, this is the maximum priority supported by the device - #[interrupt(priority = 8)] - fn UART0(_: UART0::Context) {} - - // this value is too high! - #[interrupt(priority = 9)] - fn UART1(_: UART1::Context) {} -}; diff --git a/tests/cfail/priority-too-low.rs b/tests/cfail/priority-too-low.rs deleted file mode 100644 index 361156df..00000000 --- a/tests/cfail/priority-too-low.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - // OK, this is the minimum priority that tasks can have - #[interrupt(priority = 1)] - fn UART0(_: UART0::Context) {} - - // this value is too low! - #[interrupt(priority = 0)] //~ error this literal must be in the range 1...255 - fn UART1(_: UART1::Context) {} -}; diff --git a/tests/cfail/resource-not-declared.rs b/tests/cfail/resource-not-declared.rs deleted file mode 100644 index a37be42d..00000000 --- a/tests/cfail/resource-not-declared.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init(resources = [X])] //~ ERROR this resource has NOT been declared - fn init(_: init::Context) {} -}; diff --git a/tests/cfail/resource-pub.rs b/tests/cfail/resource-pub.rs deleted file mode 100644 index 3fb21f46..00000000 --- a/tests/cfail/resource-pub.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - pub static mut X: u32 = 0; - //~^ ERROR resources must have inherited / private visibility - - #[init] - fn init(_: init::Context) {} -}; diff --git a/tests/cfail/task-divergent.rs b/tests/cfail/task-divergent.rs deleted file mode 100644 index 577f0e06..00000000 --- a/tests/cfail/task-divergent.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -#[rtfm::app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[task] - fn foo(_: foo::Context) -> ! { - //~^ ERROR this `task` handler must have type signature `fn(foo::Context, ..)` - loop {} - } - - extern "C" { - fn UART0(); - } -}; diff --git a/tests/cfail/task-idle.rs b/tests/cfail/task-idle.rs deleted file mode 100644 index 963bf1ee..00000000 --- a/tests/cfail/task-idle.rs +++ /dev/null @@ -1,23 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[task] - fn idle(_: idle::Context) { - //~^ ERROR `task` handlers can NOT be named `idle`, `init` or `resources` - } - - extern "C" { - fn UART0(); - } -}; diff --git a/tests/cfail/task-not-declared.rs b/tests/cfail/task-not-declared.rs deleted file mode 100644 index 04309f59..00000000 --- a/tests/cfail/task-not-declared.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init(spawn = [X])] //~ ERROR this task has NOT been declared - fn init(_: init::Context) {} -}; diff --git a/tests/cfail/unsafe-exception.rs b/tests/cfail/unsafe-exception.rs deleted file mode 100644 index 353194a5..00000000 --- a/tests/cfail/unsafe-exception.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[exception(binds = SVCall)] - unsafe fn foo(_: foo::Context) {} - //~^ ERROR this `exception` handler must have type signature `fn(foo::Context)` -}; diff --git a/tests/cfail/unsafe-idle.rs b/tests/cfail/unsafe-idle.rs deleted file mode 100644 index fab1b0f1..00000000 --- a/tests/cfail/unsafe-idle.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[idle] - unsafe fn idle(_: idle::Context) -> ! { - //~^ ERROR `idle` must have type signature `fn(idle::Context) -> !` - loop {} - } -}; diff --git a/tests/cfail/unsafe-init.rs b/tests/cfail/unsafe-init.rs deleted file mode 100644 index d8bb5605..00000000 --- a/tests/cfail/unsafe-init.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - unsafe fn init(_: init::Context) {} - //~^ ERROR `init` must have type signature `fn(init::Context) [-> init::LateResources]` -}; diff --git a/tests/cfail/unsafe-interrupt.rs b/tests/cfail/unsafe-interrupt.rs deleted file mode 100644 index 93225edf..00000000 --- a/tests/cfail/unsafe-interrupt.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[interrupt(binds = UART0)] - unsafe fn foo(_: foo::Context) {} - //~^ ERROR this `interrupt` handler must have type signature `fn(foo::Context)` -}; diff --git a/tests/cfail/unsafe-task.rs b/tests/cfail/unsafe-task.rs deleted file mode 100644 index 58c4d70c..00000000 --- a/tests/cfail/unsafe-task.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[task] - unsafe fn foo(_: foo::Context) {} - //~^ ERROR this `task` handler must have type signature `fn(foo::Context, ..)` - - extern "C" { - fn UART0(); - } -}; diff --git a/tests/cfail/used-free-interrupt-2.rs b/tests/cfail/used-free-interrupt-2.rs deleted file mode 100644 index ba9424fd..00000000 --- a/tests/cfail/used-free-interrupt-2.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[interrupt(binds = UART0)] //~ ERROR free interrupts (`extern { .. }`) can't be used as interrupt handlers - fn foo(_: foo::Context) {} - - extern "C" { - fn UART0(); - } -}; diff --git a/tests/cfail/used-free-interrupt.rs b/tests/cfail/used-free-interrupt.rs deleted file mode 100644 index 1a56741b..00000000 --- a/tests/cfail/used-free-interrupt.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[interrupt] - fn UART0(_: UART0::Context) {} - //~^ ERROR free interrupts (`extern { .. }`) can't be used as interrupt handlers - - extern "C" { - fn UART0(); - } -}; diff --git a/tests/compiletest.rs b/tests/compiletest.rs deleted file mode 100644 index 58702eec..00000000 --- a/tests/compiletest.rs +++ /dev/null @@ -1,57 +0,0 @@ -use std::{fs, path::PathBuf, process::Command}; - -use compiletest_rs::{common::Mode, Config}; -use tempdir::TempDir; - -#[test] -fn cfail() { - let mut config = Config::default(); - - config.mode = Mode::CompileFail; - config.src_base = PathBuf::from("tests/cfail"); - config.link_deps(); - - // remove duplicate and trailing `-L` flags - let mut s = String::new(); - if let Some(flags) = config.target_rustcflags.as_mut() { - let mut iter = flags.split_whitespace().peekable(); - - while let Some(flag) = iter.next() { - if flag == "-L" && (iter.peek() == Some(&"-L") || iter.peek() == None) { - iter.next(); - continue; - } - - s += flag; - s += " "; - } - - // path to proc-macro crate - s += "-L target/debug/deps "; - - // avoid "error: language item required, but not found: `eh_personality`" - s += "-C panic=abort "; - } - - let td = TempDir::new("rtfm").unwrap(); - for f in fs::read_dir("tests/cpass").unwrap() { - let f = f.unwrap().path(); - let name = f.file_stem().unwrap().to_str().unwrap(); - - assert!(Command::new("rustc") - .args(s.split_whitespace()) - .arg(f.display().to_string()) - .arg("-o") - .arg(td.path().join(name).display().to_string()) - .arg("-C") - .arg("linker=true") - .status() - .unwrap() - .success()); - } - - config.target_rustcflags = Some(s); - config.clean_rmeta(); - - compiletest_rs::run_tests(&config); -} diff --git a/tests/cpass/binds.rs b/tests/cpass/binds.rs deleted file mode 100644 index 897e083a..00000000 --- a/tests/cpass/binds.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! Check that `binds` works as advertised -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -#[rtfm::app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(_: init::Context) {} - - #[exception(binds = SVCall)] - fn foo(c: foo::Context) { - foo_trampoline(c) - } - - #[interrupt(binds = UART0)] - fn bar(c: bar::Context) { - bar_trampoline(c) - } -}; - -#[allow(dead_code)] -fn foo_trampoline(_: foo::Context) {} - -#[allow(dead_code)] -fn bar_trampoline(_: bar::Context) {} diff --git a/tests/cpass/cfg.rs b/tests/cpass/cfg.rs deleted file mode 100644 index a0b6a870..00000000 --- a/tests/cpass/cfg.rs +++ /dev/null @@ -1,51 +0,0 @@ -//! Compile-pass test that checks that `#[cfg]` attributes are respected - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -#[rtfm::app(device = lm3s6965)] -const APP: () = { - #[cfg(never)] - static mut FOO: u32 = 0; - - #[init] - fn init(_: init::Context) { - #[cfg(never)] - static mut BAR: u32 = 0; - } - - #[idle] - fn idle(_: idle::Context) -> ! { - #[cfg(never)] - static mut BAR: u32 = 0; - - loop {} - } - - #[task(resources = [FOO], schedule = [quux], spawn = [quux])] - fn foo(_: foo::Context) { - #[cfg(never)] - static mut BAR: u32 = 0; - } - - #[task(priority = 3, resources = [FOO], schedule = [quux], spawn = [quux])] - fn bar(_: bar::Context) { - #[cfg(never)] - static mut BAR: u32 = 0; - } - - #[cfg(never)] - #[task] - fn quux(_: quux::Context) {} - - extern "C" { - fn UART0(); - fn UART1(); - } -}; diff --git a/tests/cpass/late-not-send.rs b/tests/cpass/late-not-send.rs deleted file mode 100644 index 0f690967..00000000 --- a/tests/cpass/late-not-send.rs +++ /dev/null @@ -1,34 +0,0 @@ -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use core::marker::PhantomData; - -pub struct NotSend { - _0: PhantomData<*const ()>, -} - -#[rtfm::app(device = lm3s6965)] -const APP: () = { - static mut X: NotSend = (); - static mut Y: Option<NotSend> = None; - - #[init(resources = [Y])] - fn init(c: init::Context) -> init::LateResources { - *c.resources.Y = Some(NotSend { _0: PhantomData }); - - init::LateResources { - X: NotSend { _0: PhantomData }, - } - } - - #[idle(resources = [X, Y])] - fn idle(_: idle::Context) -> ! { - loop {} - } -}; diff --git a/tests/cpass/late-resource.rs b/tests/cpass/late-resource.rs deleted file mode 100644 index 37dcf331..00000000 --- a/tests/cpass/late-resource.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! Runtime initialized resources -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -#[rtfm::app(device = lm3s6965)] -const APP: () = { - static mut X: u32 = (); - static Y: u32 = (); - - #[init] - fn init(_: init::Context) -> init::LateResources { - init::LateResources { X: 0, Y: 1 } - } -}; diff --git a/tests/cpass/peripheral.rs b/tests/cpass/peripheral.rs deleted file mode 100644 index 34352b84..00000000 --- a/tests/cpass/peripheral.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! Core and device peripherals -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -#[rtfm::app(device = lm3s6965)] -const APP: () = { - #[init] - fn init(c: init::Context) { - let _: rtfm::Peripherals = c.core; - let _: lm3s6965::Peripherals = c.device; - } -}; diff --git a/tests/cpass/resource.rs b/tests/cpass/resource.rs deleted file mode 100644 index 4e92a032..00000000 --- a/tests/cpass/resource.rs +++ /dev/null @@ -1,81 +0,0 @@ -//! Check code generation of resources - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::Exclusive; - -#[rtfm::app(device = lm3s6965)] -const APP: () = { - static mut O1: u32 = 0; // init - static mut O2: u32 = 0; // idle - static mut O3: u32 = 0; // EXTI0 - static O4: u32 = 0; // idle - static O5: u32 = 0; // EXTI1 - static O6: u32 = 0; // init - - static mut S1: u32 = 0; // idle & EXTI0 - static mut S2: u32 = 0; // EXTI0 & EXTI1 - static S3: u32 = 0; - - #[init(resources = [O1, O4, O5, O6, S3])] - fn init(c: init::Context) { - // owned by `init` == `&'static mut` - let _: &'static mut u32 = c.resources.O1; - - // owned by `init` == `&'static` if read-only - let _: &'static u32 = c.resources.O6; - - // `init` has exclusive access to all resources - let _: &mut u32 = c.resources.O4; - let _: &mut u32 = c.resources.O5; - let _: &mut u32 = c.resources.S3; - } - - #[idle(resources = [O2, O4, S1, S3])] - fn idle(mut c: idle::Context) -> ! { - // owned by `idle` == `&'static mut` - let _: &'static mut u32 = c.resources.O2; - - // owned by `idle` == `&'static` if read-only - let _: &'static u32 = c.resources.O4; - - // shared with `idle` == `Mutex` - c.resources.S1.lock(|_| {}); - - // `&` if read-only - let _: &u32 = c.resources.S3; - - loop {} - } - - #[interrupt(resources = [O3, S1, S2, S3])] - fn UART0(c: UART0::Context) { - // owned by interrupt == `&mut` - let _: &mut u32 = c.resources.O3; - - // no `Mutex` proxy when access from highest priority task - let _: Exclusive<u32> = c.resources.S1; - - // no `Mutex` proxy when co-owned by cooperative (same priority) tasks - let _: Exclusive<u32> = c.resources.S2; - - // `&` if read-only - let _: &u32 = c.resources.S3; - } - - #[interrupt(resources = [S2, O5])] - fn UART1(c: UART1::Context) { - // owned by interrupt == `&` if read-only - let _: &u32 = c.resources.O5; - - // no `Mutex` proxy when co-owned by cooperative (same priority) tasks - let _: Exclusive<u32> = c.resources.S2; - } -}; diff --git a/tests/cpass/schedule.rs b/tests/cpass/schedule.rs deleted file mode 100644 index 346f9124..00000000 --- a/tests/cpass/schedule.rs +++ /dev/null @@ -1,60 +0,0 @@ -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::Instant; - -#[rtfm::app(device = lm3s6965)] -const APP: () = { - #[init(schedule = [foo, bar, baz])] - fn init(c: init::Context) { - let _: Result<(), ()> = c.schedule.foo(c.start + 10.cycles()); - let _: Result<(), u32> = c.schedule.bar(c.start + 20.cycles(), 0); - let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 30.cycles(), 0, 1); - } - - #[idle(schedule = [foo, bar, baz])] - fn idle(c: idle::Context) -> ! { - let _: Result<(), ()> = c.schedule.foo(Instant::now() + 40.cycles()); - let _: Result<(), u32> = c.schedule.bar(Instant::now() + 50.cycles(), 0); - let _: Result<(), (u32, u32)> = c.schedule.baz(Instant::now() + 60.cycles(), 0, 1); - - loop {} - } - - #[exception(schedule = [foo, bar, baz])] - fn SVCall(c: SVCall::Context) { - let _: Result<(), ()> = c.schedule.foo(c.start + 70.cycles()); - let _: Result<(), u32> = c.schedule.bar(c.start + 80.cycles(), 0); - let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 90.cycles(), 0, 1); - } - - #[interrupt(schedule = [foo, bar, baz])] - fn UART0(c: UART0::Context) { - let _: Result<(), ()> = c.schedule.foo(c.start + 100.cycles()); - let _: Result<(), u32> = c.schedule.bar(c.start + 110.cycles(), 0); - let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 120.cycles(), 0, 1); - } - - #[task(schedule = [foo, bar, baz])] - fn foo(c: foo::Context) { - let _: Result<(), ()> = c.schedule.foo(c.scheduled + 130.cycles()); - let _: Result<(), u32> = c.schedule.bar(c.scheduled + 140.cycles(), 0); - let _: Result<(), (u32, u32)> = c.schedule.baz(c.scheduled + 150.cycles(), 0, 1); - } - - #[task] - fn bar(_: bar::Context, _x: u32) {} - - #[task] - fn baz(_: baz::Context, _x: u32, _y: u32) {} - - extern "C" { - fn UART1(); - } -}; diff --git a/tests/cpass/spawn.rs b/tests/cpass/spawn.rs deleted file mode 100644 index 0a27c4f6..00000000 --- a/tests/cpass/spawn.rs +++ /dev/null @@ -1,59 +0,0 @@ -//! Check code generation of `spawn` -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -#[rtfm::app(device = lm3s6965)] -const APP: () = { - #[init(spawn = [foo, bar, baz])] - fn init(c: init::Context) { - let _: Result<(), ()> = c.spawn.foo(); - let _: Result<(), u32> = c.spawn.bar(0); - let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1); - } - - #[idle(spawn = [foo, bar, baz])] - fn idle(c: idle::Context) -> ! { - let _: Result<(), ()> = c.spawn.foo(); - let _: Result<(), u32> = c.spawn.bar(0); - let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1); - - loop {} - } - - #[exception(spawn = [foo, bar, baz])] - fn SVCall(c: SVCall::Context) { - let _: Result<(), ()> = c.spawn.foo(); - let _: Result<(), u32> = c.spawn.bar(0); - let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1); - } - - #[interrupt(spawn = [foo, bar, baz])] - fn UART0(c: UART0::Context) { - let _: Result<(), ()> = c.spawn.foo(); - let _: Result<(), u32> = c.spawn.bar(0); - let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1); - } - - #[task(spawn = [foo, bar, baz])] - fn foo(c: foo::Context) { - let _: Result<(), ()> = c.spawn.foo(); - let _: Result<(), u32> = c.spawn.bar(0); - let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1); - } - - #[task] - fn bar(_: bar::Context, _x: u32) {} - - #[task] - fn baz(_: baz::Context, _x: u32, _y: u32) {} - - extern "C" { - fn UART1(); - } -}; diff --git a/tests/multi.rs b/tests/multi.rs new file mode 100644 index 00000000..675fc5e9 --- /dev/null +++ b/tests/multi.rs @@ -0,0 +1,16 @@ +use std::path::PathBuf; + +use compiletest_rs::{common::Mode, Config}; + +#[test] +fn ui() { + let mut config = Config::default(); + + config.mode = Mode::Ui; + config.src_base = PathBuf::from("ui/multi"); + config.target_rustcflags = Some("--edition=2018 -Z unstable-options --extern rtfm".to_owned()); + config.link_deps(); + config.clean_rmeta(); + + compiletest_rs::run_tests(&config); +} diff --git a/tests/single.rs b/tests/single.rs new file mode 100644 index 00000000..93addf6e --- /dev/null +++ b/tests/single.rs @@ -0,0 +1,17 @@ +use std::path::PathBuf; + +use compiletest_rs::{common::Mode, Config}; + +#[test] +fn ui() { + let mut config = Config::default(); + + config.mode = Mode::Ui; + config.src_base = PathBuf::from("ui/single"); + config.target_rustcflags = + Some("--edition=2018 -L target/debug/deps -Z unstable-options --extern rtfm --extern lm3s6965".to_owned()); + config.link_deps(); + config.clean_rmeta(); + + compiletest_rs::run_tests(&config); +} |