blob: 3cac0f5811c65d65401b3c53abc56c4de2a9c3f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
mod fixtures;
use fixtures::*;
use assert_cmd::prelude::*;
use std::fs;
use std::fs::File;
use std::io::{Read, Write};
use std::process::Command;
use tempfile::tempdir;
#[test]
fn it_respects_directory_output() {
let d = tempdir().unwrap();
let f = d.as_ref().join("test.out");
let sample = mft_sample();
let mut cmd = Command::cargo_bin("mft_dump").expect("failed to find binary");
cmd.args(&["-f", &f.to_string_lossy(), sample.to_str().unwrap()]);
assert!(
cmd.output().unwrap().stdout.is_empty(),
"Expected output to be printed to file, but was printed to stdout"
);
let mut expected = vec![];
File::open(&f).unwrap().read_to_end(&mut expected).unwrap();
assert!(
!expected.is_empty(),
"Expected output to be printed to file"
)
}
#[test]
fn test_it_refuses_to_overwrite_directory() {
let d = tempdir().unwrap();
let sample = mft_sample();
let mut cmd = Command::cargo_bin("mft_dump").expect("failed to find binary");
cmd.args(&["-f", &d.path().to_string_lossy(), sample.to_str().unwrap()]);
cmd.assert().failure().code(1);
}
#[test]
fn test_non_mft_file_is_error() {
let d = tempdir().unwrap();
let f = d.as_ref().join("test.out");
let mut file = File::create(&f).unwrap();
file.write_all(b"I'm a file!").unwrap();
let mut cmd = Command::cargo_bin("mft_dump").expect("failed to find binary");
cmd.args(&[f.to_str().unwrap()]);
cmd.assert().failure().code(1);
}
#[test]
fn test_it_exports_resident_streams() {
let d = tempdir().unwrap();
let sample = mft_sample();
let mut cmd = Command::cargo_bin("mft_dump").expect("failed to find binary");
cmd.args(&[
"-e",
&d.path().to_string_lossy().to_string(),
&sample.to_string_lossy().to_string(),
]);
cmd.assert().success();
assert_eq!(fs::read_dir(d.path()).unwrap().count(), 2142)
}
|