1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 20:17:45 +00:00

hashsum: handle the case when md5sum is used but the file contains a different algo

This commit is contained in:
Sylvestre Ledru 2024-05-25 12:39:06 +02:00
parent 0882eea07c
commit 89b7a1a8fb
3 changed files with 37 additions and 4 deletions

View file

@ -1057,15 +1057,21 @@ fn test_cksum_mixed() {
let result = scene.ucmd().args(command).arg("f").succeeds();
at.append("CHECKSUM", result.stdout_str());
}
scene
println!("Content of CHECKSUM:\n{}", at.read("CHECKSUM"));
let result = scene
.ucmd()
.arg("--check")
.arg("-a")
.arg("sm3")
.arg("CHECKSUM")
.succeeds()
.stdout_contains("f: OK")
.stderr_contains("3 lines are improperly formatted");
.succeeds();
println!("result.stderr_str() {}", result.stderr_str());
println!("result.stdout_str() {}", result.stdout_str());
assert!(result.stdout_str().contains("f: OK"));
assert!(result
.stderr_str()
.contains("3 lines are improperly formatted"));
}
#[test]

View file

@ -668,6 +668,22 @@ fn test_check_status_code() {
.stdout_is("");
}
#[test]
fn test_sha1_with_md5sum_should_fail() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.touch("f");
at.write("f.sha1", "SHA1 (f) = d41d8cd98f00b204e9800998ecf8427e\n");
scene
.ccmd("md5sum")
.arg("--check")
.arg(at.subdir.join("f.sha1"))
.fails()
.stderr_contains("f.sha1: no properly formatted checksum lines found")
.stderr_does_not_contain("WARNING: 1 line is improperly formatted");
}
#[test]
fn test_check_no_backslash_no_space() {
let scene = TestScenario::new(util_name!());