mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
cksum/hashsum: refactor the common code.
Summary of the change: * Move the common code into checksum * Create a structure HashAlgorithm to handle the algorithm (instead of the 3 variables) * Use the same function for cksum & hashsum for --check (perform_checksum_validation) * Use the same for function for the hash generation (digest_reader) * Add unit tests * Add integration tests * Fix some incorrect tests
This commit is contained in:
parent
3523268936
commit
dbe7a20e08
8 changed files with 1046 additions and 891 deletions
|
@ -554,6 +554,15 @@ fn test_blake2b_512() {
|
|||
.arg("checksum")
|
||||
.succeeds()
|
||||
.stdout_contains("f: OK");
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("--status")
|
||||
.arg("--check")
|
||||
.arg("checksum")
|
||||
.succeeds()
|
||||
.stdout_contains("")
|
||||
.stderr_contains("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1168,3 +1177,18 @@ fn test_unknown_sha() {
|
|||
.fails()
|
||||
.stderr_contains("f: no properly formatted checksum lines found");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_check_directory_error() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.mkdir("d");
|
||||
at.write(
|
||||
"f",
|
||||
"BLAKE2b (d) = 786a02f742015903c6c6fd852552d272912f4740e15847618a86e217f71f5419d25e1031afee585313896444934eb04b903a685b1448b755d56f701afe9be2ce\n"
|
||||
);
|
||||
ucmd.arg("--check")
|
||||
.arg(at.subdir.join("f"))
|
||||
.fails()
|
||||
.stderr_contains("cksum: d: Is a directory\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue