[all] Apply cargo fmt
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
use anyhow::Result;
|
||||
use thinp::version::TOOLS_VERSION;
|
||||
use duct::cmd;
|
||||
use thinp::version::TOOLS_VERSION;
|
||||
|
||||
mod common;
|
||||
|
||||
use common::*;
|
||||
use common::test_dir::*;
|
||||
use common::*;
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
@@ -88,7 +88,7 @@ fn failing_q() -> Result<()> {
|
||||
assert_eq!(output.stderr.len(), 0);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn failing_quiet() -> Result<()> {
|
||||
let mut td = TestDir::new()?;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use anyhow::{Result};
|
||||
use anyhow::Result;
|
||||
use rand::prelude::*;
|
||||
use std::collections::HashSet;
|
||||
use std::fs::OpenOptions;
|
||||
|
||||
@@ -4,14 +4,14 @@ use anyhow::Result;
|
||||
use duct::{cmd, Expression};
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::{Read, Write};
|
||||
use std::path::{PathBuf};
|
||||
use std::path::PathBuf;
|
||||
use std::str::from_utf8;
|
||||
use thinp::file_utils;
|
||||
use thinp::io_engine::*;
|
||||
|
||||
pub mod thin_xml_generator;
|
||||
pub mod cache_xml_generator;
|
||||
pub mod test_dir;
|
||||
pub mod thin_xml_generator;
|
||||
|
||||
use crate::common::thin_xml_generator::{write_xml, SingleThinS};
|
||||
use test_dir::TestDir;
|
||||
@@ -273,7 +273,12 @@ pub fn set_needs_check(md: &PathBuf) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn generate_metadata_leaks(md: &PathBuf, nr_blocks: u64, expected: u32, actual: u32) -> Result<()> {
|
||||
pub fn generate_metadata_leaks(
|
||||
md: &PathBuf,
|
||||
nr_blocks: u64,
|
||||
expected: u32,
|
||||
actual: u32,
|
||||
) -> Result<()> {
|
||||
let output = thin_generate_damage!(
|
||||
"-o",
|
||||
&md,
|
||||
@@ -318,4 +323,3 @@ where
|
||||
assert_eq!(csum, md5(p)?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ use anyhow::Result;
|
||||
use thinp::version::TOOLS_VERSION;
|
||||
|
||||
mod common;
|
||||
use common::*;
|
||||
use common::test_dir::*;
|
||||
use common::*;
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
@@ -68,4 +68,3 @@ fn dev_unspecified() -> Result<()> {
|
||||
assert!(stderr.contains("No input device provided"));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use anyhow::Result;
|
||||
use thinp::file_utils;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::{Write};
|
||||
use std::io::Write;
|
||||
use std::str::from_utf8;
|
||||
use thinp::file_utils;
|
||||
|
||||
mod common;
|
||||
use common::*;
|
||||
use common::test_dir::*;
|
||||
use common::*;
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
@@ -27,7 +27,11 @@ fn dump_restore_cycle() -> Result<()> {
|
||||
let output = thin_dump!(&md).run()?;
|
||||
|
||||
let xml = td.mk_path("meta.xml");
|
||||
let mut file = OpenOptions::new().read(false).write(true).create(true).open(&xml)?;
|
||||
let mut file = OpenOptions::new()
|
||||
.read(false)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.open(&xml)?;
|
||||
file.write_all(&output.stdout[0..])?;
|
||||
drop(file);
|
||||
|
||||
@@ -63,7 +67,7 @@ fn override_something(flag: &str, value: &str, pattern: &str) -> Result<()> {
|
||||
|
||||
#[test]
|
||||
fn override_transaction_id() -> Result<()> {
|
||||
override_something("--transaction-id", "2345", "transaction=\"2345\"")
|
||||
override_something("--transaction-id", "2345", "transaction=\"2345\"")
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -80,13 +84,26 @@ fn override_nr_data_blocks() -> Result<()> {
|
||||
fn repair_superblock() -> Result<()> {
|
||||
let mut td = TestDir::new()?;
|
||||
let md = mk_valid_md(&mut td)?;
|
||||
let before = thin_dump!("--transaction-id=5", "--data-block-size=128", "--nr-data-blocks=4096000", &md).run()?;
|
||||
let before = thin_dump!(
|
||||
"--transaction-id=5",
|
||||
"--data-block-size=128",
|
||||
"--nr-data-blocks=4096000",
|
||||
&md
|
||||
)
|
||||
.run()?;
|
||||
damage_superblock(&md)?;
|
||||
|
||||
let after = thin_dump!("--repair", "--transaction-id=5", "--data-block-size=128", "--nr-data-blocks=4096000", &md).run()?;
|
||||
let after = thin_dump!(
|
||||
"--repair",
|
||||
"--transaction-id=5",
|
||||
"--data-block-size=128",
|
||||
"--nr-data-blocks=4096000",
|
||||
&md
|
||||
)
|
||||
.run()?;
|
||||
assert_eq!(after.stderr.len(), 0);
|
||||
assert_eq!(before.stdout, after.stdout);
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -95,7 +112,12 @@ fn missing_transaction_id() -> Result<()> {
|
||||
let mut td = TestDir::new()?;
|
||||
let md = mk_valid_md(&mut td)?;
|
||||
damage_superblock(&md)?;
|
||||
let stderr = run_fail(thin_dump!("--repair", "--data-block-size=128", "--nr-data-blocks=4096000", &md))?;
|
||||
let stderr = run_fail(thin_dump!(
|
||||
"--repair",
|
||||
"--data-block-size=128",
|
||||
"--nr-data-blocks=4096000",
|
||||
&md
|
||||
))?;
|
||||
assert!(stderr.contains("transaction id"));
|
||||
Ok(())
|
||||
}
|
||||
@@ -105,7 +127,12 @@ fn missing_data_block_size() -> Result<()> {
|
||||
let mut td = TestDir::new()?;
|
||||
let md = mk_valid_md(&mut td)?;
|
||||
damage_superblock(&md)?;
|
||||
let stderr = run_fail(thin_dump!("--repair", "--transaction-id=5", "--nr-data-blocks=4096000", &md))?;
|
||||
let stderr = run_fail(thin_dump!(
|
||||
"--repair",
|
||||
"--transaction-id=5",
|
||||
"--nr-data-blocks=4096000",
|
||||
&md
|
||||
))?;
|
||||
assert!(stderr.contains("data block size"));
|
||||
Ok(())
|
||||
}
|
||||
@@ -115,7 +142,12 @@ fn missing_nr_data_blocks() -> Result<()> {
|
||||
let mut td = TestDir::new()?;
|
||||
let md = mk_valid_md(&mut td)?;
|
||||
damage_superblock(&md)?;
|
||||
let stderr = run_fail(thin_dump!("--repair", "--transaction-id=5", "--data-block-size=128", &md))?;
|
||||
let stderr = run_fail(thin_dump!(
|
||||
"--repair",
|
||||
"--transaction-id=5",
|
||||
"--data-block-size=128",
|
||||
&md
|
||||
))?;
|
||||
assert!(stderr.contains("nr data blocks"));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ use anyhow::Result;
|
||||
use thinp::version::TOOLS_VERSION;
|
||||
|
||||
mod common;
|
||||
use common::*;
|
||||
use common::test_dir::*;
|
||||
use common::*;
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ use anyhow::Result;
|
||||
use thinp::version::TOOLS_VERSION;
|
||||
|
||||
mod common;
|
||||
use common::*;
|
||||
use common::test_dir::*;
|
||||
use common::*;
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ use std::str::from_utf8;
|
||||
use thinp::version::TOOLS_VERSION;
|
||||
|
||||
mod common;
|
||||
use common::*;
|
||||
use common::test_dir::*;
|
||||
use common::*;
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
@@ -132,8 +132,7 @@ fn superblock_succeeds() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn missing_thing(flag1: &str, flag2: &str, pattern: &str) -> Result<()>
|
||||
{
|
||||
fn missing_thing(flag1: &str, flag2: &str, pattern: &str) -> Result<()> {
|
||||
let mut td = TestDir::new()?;
|
||||
let md1 = mk_valid_md(&mut td)?;
|
||||
damage_superblock(&md1)?;
|
||||
@@ -145,15 +144,27 @@ fn missing_thing(flag1: &str, flag2: &str, pattern: &str) -> Result<()>
|
||||
|
||||
#[test]
|
||||
fn missing_transaction_id() -> Result<()> {
|
||||
missing_thing("--data-block-size=128", "--nr-data-blocks=4096000", "transaction id")
|
||||
missing_thing(
|
||||
"--data-block-size=128",
|
||||
"--nr-data-blocks=4096000",
|
||||
"transaction id",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_data_block_size() -> Result<()> {
|
||||
missing_thing("--transaction-id=5", "--nr-data-blocks=4096000", "data block size")
|
||||
missing_thing(
|
||||
"--transaction-id=5",
|
||||
"--nr-data-blocks=4096000",
|
||||
"data block size",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_nr_data_blocks() -> Result<()> {
|
||||
missing_thing("--transaction-id=5", "--data-block-size=128", "nr data blocks")
|
||||
missing_thing(
|
||||
"--transaction-id=5",
|
||||
"--data-block-size=128",
|
||||
"nr data blocks",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ use thinp::file_utils;
|
||||
use thinp::version::TOOLS_VERSION;
|
||||
|
||||
mod common;
|
||||
use common::*;
|
||||
use common::test_dir::*;
|
||||
use common::*;
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ use anyhow::Result;
|
||||
use thinp::version::TOOLS_VERSION;
|
||||
|
||||
mod common;
|
||||
use common::*;
|
||||
use common::test_dir::*;
|
||||
use common::*;
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
@@ -54,7 +54,16 @@ fn valid_region_format_should_pass() -> Result<()> {
|
||||
|
||||
#[test]
|
||||
fn invalid_regions_should_fail() -> Result<()> {
|
||||
let invalid_regions = ["23,7890", "23..six", "found..7890", "89..88", "89..89", "89..", "", "89...99"];
|
||||
let invalid_regions = [
|
||||
"23,7890",
|
||||
"23..six",
|
||||
"found..7890",
|
||||
"89..88",
|
||||
"89..89",
|
||||
"89..",
|
||||
"",
|
||||
"89...99",
|
||||
];
|
||||
for r in &invalid_regions {
|
||||
let mut td = TestDir::new()?;
|
||||
let md = mk_valid_md(&mut td)?;
|
||||
|
||||
@@ -3,16 +3,14 @@ use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||
use rand::prelude::*;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::{Cursor, Read, Seek, SeekFrom, Write};
|
||||
use std::path::{Path};
|
||||
use std::path::Path;
|
||||
|
||||
use thinp::file_utils;
|
||||
use thinp::thin::xml::{self, Visit};
|
||||
|
||||
mod common;
|
||||
use common::test_dir::*;
|
||||
use common::thin_xml_generator::{
|
||||
write_xml, EmptyPoolS, FragmentedS, SingleThinS, SnapS, XmlGen
|
||||
};
|
||||
use common::thin_xml_generator::{write_xml, EmptyPoolS, FragmentedS, SingleThinS, SnapS, XmlGen};
|
||||
|
||||
//------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user