mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-16 19:56:17 +00:00
Improve coverage / error messages from parse_size
PR
https://github.com/uutils/coreutils/pull/3084 (2a333ab391
) had some
missing coverage and was merged before I had a chance to fix it.
This PR adds some coverage / improved error messages that were missing
from that previous PR.
This commit is contained in:
parent
2a333ab391
commit
0ce22f3a08
8 changed files with 67 additions and 5 deletions
|
@ -460,6 +460,20 @@ fn test_zeros_to_stdout() {
|
|||
.success();
|
||||
}
|
||||
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
#[test]
|
||||
fn test_oversized_bs_32_bit() {
|
||||
for bs_param in &["bs", "ibs", "obs", "cbs"] {
|
||||
new_ucmd!()
|
||||
.args(&[format!("{}=5GB", bs_param)])
|
||||
.run()
|
||||
.no_stdout()
|
||||
.failure()
|
||||
.status_code(1)
|
||||
.stderr_is(format!("dd: {}=N cannot fit into memory\n", bs_param));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_to_stdout_with_ibs_obs() {
|
||||
let output: Vec<_> = String::from("y\n").bytes().cycle().take(1024).collect();
|
||||
|
|
|
@ -305,6 +305,16 @@ fn test_head_invalid_num() {
|
|||
new_ucmd!().args(&["-c", size]).succeeds();
|
||||
}
|
||||
}
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
{
|
||||
let sizes = ["-1000G", "-10T"];
|
||||
for size in &sizes {
|
||||
new_ucmd!()
|
||||
.args(&["-c", size])
|
||||
.fails()
|
||||
.stderr_is("head: out of range integral type conversion attempted: number of bytes is too large");
|
||||
}
|
||||
}
|
||||
new_ucmd!()
|
||||
.args(&["-c", "-³"])
|
||||
.fails()
|
||||
|
|
|
@ -342,6 +342,31 @@ fn test_split_invalid_bytes_size() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_split_chunks_num_chunks_oversized_32() {
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
{
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
at.touch("file");
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["--number", "5000000000", "file"])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_only("split: Number of chunks too big");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_split_stdin_num_chunks() {
|
||||
new_ucmd!()
|
||||
.args(&["--number=1"])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_only("split: -: cannot determine file size");
|
||||
}
|
||||
|
||||
fn file_read(at: &AtPath, filename: &str) -> String {
|
||||
let mut s = String::new();
|
||||
at.open(filename).read_to_string(&mut s).unwrap();
|
||||
|
|
|
@ -75,5 +75,15 @@ fn test_stdbuf_invalid_mode_fails() {
|
|||
.fails()
|
||||
.code_is(125)
|
||||
.stderr_contains("stdbuf: invalid mode '1Y': Value too large for defined data type");
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
{
|
||||
new_ucmd!()
|
||||
.args(&[*option, "5GB", "head"])
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.stderr_contains(
|
||||
"stdbuf: invalid mode '5GB': Value too large for defined data type",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue