Fix failing UI test

This commit is contained in:
Emil Fresk 2023-01-08 16:36:48 +01:00 committed by Henrik Tjäder
parent 4d2885e220
commit 796433fad2
2 changed files with 27 additions and 8 deletions

View file

@ -13,17 +13,17 @@ use crate::syntax::{
pub(crate) fn app(app: &App) -> Result<Analysis, syn::Error> { pub(crate) fn app(app: &App) -> Result<Analysis, syn::Error> {
// Collect all tasks into a vector // Collect all tasks into a vector
type TaskName = String; type TaskName = Ident;
type Priority = u8; type Priority = u8;
// The task list is a Tuple (Name, Shared Resources, Local Resources, Priority) // The task list is a Tuple (Name, Shared Resources, Local Resources, Priority)
let task_resources_list: Vec<(TaskName, Vec<&Ident>, &LocalResources, Priority)> = let task_resources_list: Vec<(TaskName, Vec<&Ident>, &LocalResources, Priority)> =
Some(&app.init) Some(&app.init)
.iter() .iter()
.map(|ht| ("init".to_string(), Vec::new(), &ht.args.local_resources, 0)) .map(|ht| (ht.name.clone(), Vec::new(), &ht.args.local_resources, 0))
.chain(app.idle.iter().map(|ht| { .chain(app.idle.iter().map(|ht| {
( (
"idle".to_string(), ht.name.clone(),
ht.args ht.args
.shared_resources .shared_resources
.iter() .iter()
@ -35,7 +35,7 @@ pub(crate) fn app(app: &App) -> Result<Analysis, syn::Error> {
})) }))
.chain(app.software_tasks.iter().map(|(name, ht)| { .chain(app.software_tasks.iter().map(|(name, ht)| {
( (
name.to_string(), name.clone(),
ht.args ht.args
.shared_resources .shared_resources
.iter() .iter()
@ -47,7 +47,7 @@ pub(crate) fn app(app: &App) -> Result<Analysis, syn::Error> {
})) }))
.chain(app.hardware_tasks.iter().map(|(name, ht)| { .chain(app.hardware_tasks.iter().map(|(name, ht)| {
( (
name.to_string(), name.clone(),
ht.args ht.args
.shared_resources .shared_resources
.iter() .iter()
@ -77,7 +77,8 @@ pub(crate) fn app(app: &App) -> Result<Analysis, syn::Error> {
for r in tr { for r in tr {
// Get all uses of resources annotated lock_free // Get all uses of resources annotated lock_free
if lf_res == r { if lf_res == r {
// lock_free resources are not allowed in async tasks // Check so async tasks do not use lock free resources
if app.software_tasks.get(task).is_some() {
error.push(syn::Error::new( error.push(syn::Error::new(
r.span(), r.span(),
format!( format!(
@ -85,8 +86,8 @@ pub(crate) fn app(app: &App) -> Result<Analysis, syn::Error> {
r.to_string(), r.to_string(),
), ),
)); ));
}
// TODO: Should this be removed?
// HashMap returns the previous existing object if old.key == new.key // HashMap returns the previous existing object if old.key == new.key
if let Some(lf_res) = lf_hash.insert(r.to_string(), (task, r, priority)) { if let Some(lf_res) = lf_hash.insert(r.to_string(), (task, r, priority)) {
// Check if priority differ, if it does, append to // Check if priority differ, if it does, append to
@ -95,6 +96,7 @@ pub(crate) fn app(app: &App) -> Result<Analysis, syn::Error> {
lf_res_with_error.push(lf_res.1); lf_res_with_error.push(lf_res.1);
lf_res_with_error.push(r); lf_res_with_error.push(r);
} }
// If the resource already violates lock free properties // If the resource already violates lock free properties
if lf_res_with_error.contains(&r) { if lf_res_with_error.contains(&r) {
lf_res_with_error.push(lf_res.1); lf_res_with_error.push(lf_res.1);

View file

@ -0,0 +1,17 @@
error: Lock free shared resource "e1" is used by tasks at different priorities
--> ui/shared-lock-free.rs:9:9
|
9 | e1: u32,
| ^^
error: Shared resource "e1" is declared lock free but used by tasks at different priorities
--> ui/shared-lock-free.rs:30:51
|
30 | #[task(binds = UART0, priority = 1, shared = [e1])]
| ^^
error: Shared resource "e1" is declared lock free but used by tasks at different priorities
--> ui/shared-lock-free.rs:36:51
|
36 | #[task(binds = UART1, priority = 2, shared = [e1])]
| ^^