Skip to content

Commit 0164482

Browse files
committed
test(cksum): Add GNU 9.9 tests to mod gnu_cksum_c
1 parent be99b63 commit 0164482

File tree

1 file changed

+65
-18
lines changed

1 file changed

+65
-18
lines changed

tests/by-util/test_cksum.rs

Lines changed: 65 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,6 +2459,71 @@ mod gnu_cksum_c {
24592459
scene
24602460
}
24612461

2462+
fn make_scene_with_comment() -> TestScenario {
2463+
let scene = make_scene();
2464+
2465+
scene
2466+
.fixtures
2467+
.append("CHECKSUMS", "# Very important comment\n");
2468+
2469+
scene
2470+
}
2471+
2472+
fn make_scene_with_invalid_line() -> TestScenario {
2473+
let scene = make_scene_with_comment();
2474+
2475+
scene.fixtures.append("CHECKSUMS", "invalid_line\n");
2476+
2477+
scene
2478+
}
2479+
2480+
#[test]
2481+
fn test_tagged_invalid_length() {
2482+
let (at, mut ucmd) = at_and_ucmd!();
2483+
2484+
at.write(
2485+
"sha2-bad-length.sum",
2486+
"SHA2-128 (/dev/null) = 38b060a751ac96384cd9327eb1b1e36a",
2487+
);
2488+
2489+
ucmd.arg("--check")
2490+
.arg("sha2-bad-length.sum")
2491+
.fails()
2492+
.stderr_contains("sha2-bad-length.sum: no properly formatted checksum lines found");
2493+
}
2494+
2495+
#[test]
2496+
#[cfg_attr(not(unix), ignore = "/dev/null is only available on UNIX")]
2497+
fn test_untagged_base64_matching_tag() {
2498+
let (at, mut ucmd) = at_and_ucmd!();
2499+
2500+
at.write("tag-prefix.sum", "SHA1+++++++++++++++++++++++= /dev/null");
2501+
2502+
ucmd.arg("--check")
2503+
.arg("-a")
2504+
.arg("sha1")
2505+
.arg("tag-prefix.sum")
2506+
.fails()
2507+
.stderr_contains("WARNING: 1 computed checksum did NOT match");
2508+
}
2509+
2510+
#[test]
2511+
#[cfg_attr(windows, ignore = "Awkward filename is not supported on windows")]
2512+
fn test_awkward_filename() {
2513+
let ts = TestScenario::new(util_name!());
2514+
let at = &ts.fixtures;
2515+
2516+
let awkward_file = "abc (f) = abc";
2517+
2518+
at.touch(awkward_file);
2519+
2520+
let result = ts.ucmd().arg("-a").arg("sha1").arg(awkward_file).succeeds();
2521+
2522+
at.write_bytes("tag-awkward.sum", result.stdout());
2523+
2524+
ts.ucmd().arg("-c").arg("tag-awkward.sum").succeeds();
2525+
}
2526+
24622527
#[test]
24632528
#[ignore = "todo"]
24642529
fn test_signed_checksums() {
@@ -2510,16 +2575,6 @@ mod gnu_cksum_c {
25102575
.no_output();
25112576
}
25122577

2513-
fn make_scene_with_comment() -> TestScenario {
2514-
let scene = make_scene();
2515-
2516-
scene
2517-
.fixtures
2518-
.append("CHECKSUMS", "# Very important comment\n");
2519-
2520-
scene
2521-
}
2522-
25232578
#[test]
25242579
fn test_status_with_comment() {
25252580
let scene = make_scene_with_comment();
@@ -2533,14 +2588,6 @@ mod gnu_cksum_c {
25332588
.no_output();
25342589
}
25352590

2536-
fn make_scene_with_invalid_line() -> TestScenario {
2537-
let scene = make_scene_with_comment();
2538-
2539-
scene.fixtures.append("CHECKSUMS", "invalid_line\n");
2540-
2541-
scene
2542-
}
2543-
25442591
#[test]
25452592
fn test_check_strict() {
25462593
let scene = make_scene_with_invalid_line();

0 commit comments

Comments
 (0)