2020-08-05 12:54:52 +05:30
|
|
|
use anyhow::Result;
|
|
|
|
|
|
|
|
mod common;
|
2021-07-01 19:57:37 +05:30
|
|
|
|
|
|
|
use common::common_args::*;
|
2020-08-07 19:00:00 +05:30
|
|
|
use common::test_dir::*;
|
2021-05-04 13:40:20 +05:30
|
|
|
use common::*;
|
2020-08-05 12:54:52 +05:30
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
|
2021-07-01 19:57:37 +05:30
|
|
|
const USAGE: &str = "Usage: thin_delta [options] <device or file>\n\
|
|
|
|
Options:\n \
|
|
|
|
{--thin1, --snap1, --root1}\n \
|
|
|
|
{--thin2, --snap2, --root2}\n \
|
|
|
|
{-m, --metadata-snap} [block#]\n \
|
|
|
|
{--verbose}\n \
|
|
|
|
{-h|--help}\n \
|
|
|
|
{-V|--version}";
|
2020-08-05 12:54:52 +05:30
|
|
|
|
2021-07-01 19:57:37 +05:30
|
|
|
//------------------------------------------
|
2020-08-05 12:54:52 +05:30
|
|
|
|
2021-07-01 19:57:37 +05:30
|
|
|
test_accepts_help!(THIN_DELTA, USAGE);
|
|
|
|
test_accepts_version!(THIN_DELTA);
|
|
|
|
test_rejects_bad_option!(THIN_DELTA);
|
2020-08-05 12:54:52 +05:30
|
|
|
|
2021-07-01 19:57:37 +05:30
|
|
|
//------------------------------------------
|
2020-08-05 12:54:52 +05:30
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn snap1_unspecified() -> Result<()> {
|
|
|
|
let mut td = TestDir::new()?;
|
|
|
|
let md = mk_valid_md(&mut td)?;
|
2021-07-01 19:57:37 +05:30
|
|
|
let stderr = run_fail(THIN_DELTA, &["--snap2", "45", md.to_str().unwrap()])?;
|
2020-11-26 08:05:40 +05:30
|
|
|
assert!(stderr.contains("--snap1 or --root1 not specified"));
|
2020-08-05 12:54:52 +05:30
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn snap2_unspecified() -> Result<()> {
|
|
|
|
let mut td = TestDir::new()?;
|
|
|
|
let md = mk_valid_md(&mut td)?;
|
2021-07-01 19:57:37 +05:30
|
|
|
let stderr = run_fail(THIN_DELTA, &["--snap1", "45", md.to_str().unwrap()])?;
|
2020-11-26 08:05:40 +05:30
|
|
|
assert!(stderr.contains("--snap2 or --root2 not specified"));
|
2020-08-05 12:54:52 +05:30
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn dev_unspecified() -> Result<()> {
|
2021-07-01 19:57:37 +05:30
|
|
|
let stderr = run_fail(THIN_DELTA, &["--snap1", "45", "--snap2", "46"])?;
|
2021-06-21 13:14:56 +05:30
|
|
|
// TODO: replace with msg::MISSING_INPUT_ARG once the rust version is ready
|
|
|
|
assert!(stderr.contains("No input file provided"));
|
2020-08-05 12:54:52 +05:30
|
|
|
Ok(())
|
|
|
|
}
|
2021-07-01 19:57:37 +05:30
|
|
|
|
|
|
|
//------------------------------------------
|