style: cargo fmt kernel crates

This commit is contained in:
2026-10-26 19:07:54 +01:00
parent 818eaecadd
commit 1c04ddf909
50 changed files with 995 additions and 499 deletions

View File

@@ -236,7 +236,13 @@ impl ThreadTable {
.ok_or(KernelError::TooManyThreads)?;
let id = ThreadId::from_raw(idx as u16);
self.threads[idx] = Some(Thread::new(id, process, priority, time_slice, core_affinity));
self.threads[idx] = Some(Thread::new(
id,
process,
priority,
time_slice,
core_affinity,
));
Ok(id)
}
@@ -255,7 +261,14 @@ impl ThreadTable {
.ok_or(KernelError::TooManyThreads)?;
let id = ThreadId::from_raw(idx as u16);
self.threads[idx] = Some(Thread::with_context(id, process, priority, time_slice, core_affinity, context));
self.threads[idx] = Some(Thread::with_context(
id,
process,
priority,
time_slice,
core_affinity,
context,
));
Ok(id)
}

View File

@@ -66,7 +66,10 @@ fn running_to_blocked() {
let mut t = test_thread(0, 0);
t.set_running(core(0)).unwrap();
t.block(BlockReason::WaitingAny).unwrap();
assert!(matches!(t.state(), ThreadState::Blocked(BlockReason::WaitingAny)));
assert!(matches!(
t.state(),
ThreadState::Blocked(BlockReason::WaitingAny)
));
}
#[test]
@@ -162,7 +165,9 @@ fn time_slice_mut_ticks() {
#[test]
fn table_spawn_and_lookup() {
let mut table = ThreadTable::new();
let id = table.spawn(process(0), prio(10), time_slice(), None).unwrap();
let id = table
.spawn(process(0), prio(10), time_slice(), None)
.unwrap();
let t = table.get(id).unwrap();
assert_eq!(t.id(), id);
assert_eq!(t.process(), process(0));
@@ -171,15 +176,21 @@ fn table_spawn_and_lookup() {
#[test]
fn table_spawn_returns_unique_ids() {
let mut table = ThreadTable::new();
let a = table.spawn(process(0), prio(10), time_slice(), None).unwrap();
let b = table.spawn(process(0), prio(10), time_slice(), None).unwrap();
let a = table
.spawn(process(0), prio(10), time_slice(), None)
.unwrap();
let b = table
.spawn(process(0), prio(10), time_slice(), None)
.unwrap();
assert_ne!(a, b);
}
#[test]
fn table_destroy_then_get_fails() {
let mut table = ThreadTable::new();
let id = table.spawn(process(0), prio(10), time_slice(), None).unwrap();
let id = table
.spawn(process(0), prio(10), time_slice(), None)
.unwrap();
table.destroy(id).unwrap();
assert!(table.get(id).is_err());
}
@@ -187,9 +198,15 @@ fn table_destroy_then_get_fails() {
#[test]
fn table_threads_for_process_filters() {
let mut table = ThreadTable::new();
table.spawn(process(0), prio(10), time_slice(), None).unwrap();
table.spawn(process(1), prio(10), time_slice(), None).unwrap();
table.spawn(process(0), prio(5), time_slice(), None).unwrap();
table
.spawn(process(0), prio(10), time_slice(), None)
.unwrap();
table
.spawn(process(1), prio(10), time_slice(), None)
.unwrap();
table
.spawn(process(0), prio(5), time_slice(), None)
.unwrap();
let count = table.threads_for_process(process(0)).count();
assert_eq!(count, 2);
@@ -198,16 +215,25 @@ fn table_threads_for_process_filters() {
#[test]
fn table_get_mut_allows_state_transition() {
let mut table = ThreadTable::new();
let id = table.spawn(process(0), prio(10), time_slice(), None).unwrap();
let id = table
.spawn(process(0), prio(10), time_slice(), None)
.unwrap();
table.get_mut(id).unwrap().set_running(core(0)).unwrap();
assert!(matches!(table.get(id).unwrap().state(), ThreadState::Running(_)));
assert!(matches!(
table.get(id).unwrap().state(),
ThreadState::Running(_)
));
}
#[test]
fn table_destroy_reuses_slot() {
let mut table = ThreadTable::new();
let id = table.spawn(process(0), prio(10), time_slice(), None).unwrap();
let id = table
.spawn(process(0), prio(10), time_slice(), None)
.unwrap();
table.destroy(id).unwrap();
let new_id = table.spawn(process(0), prio(10), time_slice(), None).unwrap();
let new_id = table
.spawn(process(0), prio(10), time_slice(), None)
.unwrap();
assert_eq!(id, new_id);
}