Skip to content

Commit 5233258

Browse files
authored
Remove history_file (#1446)
`write_json` already accepts `AsRef<Path>`, so this conversion function doesn't do anything.
1 parent b026dd8 commit 5233258

File tree

2 files changed

+18
-31
lines changed

2 files changed

+18
-31
lines changed

crutest/src/cli.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -815,12 +815,11 @@ async fn process_cli_command(
815815
)))
816816
.await
817817
} else if let Some(vo) = verify_output {
818-
println!("Exporting write history to {:?}", vo);
819-
let cp = history_file(vo.clone());
820-
match write_json(&cp, &ri.write_log, true) {
818+
println!("Exporting write history to {vo:?}");
819+
match write_json(&vo, &ri.write_log, true) {
821820
Ok(_) => fw.send(CliMessage::DoneOk).await,
822821
Err(e) => {
823-
println!("Failed writing to {:?} with {}", vo, e);
822+
println!("Failed writing to {vo:?} with {e}");
824823
fw.send(CliMessage::Error(CrucibleError::GenericError(
825824
"Failed writing to file".to_string(),
826825
)))

crutest/src/main.rs

+15-27
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fs::File;
44
use std::io::Write;
55
use std::net::{IpAddr, SocketAddr};
66
use std::num::NonZeroU64;
7-
use std::path::{Path, PathBuf};
7+
use std::path::PathBuf;
88
use std::sync::{
99
atomic::{AtomicBool, AtomicUsize, Ordering},
1010
Arc,
@@ -299,11 +299,6 @@ pub fn opts() -> Result<Opt> {
299299
Ok(opt)
300300
}
301301

302-
fn history_file<P: AsRef<Path>>(file: P) -> PathBuf {
303-
let out = file.as_ref().to_path_buf();
304-
out
305-
}
306-
307302
#[derive(Copy, Clone, Debug, clap::Args)]
308303
struct BufferbloatWorkload {
309304
/// Size in blocks of each IO
@@ -681,16 +676,14 @@ async fn load_write_log(
681676
/*
682677
* Fill the write count from a provided file.
683678
*/
684-
let cp = history_file(vi);
685-
ri.write_log = match read_json(&cp) {
679+
ri.write_log = match read_json(&vi) {
686680
Ok(write_log) => write_log,
687-
Err(e) => bail!("Error {:?} reading verify config {:?}", e, cp),
681+
Err(e) => bail!("Error {:?} reading verify config {:?}", e, vi),
688682
};
689-
println!("Loading write count information from file {:?}", cp);
683+
println!("Loading write count information from file {vi:?}");
690684
if ri.write_log.len() != ri.total_blocks {
691685
bail!(
692-
"Verify file {:?} blocks:{} does not match regions:{}",
693-
cp,
686+
"Verify file {vi:?} blocks:{} does not match regions:{}",
694687
ri.write_log.len(),
695688
ri.total_blocks
696689
);
@@ -992,9 +985,8 @@ async fn main() -> Result<()> {
992985
* things that came after the flush.
993986
*/
994987
if let Some(vo) = &opt.verify_out {
995-
let cp = history_file(vo);
996-
write_json(&cp, &region_info.write_log, true)?;
997-
println!("Wrote out file {:?}", cp);
988+
write_json(vo, &region_info.write_log, true)?;
989+
println!("Wrote out file {vo:?}");
998990
}
999991
return Ok(());
1000992
}
@@ -1137,9 +1129,8 @@ async fn main() -> Result<()> {
11371129
repair_workload(&guest, count, &mut region_info).await?;
11381130
drop(guest);
11391131
if let Some(vo) = &opt.verify_out {
1140-
let cp = history_file(vo);
1141-
write_json(&cp, &region_info.write_log, true)?;
1142-
println!("Wrote out file {:?}", cp);
1132+
write_json(vo, &region_info.write_log, true)?;
1133+
println!("Wrote out file {vo:?}");
11431134
}
11441135
return Ok(());
11451136
}
@@ -1258,9 +1249,8 @@ async fn main() -> Result<()> {
12581249
bail!("Initial volume verify failed: {:?}", e)
12591250
}
12601251
if let Some(vo) = &opt.verify_out {
1261-
let cp = history_file(vo);
1262-
write_json(&cp, &region_info.write_log, true)?;
1263-
println!("Wrote out file {:?}", cp);
1252+
write_json(vo, &region_info.write_log, true)?;
1253+
println!("Wrote out file {vo:?}");
12641254
}
12651255
if opt.quit {
12661256
println!("Verify test completed");
@@ -1303,9 +1293,8 @@ async fn main() -> Result<()> {
13031293
}
13041294

13051295
if let Some(vo) = &opt.verify_out {
1306-
let cp = history_file(vo);
1307-
write_json(&cp, &region_info.write_log, true)?;
1308-
println!("Wrote out file {:?}", cp);
1296+
write_json(vo, &region_info.write_log, true)?;
1297+
println!("Wrote out file {vo:?}");
13091298
}
13101299

13111300
println!("CLIENT: Tests done. All submitted work has been ACK'd");
@@ -3541,9 +3530,8 @@ async fn burst_workload(
35413530
*/
35423531
println!();
35433532
if let Some(vo) = &verify_out {
3544-
let cp = history_file(vo);
3545-
write_json(&cp, &ri.write_log, true)?;
3546-
println!("Wrote out file {:?} at this time", cp);
3533+
write_json(vo, &ri.write_log, true)?;
3534+
println!("Wrote out file {vo:?} at this time");
35473535
}
35483536
println!(
35493537
"{:>0width$}/{:>0width$}: 2 second pause, then another test loop",

0 commit comments

Comments
 (0)