Skip to content

Commit 851de5b

Browse files
committed
refactor(test_suite): inline format args
Ditto. The instances in `kernel_tets::interrupt_misc` were missed by Clippy due to conditional compilation.
1 parent 7144488 commit 851de5b

14 files changed

+39
-56
lines changed

src/r3_test_suite/src/kernel_tests/compute_atomics_round_robin.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,8 @@ fn judge_task_body<System: SupportedSystem, D: Driver<App<System>>>() {
246246

247247
let Wrapping(local_counter_sum) = local_counters.iter().cloned().map(Wrapping).sum();
248248

249-
log::debug!("counter = {}", counter);
250-
log::debug!(
251-
"local_counters = {:?} (sum = {})",
252-
local_counters,
253-
local_counter_sum
254-
);
249+
log::debug!("counter = {counter}");
250+
log::debug!("local_counters = {local_counters:?} (sum = {local_counter_sum})");
255251

256252
assert_eq!(counter, local_counter_sum);
257253

@@ -271,7 +267,7 @@ fn timer_body<System: SupportedSystem, D: Driver<App<System>>>(sched_state: &mut
271267

272268
// Switch the running task
273269
let new_task = (sched_state.cur_task + 1) % NUM_TASKS;
274-
log::trace!("scheduing tasks[{}]", new_task);
270+
log::trace!("scheduing tasks[{new_task}]");
275271
tasks[sched_state.cur_task].set_priority(2).unwrap();
276272
tasks[new_task].set_priority(1).unwrap();
277273
sched_state.cur_task = new_task;

src/r3_test_suite/src/kernel_tests/compute_round_robin.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,21 @@ fn worker_body<System: SupportedSystem, D: Driver<App<System>>>(
163163

164164
while !state.stop.load(Ordering::Relaxed) {
165165
i += 1;
166-
log::trace!("[{}] Iteration {}: starting", worker_id, i);
166+
log::trace!("[{worker_id}] Iteration {i}: starting");
167167
task_state.output = Init::INIT;
168168

169169
// Run the computation
170170
task_state.kernel_state.run(&mut task_state.output);
171171

172172
// Validate the output
173-
log::trace!("[{}] Iteration {}: validating", worker_id, i);
173+
log::trace!("[{worker_id}] Iteration {i}: validating");
174174
let valid = task_state.output == *ref_output;
175175
if !valid {
176176
stop::<System, D>();
177177
panic!("Output validation failed");
178178
}
179179

180-
log::trace!("[{}] Iteration {}: complete", worker_id, i);
180+
log::trace!("[{worker_id}] Iteration {i}: complete");
181181

182182
// Note: Some targets don't support CAS atomics. Non-atomic load/store
183183
// suffices because `run_count` is only written by this task.
@@ -192,7 +192,7 @@ fn timer_body<System: SupportedSystem, D: Driver<App<System>>>(sched_state: &mut
192192

193193
// Switch the running task
194194
let new_task = (sched_state.cur_task + 1) % NUM_TASKS;
195-
log::trace!("scheduing tasks[{}]", new_task);
195+
log::trace!("scheduing tasks[{new_task}]");
196196
tasks[sched_state.cur_task].set_priority(3).unwrap();
197197
tasks[new_task].set_priority(2).unwrap();
198198
sched_state.cur_task = new_task;
@@ -209,7 +209,7 @@ fn timer_body<System: SupportedSystem, D: Driver<App<System>>>(sched_state: &mut
209209
}
210210

211211
if sched_state.time % 20 == 0 {
212-
log::debug!("run_count = {:?}", run_count);
212+
log::debug!("run_count = {run_count:?}");
213213
}
214214

215215
let min_run_count: usize = *run_count.iter().min().unwrap();

src/r3_test_suite/src/kernel_tests/interrupt_handler_priority.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn task_body<System: SupportedSystem, D: Driver<App<System>>>() {
117117
}
118118

119119
fn isr<System: SupportedSystem, D: Driver<App<System>>>(i: usize) {
120-
log::trace!("isr({})", i);
120+
log::trace!("isr({i})");
121121
D::app().seq.expect_and_replace(i, i + 1);
122122

123123
if i == 10 {

src/r3_test_suite/src/kernel_tests/interrupt_misc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn startup_hook<System: SupportedSystem, D: Driver<App<System>>>() {
7979
int.disable().unwrap();
8080
match int.is_pending() {
8181
Ok(false) | Err(kernel::QueryInterruptLineError::NotSupported) => {}
82-
value => panic!("{:?}", value),
82+
value => panic!("{value:?}"),
8383
}
8484

8585
// Before doing the next test, make sure `clear` is supported
@@ -89,7 +89,7 @@ fn startup_hook<System: SupportedSystem, D: Driver<App<System>>>() {
8989
int.pend().unwrap();
9090
match int.is_pending() {
9191
Ok(true) | Err(kernel::QueryInterruptLineError::NotSupported) => {}
92-
value => panic!("{:?}", value),
92+
value => panic!("{value:?}"),
9393
}
9494
int.clear().unwrap();
9595
}
@@ -149,7 +149,7 @@ fn task_body<System: SupportedSystem, D: Driver<App<System>>>() {
149149
int.pend().unwrap();
150150
match int.is_pending() {
151151
Ok(true) | Err(kernel::QueryInterruptLineError::NotSupported) => {}
152-
value => panic!("{:?}", value),
152+
value => panic!("{value:?}"),
153153
}
154154
int.clear().unwrap();
155155
unsafe { System::release_cpu_lock() }.unwrap();
@@ -160,15 +160,15 @@ fn task_body<System: SupportedSystem, D: Driver<App<System>>>() {
160160
int.pend().unwrap();
161161
match int.is_pending() {
162162
Ok(true) | Err(kernel::QueryInterruptLineError::NotSupported) => {}
163-
value => panic!("{:?}", value),
163+
value => panic!("{value:?}"),
164164
}
165165
int.clear().unwrap();
166166
int.enable().unwrap();
167167
}
168168

169169
match int.is_pending() {
170170
Ok(false) | Err(kernel::QueryInterruptLineError::NotSupported) => {}
171-
value => panic!("{:?}", value),
171+
value => panic!("{value:?}"),
172172
}
173173

174174
if let &[pri, ..] = D::INTERRUPT_PRIORITIES {

src/r3_test_suite/src/kernel_tests/mutex_misc.rs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ fn task1_body<System: SupportedSystem, D: Driver<App<System>, System = System>>(
210210
let mut free = (1u32 << N) - 1; // 0b1111
211211
let mut locked: ArrayVec<usize, N> = ArrayVec::new();
212212
for i in (0..100).rev() {
213-
log::trace!(" locked = {:?}", locked);
213+
log::trace!(" locked = {locked:?}");
214214

215215
// All held mutexes but the last one should be prevented from being
216216
// unlocked
217217
for &[i, _] in locked.array_windows::<2>() {
218-
log::trace!(" making sure m[{}] is unlockable at this point", i);
218+
log::trace!(" making sure m[{i}] is unlockable at this point");
219219
assert_eq!(
220220
app.m[i].unlock(),
221221
Err(r3::kernel::UnlockMutexError::BadObjectState)
@@ -237,12 +237,12 @@ fn task1_body<System: SupportedSystem, D: Driver<App<System>, System = System>>(
237237
} else {
238238
rng.next() as usize % app.m.len()
239239
};
240-
log::trace!(" new_level = {}", new_level);
240+
log::trace!(" new_level = {new_level}");
241241

242242
while new_level < locked.len() {
243243
// Unlock the last held mutex
244244
let i = locked.pop().unwrap();
245-
log::trace!(" unlocking m[{:?}]", i);
245+
log::trace!(" unlocking m[{i}]");
246246
app.m[i].unlock().unwrap();
247247
free |= 1 << i;
248248
}
@@ -258,7 +258,7 @@ fn task1_body<System: SupportedSystem, D: Driver<App<System>, System = System>>(
258258
// Choose the method to use
259259
let method = (rng.next() & 0xff) % 3;
260260

261-
log::trace!(" locking m[{:?}] using method {:?})", i, method);
261+
log::trace!(" locking m[{i}] using method {method:?})");
262262
let m = app.m[i];
263263
match method {
264264
0 => m.lock().unwrap(),
@@ -286,11 +286,7 @@ fn task1_body<System: SupportedSystem, D: Driver<App<System>, System = System>>(
286286
let cur_task: LocalTask<System> = LocalTask::current().unwrap();
287287
for pri in 0..=3 {
288288
let exceeds_ceiling = pri < 1;
289-
log::trace!(
290-
"set_priority({}) exceeds_ceiling = {:?}",
291-
pri,
292-
exceeds_ceiling
293-
);
289+
log::trace!("set_priority({pri}) exceeds_ceiling = {exceeds_ceiling}");
294290
cur_task.set_priority(pri).unwrap();
295291

296292
assert_eq!(cur_task.priority().unwrap(), pri);
@@ -322,11 +318,7 @@ fn task1_body<System: SupportedSystem, D: Driver<App<System>, System = System>>(
322318
// restricted according to the locking protocol's precondition.
323319
for pri2 in 0..=3 {
324320
let exceeds_ceiling = pri2 < 1;
325-
log::trace!(
326-
" set_priority({}) exceeds_ceiling = {:?}",
327-
pri2,
328-
exceeds_ceiling
329-
);
321+
log::trace!(" set_priority({pri2}) exceeds_ceiling = {exceeds_ceiling}");
330322
if exceeds_ceiling {
331323
assert_eq!(
332324
cur_task.set_priority(pri2),
@@ -360,11 +352,7 @@ fn task1_body<System: SupportedSystem, D: Driver<App<System>, System = System>>(
360352
// restricted according to the locking protocol's precondition.
361353
for pri in (0..=3).rev() {
362354
let exceeds_ceiling = pri < 1;
363-
log::trace!(
364-
"task3.set_priority({}) exceeds_ceiling = {:?}",
365-
pri,
366-
exceeds_ceiling
367-
);
355+
log::trace!("task3.set_priority({pri}) exceeds_ceiling = {exceeds_ceiling}");
368356
if exceeds_ceiling {
369357
assert_eq!(
370358
app.task3.set_priority(pri),

src/r3_test_suite/src/kernel_tests/startup_hook_priority.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<System: SupportedSystem> App<System> {
103103
}
104104

105105
fn hook<System: SupportedSystem, D: Driver<App<System>>>(i: usize) {
106-
log::trace!("hook({})", i);
106+
log::trace!("hook({i})");
107107
D::app().seq.expect_and_replace(i, i + 1);
108108

109109
if i == 18 {

src/r3_test_suite/src/kernel_tests/task_queue_fifo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn task1_body<System: SupportedSystem, D: Driver<App<System>>>() {
6464

6565
fn task2_body<System: SupportedSystem, D: Driver<App<System>>>(i: usize) {
6666
D::app().seq.expect_and_replace(i, i + 1);
67-
log::trace!("*Rabbit noise {}*", i);
67+
log::trace!("*Rabbit noise {i}*");
6868
if i == 4 {
6969
D::success();
7070
}

src/r3_test_suite/src/kernel_tests/time_misc.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn startup_hook<System: SupportedSystem, D: Driver<App<System>>>() {
5959
fn task_body<System: SupportedSystem, D: Driver<App<System>>>() {
6060
let now = if let Some(cap) = System::TIME_CAPABILITY {
6161
let now = System::time(cap).unwrap();
62-
log::trace!("time = {:?}", now);
62+
log::trace!("time = {now:?}");
6363
Some((cap, now))
6464
} else {
6565
None
@@ -72,13 +72,13 @@ fn task_body<System: SupportedSystem, D: Driver<App<System>>>() {
7272

7373
// Now change the time
7474
let now2 = Time::from_millis(114514);
75-
log::trace!("changing system time to {:?}", now2);
75+
log::trace!("changing system time to {now2:?}");
7676
System::set_time(now2).unwrap();
7777

7878
// Because we just changed the time to `now2`, the current time should be
7979
// still very close to `now2`
8080
let now2_got = System::time(cap).unwrap();
81-
log::trace!("time = {:?}", now2_got);
81+
log::trace!("time = {now2_got:?}");
8282
assert_eq!(now2_got.duration_since(now2).unwrap().as_secs(), 0);
8383
}
8484

@@ -105,16 +105,16 @@ fn task_body<System: SupportedSystem, D: Driver<App<System>>>() {
105105
let now4_got = if let Some(cap) = System::TIME_CAPABILITY {
106106
// System time should wrap around
107107
let now3 = Time::from_micros(0xfffffffffffe0000);
108-
log::trace!("changing system time to {:?}", now3);
108+
log::trace!("changing system time to {now3:?}");
109109
System::set_time(now3).unwrap();
110110

111111
let d = Duration::from_micros(0x40000);
112-
log::trace!("sleeping for {:?}", d);
112+
log::trace!("sleeping for {d:?}");
113113
System::sleep(d).unwrap();
114114

115115
let now4 = now3 + d;
116116
let now4_got = System::time(cap).unwrap();
117-
log::trace!("time = {:?} (expected >= {:?})", now4_got, now4);
117+
log::trace!("time = {now4_got:?} (expected >= {now4:?})");
118118
assert!(now4_got.as_micros() >= now4.as_micros());
119119

120120
Some((cap, now4_got))
@@ -128,7 +128,7 @@ fn task_body<System: SupportedSystem, D: Driver<App<System>>>() {
128128
if let Some((cap, now4_got)) = now4_got {
129129
let now5 = now4_got;
130130
let now5_got = System::time(cap).unwrap();
131-
log::trace!("time = {:?} (expected {:?})", now5_got, now5);
131+
log::trace!("time = {now5_got:?} (expected {now5:?})");
132132
assert!(now5_got.as_micros() >= now5.as_micros());
133133
assert!(now5_got.as_micros() <= now5.as_micros() + 100_000);
134134
}

src/r3_test_suite/src/kernel_tests/time_stress.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn task_body<System: SupportedSystem, D: Driver<App<System>>>(i: usize) {
5151

5252
for i in 0.. {
5353
let now = System::time().unwrap();
54-
log::trace!("[{}] time = {:?}", i, now);
54+
log::trace!("[{i}] time = {now:?}");
5555

5656
if now.as_secs() >= 2 {
5757
break;
@@ -69,7 +69,7 @@ fn task_body<System: SupportedSystem, D: Driver<App<System>>>(i: usize) {
6969

7070
let now2 = Time::from_micros(now.as_micros().wrapping_add(delay.as_micros() as _));
7171
let now2_got = System::time().unwrap();
72-
log::trace!("[{}] time = {:?} (expected = {:?})", i, now2_got, now2);
72+
log::trace!("[{i}] time = {now2_got:?} (expected = {now2:?})");
7373

7474
// `now2 <= now2_got < now2 + timing_error`
7575
let delta = now2_got.duration_since(now2);

src/r3_test_suite/src/kernel_tests/timer_misc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fn task_body<System: SupportedSystem, D: Driver<App<System>>>() {
113113
if let Some(cap) = System::TIME_CAPABILITY {
114114
let now = Time::from_millis(100);
115115
let now_got = System::time(cap).unwrap();
116-
log::trace!("time = {:?} (expected {:?})", now_got, now);
116+
log::trace!("time = {now_got:?} (expected {now:?})");
117117
assert!(now_got.as_micros() >= now.as_micros());
118118
assert!(now_got.as_micros() <= now.as_micros() + 100_000);
119119
}
@@ -125,7 +125,7 @@ fn task_body<System: SupportedSystem, D: Driver<App<System>>>() {
125125
if let Some(cap) = System::TIME_CAPABILITY {
126126
let now = Time::from_millis(200);
127127
let now_got = System::time(cap).unwrap();
128-
log::trace!("time = {:?} (expected {:?})", now_got, now);
128+
log::trace!("time = {now_got:?} (expected {now:?})");
129129
assert!(now_got.as_micros() >= now.as_micros());
130130
assert!(now_got.as_micros() <= now.as_micros() + 100_000);
131131
}

0 commit comments

Comments
 (0)