-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merges: #42
- Loading branch information
Showing
9 changed files
with
92 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
from testrunner import run | ||
|
||
def test(child): | ||
# Both LEDs light up at some point | ||
child.expect("LED_RED_TOGGLE") | ||
child.expect("LED_GREEN_TOGGLE") | ||
|
||
if __name__ == "__main__": | ||
if os.environ['BOARD'] != 'native': | ||
print("Automated test only works on native (other boards don't report hteir LED activity)", file=sys.stderr) | ||
sys.exit(1) | ||
sys.exit(run(test)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "riot-wrappers-test-mutex" | ||
version = "0.1.0" | ||
authors = ["Christian Amsüss <chrysn@fsfe.org>"] | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["staticlib"] | ||
|
||
[profile.release] | ||
panic = "abort" | ||
|
||
[dependencies] | ||
riot-wrappers = { version = "*", features = [ "set_panic_handler" ] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
APPLICATION = riot-wrappers-test-mutex | ||
BOARD ?= native | ||
APPLICATION_RUST_MODULE = riot_wrappers_test_mutex | ||
BASELIBS += $(APPLICATION_RUST_MODULE).module | ||
FEATURES_REQUIRED += rust_target | ||
|
||
include $(RIOTBASE)/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#![no_std] | ||
|
||
use riot_wrappers::mutex::Mutex; | ||
use riot_wrappers::println; | ||
use riot_wrappers::riot_main; | ||
use riot_wrappers::thread::{InThread, ValueInThread}; | ||
|
||
riot_main!(main); | ||
|
||
static M1: Mutex<()> = Mutex::new(()); | ||
|
||
fn main() { | ||
let l1 = M1.lock(); | ||
drop(l1); | ||
let m1 = InThread::new().unwrap().promote(&M1); | ||
let l2 = m1.lock(); | ||
assert!(m1.try_lock().is_none()); | ||
drop(l2); | ||
let l3 = m1.try_lock(); | ||
assert!(l3.is_some()); | ||
drop(l3); | ||
|
||
let m2 = Mutex::new(0u8); | ||
*m2.lock() = 4; | ||
assert!(*m2.lock() == 4); | ||
|
||
println!("SUCCESS"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
from testrunner import run | ||
|
||
def test(child): | ||
child.expect("SUCCESS") | ||
|
||
if __name__ == "__main__": | ||
sys.exit(run(test)) |