Skip to content

Commit

Permalink
test(test_suite): check the return value of Task::current in anothe…
Browse files Browse the repository at this point in the history
…r task just in case
  • Loading branch information
yvt committed Jun 25, 2020
1 parent c2b864a commit 9cc6484
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/constance_test_suite/src/kernel_tests/task_misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use super::Driver;
pub struct App<System> {
task1: Task<System>,
task2: Task<System>,
task3: Task<System>,
}

impl<System: Kernel> App<System> {
Expand All @@ -22,8 +23,9 @@ impl<System: Kernel> App<System> {
param = 42,
};
let task2 = new! { Task<_>, start = task2_body::<System, D>, priority = 1 };
let task3 = new! { Task<_>, start = task3_body::<System, D>, priority = 1 };

App { task1, task2 }
App { task1, task2, task3 }
}
}
}
Expand Down Expand Up @@ -73,6 +75,10 @@ fn task1_body<System: Kernel, D: Driver<App<System>>>(param: usize) {
);

// Current task
// This assertion might not be useful because `task1` always has ID 0, so
// it's unlikely to catch errors such as dividing a pointer difference by a
// wrong divisor. For this reason, we check this again in a different
// task.
assert_eq!(Task::current().unwrap(), Some(app.task1));

// CPU Lock active
Expand All @@ -95,9 +101,17 @@ fn task1_body<System: Kernel, D: Driver<App<System>>>(param: usize) {
);
unsafe { System::release_cpu_lock().unwrap() };

D::success();
// Go to `task3_body`
app.task3.activate().unwrap();
}

fn task2_body<System: Kernel, D: Driver<App<System>>>(_: usize) {
unreachable!();
}

fn task3_body<System: Kernel, D: Driver<App<System>>>(_: usize) {
// Current task (again)
assert_eq!(Task::current().unwrap(), Some(D::app().task3));

D::success();
}

0 comments on commit 9cc6484

Please sign in to comment.