Skip to content

Commit 246db35

Browse files
committed
b2sum: report malformed status input
1 parent 7cfc74e commit 246db35

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

src/uucore/src/lib/features/checksum/validate.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -951,9 +951,7 @@ fn process_checksum_file(
951951
// not a single line correctly formatted found
952952
// return an error
953953
if res.total_properly_formatted() == 0 {
954-
if opts.verbose.over_status() {
955-
log_no_properly_formatted(filename_display());
956-
}
954+
log_no_properly_formatted(filename_display());
957955
return Err(FileCheckError::Failed);
958956
}
959957

tests/by-util/test_b2sum.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,23 @@ fn test_check_b2sum_length_option_8() {
158158
.stdout_only("testf: OK\n");
159159
}
160160

161+
#[test]
162+
fn test_check_b2sum_status_reports_no_properly_formatted_lines() {
163+
let invalid_checksum = concat!(
164+
"bedfbb90d858c2d67b7ee8f7523be3d3b54004ef9e4f02f2",
165+
"ad79a1d05bfdfe49b81e3c92ebf99b504102b6bf003fa342",
166+
"587f5b3124c205f55204e8c4b4ce7d7c",
167+
);
168+
169+
new_ucmd!()
170+
.arg("-c")
171+
.arg("--status")
172+
.pipe_in(invalid_checksum)
173+
.fails()
174+
.no_stdout()
175+
.stderr_contains("b2sum: 'standard input': no properly formatted checksum lines found");
176+
}
177+
161178
#[test]
162179
fn test_invalid_b2sum_length_option_not_multiple_of_8() {
163180
let scene = TestScenario::new(util_name!());

0 commit comments

Comments
 (0)