1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-16 03:36:18 +00:00

Merge branch 'uutils:main' into mkdir-fix

This commit is contained in:
Pyokyeong Son 2022-03-25 23:03:29 +09:00 committed by GitHub
commit 8108fb15b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
249 changed files with 2625 additions and 1299 deletions

View file

@ -183,6 +183,16 @@ fn test_cp_arg_no_target_directory() {
.stderr_contains("cannot overwrite directory");
}
#[test]
fn test_cp_target_directory_is_file() {
new_ucmd!()
.arg("-t")
.arg(TEST_HOW_ARE_YOU_SOURCE)
.arg(TEST_HELLO_WORLD_SOURCE)
.fails()
.stderr_contains(format!("'{}' is not a directory", TEST_HOW_ARE_YOU_SOURCE));
}
#[test]
fn test_cp_arg_interactive() {
new_ucmd!()

View file

@ -1,4 +1,4 @@
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, availible, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat abcdefghijklm abcdefghi nabcde nabcdefg abcdefg
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, availible, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, iseek, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, oseek, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat abcdefghijklm abcdefghi nabcde nabcdefg abcdefg
use crate::common::util::*;
@ -1139,3 +1139,48 @@ fn test_block_sync() {
.stdout_is("012 abcde ")
.stderr_is("2+1 records in\n0+1 records out\n1 truncated record\n");
}
#[test]
fn test_bytes_iseek_bytes_iflag() {
new_ucmd!()
.args(&["iseek=10", "iflag=skip_bytes", "bs=2"])
.pipe_in("0123456789abcdefghijklm")
.succeeds()
.stdout_is("abcdefghijklm");
}
#[test]
fn test_bytes_iseek_skip_additive() {
new_ucmd!()
.args(&["iseek=5", "skip=5", "iflag=skip_bytes", "bs=2"])
.pipe_in("0123456789abcdefghijklm")
.succeeds()
.stdout_is("abcdefghijklm");
}
#[test]
fn test_bytes_oseek_bytes_oflag() {
new_ucmd!()
.args(&["oseek=8", "oflag=seek_bytes", "bs=2"])
.pipe_in("abcdefghijklm")
.succeeds()
.stdout_is_fixture_bytes("dd-bytes-alphabet-null.spec");
}
#[test]
fn test_bytes_oseek_bytes_trunc_oflag() {
new_ucmd!()
.args(&["oseek=8", "oflag=seek_bytes", "bs=2", "count=0"])
.pipe_in("abcdefghijklm")
.succeeds()
.stdout_is_fixture_bytes("dd-bytes-null-trunc.spec");
}
#[test]
fn test_bytes_oseek_seek_additive() {
new_ucmd!()
.args(&["oseek=4", "seek=4", "oflag=seek_bytes", "bs=2"])
.pipe_in("abcdefghijklm")
.succeeds()
.stdout_is_fixture_bytes("dd-bytes-alphabet-null.spec");
}

View file

@ -85,6 +85,11 @@ fn test_type_option() {
new_ucmd!().args(&["-t", "ext4", "-t", "ext3"]).succeeds();
}
#[test]
fn test_exclude_type_option() {
new_ucmd!().args(&["-x", "ext4", "-x", "ext3"]).succeeds();
}
#[test]
fn test_total() {
// Example output:

View file

@ -483,7 +483,7 @@ fn test_install_copy_then_compare_file() {
file2_meta = at.metadata(file2);
let after = FileTime::from_last_modification_time(&file2_meta);
assert!(before == after);
assert_eq!(before, after);
}
#[test]

View file

@ -45,7 +45,7 @@ fn test_link_one_argument() {
let (_, mut ucmd) = at_and_ucmd!();
let file = "test_link_argument";
ucmd.args(&[file]).fails().stderr_contains(
"error: The argument '<FILES>...' requires at least 2 values, but only 1 was provide",
"error: The argument '<FILES>...' requires at least 2 values but only 1 was provided",
);
}

View file

@ -79,7 +79,224 @@ fn test_ls_ordering() {
.stdout_matches(&Regex::new("some-dir1:\\ntotal 0").unwrap());
}
//#[cfg(all(feature = "mknod"))]
#[cfg(all(feature = "truncate", feature = "dd"))]
#[test]
fn test_ls_allocation_size() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.mkdir("some-dir1");
at.touch("some-dir1/empty-file");
#[cfg(unix)]
{
scene
.ccmd("truncate")
.arg("-s")
.arg("4M")
.arg("some-dir1/file-with-holes")
.succeeds();
// fill empty file with zeros
scene
.ccmd("dd")
.arg("--if=/dev/zero")
.arg("--of=some-dir1/zero-file")
.arg("bs=1024")
.arg("count=4096")
.succeeds();
scene
.ccmd("dd")
.arg("--if=/dev/zero")
.arg("--of=irregular-file")
.arg("bs=1")
.arg("count=777")
.succeeds();
scene
.ucmd()
.arg("-l")
.arg("--block-size=512")
.arg("irregular-file")
.succeeds()
.stdout_matches(&Regex::new("[^ ] 2 [^ ]").unwrap());
scene
.ucmd()
.arg("-s1")
.arg("some-dir1")
.succeeds()
.stdout_is("total 4096\n 0 empty-file\n 0 file-with-holes\n4096 zero-file\n");
scene
.ucmd()
.arg("-sl")
.arg("some-dir1")
.succeeds()
// block size is 0 whereas size/len is 4194304
.stdout_contains("4194304");
scene
.ucmd()
.arg("-s1")
.arg("some-dir1")
.succeeds()
.stdout_contains("0 empty-file")
.stdout_contains("4096 zero-file");
// Test alignment of different block sized files
let res = scene.ucmd().arg("-si1").arg("some-dir1").succeeds();
let empty_file_len = String::from_utf8(res.stdout().to_owned())
.ok()
.unwrap()
.lines()
.nth(1)
.unwrap()
.strip_suffix("empty-file")
.unwrap()
.len();
let file_with_holes_len = String::from_utf8(res.stdout().to_owned())
.ok()
.unwrap()
.lines()
.nth(2)
.unwrap()
.strip_suffix("file-with-holes")
.unwrap()
.len();
assert_eq!(empty_file_len, file_with_holes_len);
scene
.ucmd()
.env("LS_BLOCK_SIZE", "8K")
.env("BLOCK_SIZE", "4K")
.arg("-s1")
.arg("some-dir1")
.succeeds()
.stdout_contains("total 512")
.stdout_contains("0 empty-file")
.stdout_contains("0 file-with-holes")
.stdout_contains("512 zero-file");
scene
.ucmd()
.env("BLOCK_SIZE", "4K")
.arg("-s1")
.arg("some-dir1")
.succeeds()
.stdout_contains("total 1024")
.stdout_contains("0 empty-file")
.stdout_contains("0 file-with-holes")
.stdout_contains("1024 zero-file");
scene
.ucmd()
.env("BLOCK_SIZE", "4K")
.arg("-s1")
.arg("--si")
.arg("some-dir1")
.succeeds()
.stdout_contains("total 4.2M")
.stdout_contains("0 empty-file")
.stdout_contains("0 file-with-holes")
.stdout_contains("4.2M zero-file");
scene
.ucmd()
.env("BLOCK_SIZE", "4096")
.arg("-s1")
.arg("some-dir1")
.succeeds()
.stdout_contains("total 1024")
.stdout_contains("0 empty-file")
.stdout_contains("0 file-with-holes")
.stdout_contains("1024 zero-file");
scene
.ucmd()
.env("POSIXLY_CORRECT", "true")
.arg("-s1")
.arg("some-dir1")
.succeeds()
.stdout_contains("total 8192")
.stdout_contains("0 empty-file")
.stdout_contains("0 file-with-holes")
.stdout_contains("8192 zero-file");
// -k should make 'ls' ignore the env var
scene
.ucmd()
.env("BLOCK_SIZE", "4K")
.arg("-s1k")
.arg("some-dir1")
.succeeds()
.stdout_contains("total 4096")
.stdout_contains("0 empty-file")
.stdout_contains("0 file-with-holes")
.stdout_contains("4096 zero-file");
// but manually specified blocksize overrides -k
scene
.ucmd()
.arg("-s1k")
.arg("--block-size=4K")
.arg("some-dir1")
.succeeds()
.stdout_contains("total 1024")
.stdout_contains("0 empty-file")
.stdout_contains("0 file-with-holes")
.stdout_contains("1024 zero-file");
scene
.ucmd()
.arg("-s1")
.arg("--block-size=4K")
.arg("some-dir1")
.succeeds()
.stdout_contains("total 1024")
.stdout_contains("0 empty-file")
.stdout_contains("0 file-with-holes")
.stdout_contains("1024 zero-file");
// si option should always trump the human-readable option
scene
.ucmd()
.arg("-s1h")
.arg("--si")
.arg("some-dir1")
.succeeds()
.stdout_contains("total 4.2M")
.stdout_contains("0 empty-file")
.stdout_contains("0 file-with-holes")
.stdout_contains("4.2M zero-file");
scene
.ucmd()
.arg("-s1")
.arg("--block-size=human-readable")
.arg("some-dir1")
.succeeds()
.stdout_contains("total 4.0M")
.stdout_contains("0 empty-file")
.stdout_contains("0 file-with-holes")
.stdout_contains("4.0M zero-file");
scene
.ucmd()
.arg("-s1")
.arg("--block-size=si")
.arg("some-dir1")
.succeeds()
.stdout_contains("total 4.2M")
.stdout_contains("0 empty-file")
.stdout_contains("0 file-with-holes")
.stdout_contains("4.2M zero-file");
}
}
#[test]
fn test_ls_devices() {
let scene = TestScenario::new(util_name!());
@ -107,7 +324,7 @@ fn test_ls_devices() {
.stdout_matches(&Regex::new("[^ ] 1, 3 [^ ]").unwrap());
}
// Regex tests alignment against a file (stdout is a link to a tty)
// Tests display alignment against a file (stdout is a link to a tty)
#[cfg(unix)]
{
let res = scene
@ -2542,22 +2759,14 @@ fn test_ls_dangling_symlinks() {
.succeeds()
.stdout_contains("dangle");
#[cfg(not(windows))]
scene
.ucmd()
.arg("-Li")
.arg("temp_dir")
.fails()
.stderr_contains("cannot access")
.stdout_contains("? dangle");
#[cfg(windows)]
scene
.ucmd()
.arg("-Li")
.arg("temp_dir")
.succeeds()
.stdout_contains("dangle");
.stderr_contains("No such file or directory")
.stdout_contains(if cfg!(windows) { "dangle" } else { "? dangle" });
scene
.ucmd()
@ -2660,3 +2869,47 @@ fn test_ls_context_format() {
);
}
}
#[test]
#[allow(non_snake_case)]
fn test_ls_a_A() {
let scene = TestScenario::new(util_name!());
scene
.ucmd()
.arg("-A")
.arg("-a")
.succeeds()
.stdout_contains(".")
.stdout_contains("..");
scene
.ucmd()
.arg("-a")
.arg("-A")
.succeeds()
.stdout_does_not_contain(".")
.stdout_does_not_contain("..");
}
#[test]
#[allow(non_snake_case)]
fn test_ls_multiple_a_A() {
let scene = TestScenario::new(util_name!());
scene
.ucmd()
.arg("-a")
.arg("-a")
.succeeds()
.stdout_contains(".")
.stdout_contains("..");
scene
.ucmd()
.arg("-A")
.arg("-A")
.succeeds()
.stdout_does_not_contain(".")
.stdout_does_not_contain("..");
}

View file

@ -86,14 +86,14 @@ fn test_mknod_character_device_requires_major_and_minor() {
.arg("1")
.arg("c")
.fails()
.stderr_contains(&"Invalid value for '<MINOR>'");
.stderr_contains(&"Invalid value \"c\" for '<MINOR>'");
new_ucmd!()
.arg("test_file")
.arg("c")
.arg("c")
.arg("1")
.fails()
.stderr_contains(&"Invalid value for '<MAJOR>'");
.stderr_contains(&"Invalid value \"c\" for '<MAJOR>'");
}
#[test]

View file

@ -20,7 +20,7 @@ fn test_nproc_all_omp() {
.succeeds();
let nproc_omp: u8 = result.stdout_str().trim().parse().unwrap();
assert!(nproc_omp == 60);
assert_eq!(nproc_omp, 60);
let result = TestScenario::new(util_name!())
.ucmd_keepenv()
@ -28,7 +28,7 @@ fn test_nproc_all_omp() {
.arg("--all")
.succeeds();
let nproc_omp: u8 = result.stdout_str().trim().parse().unwrap();
assert!(nproc == nproc_omp);
assert_eq!(nproc, nproc_omp);
// If the parsing fails, returns the number of CPU
let result = TestScenario::new(util_name!())
@ -36,7 +36,7 @@ fn test_nproc_all_omp() {
.env("OMP_NUM_THREADS", "incorrectnumber") // returns the number CPU
.succeeds();
let nproc_omp: u8 = result.stdout_str().trim().parse().unwrap();
assert!(nproc == nproc_omp);
assert_eq!(nproc, nproc_omp);
}
#[test]
@ -51,14 +51,14 @@ fn test_nproc_ignore() {
.arg((nproc_total - 1).to_string())
.succeeds();
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
assert!(nproc == 1);
assert_eq!(nproc, 1);
// Ignore all CPU but one with a string
let result = TestScenario::new(util_name!())
.ucmd_keepenv()
.arg("--ignore= 1")
.succeeds();
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
assert!(nproc_total - 1 == nproc);
assert_eq!(nproc_total - 1, nproc);
}
}
@ -70,5 +70,99 @@ fn test_nproc_ignore_all_omp() {
.arg("--ignore=40")
.succeeds();
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
assert!(nproc == 2);
assert_eq!(nproc, 2);
}
#[test]
fn test_nproc_omp_limit() {
let result = TestScenario::new(util_name!())
.ucmd_keepenv()
.env("OMP_NUM_THREADS", "42")
.env("OMP_THREAD_LIMIT", "0")
.succeeds();
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
assert_eq!(nproc, 42);
let result = TestScenario::new(util_name!())
.ucmd_keepenv()
.env("OMP_NUM_THREADS", "42")
.env("OMP_THREAD_LIMIT", "2")
.succeeds();
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
assert_eq!(nproc, 2);
let result = TestScenario::new(util_name!())
.ucmd_keepenv()
.env("OMP_NUM_THREADS", "42")
.env("OMP_THREAD_LIMIT", "2bad")
.succeeds();
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
assert_eq!(nproc, 42);
let result = new_ucmd!().arg("--all").succeeds();
let nproc_system: u8 = result.stdout_str().trim().parse().unwrap();
assert!(nproc_system > 0);
let result = TestScenario::new(util_name!())
.ucmd_keepenv()
.env("OMP_THREAD_LIMIT", "1")
.succeeds();
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
assert_eq!(nproc, 1);
let result = TestScenario::new(util_name!())
.ucmd_keepenv()
.env("OMP_NUM_THREADS", "0")
.env("OMP_THREAD_LIMIT", "")
.succeeds();
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
assert_eq!(nproc, nproc_system);
let result = TestScenario::new(util_name!())
.ucmd_keepenv()
.env("OMP_NUM_THREADS", "")
.env("OMP_THREAD_LIMIT", "")
.succeeds();
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
assert_eq!(nproc, nproc_system);
let result = TestScenario::new(util_name!())
.ucmd_keepenv()
.env("OMP_NUM_THREADS", "2,2,1")
.env("OMP_THREAD_LIMIT", "")
.succeeds();
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
assert_eq!(2, nproc);
let result = TestScenario::new(util_name!())
.ucmd_keepenv()
.env("OMP_NUM_THREADS", "2,ignored")
.env("OMP_THREAD_LIMIT", "")
.succeeds();
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
assert_eq!(2, nproc);
let result = TestScenario::new(util_name!())
.ucmd_keepenv()
.env("OMP_NUM_THREADS", "2,2,1")
.env("OMP_THREAD_LIMIT", "0")
.succeeds();
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
assert_eq!(2, nproc);
let result = TestScenario::new(util_name!())
.ucmd_keepenv()
.env("OMP_NUM_THREADS", "2,2,1")
.env("OMP_THREAD_LIMIT", "1bad")
.succeeds();
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
assert_eq!(2, nproc);
let result = TestScenario::new(util_name!())
.ucmd_keepenv()
.env("OMP_NUM_THREADS", "29,2,1")
.env("OMP_THREAD_LIMIT", "1bad")
.succeeds();
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
assert_eq!(29, nproc);
}

View file

@ -44,7 +44,14 @@ fn test_long_format() {
#[cfg(unix)]
#[test]
fn test_long_format_multiple_users() {
let args = ["-l", "root", "root", "root"];
// multiple instances of one account we know exists,
// the account of the test runner,
// and an account that (probably) doesn't exist
let runner = match std::env::var("USER") {
Ok(user) => user,
Err(_) => "".to_string(),
};
let args = ["-l", "root", "root", "root", &runner, "no_such_user"];
let ts = TestScenario::new(util_name!());
let expect = unwrap_or_return!(expected_result(&ts, &args));

View file

@ -26,5 +26,5 @@ fn test_get_var() {
.succeeds();
assert!(!result.stdout_str().is_empty());
assert!(result.stdout_str().trim() == "VALUE");
assert_eq!(result.stdout_str().trim(), "VALUE");
}

View file

@ -289,7 +289,7 @@ fn sub_num_dec_trunc() {
new_ucmd!()
.args(&["pi is ~ %g", "3.1415926535"])
.succeeds()
.stdout_only("pi is ~ 3.141593");
.stdout_only("pi is ~ 3.14159");
}
#[cfg_attr(not(feature = "test_unimplemented"), ignore)]
@ -469,3 +469,56 @@ fn sub_float_leading_zeroes() {
.succeeds()
.stdout_only("001.000000");
}
#[test]
fn sub_general_float() {
new_ucmd!()
.args(&["%g", "1.1"])
.succeeds()
.stdout_only("1.1");
}
#[test]
fn sub_general_truncate_to_integer() {
new_ucmd!().args(&["%g", "1.0"]).succeeds().stdout_only("1");
}
#[test]
fn sub_general_scientific_notation() {
new_ucmd!()
.args(&["%g", "1000010"])
.succeeds()
.stdout_only("1.00001e+06");
}
#[test]
fn sub_general_round_scientific_notation() {
new_ucmd!()
.args(&["%g", "123456789"])
.succeeds()
.stdout_only("1.23457e+08");
}
#[test]
fn sub_general_round_float() {
new_ucmd!()
.args(&["%g", "12345.6789"])
.succeeds()
.stdout_only("12345.7");
}
#[test]
fn sub_general_round_float_to_integer() {
new_ucmd!()
.args(&["%g", "123456.7"])
.succeeds()
.stdout_only("123457");
}
#[test]
fn sub_general_round_float_leading_zeroes() {
new_ucmd!()
.args(&["%g", "1.000009"])
.succeeds()
.stdout_only("1.00001");
}

View file

@ -1,7 +1,16 @@
// spell-checker:ignore dont
use crate::common::util::*;
use std::time::{Duration, Instant};
#[test]
fn test_invalid_time_interval() {
new_ucmd!()
.arg("xyz")
.fails()
.usage_error("invalid time interval 'xyz'");
}
#[test]
fn test_sleep_no_suffix() {
let millis_100 = Duration::from_millis(100);
@ -115,3 +124,36 @@ fn test_sleep_sum_duration_many() {
fn test_sleep_wrong_time() {
new_ucmd!().args(&["0.1s", "abc"]).fails();
}
// TODO These tests would obviously block for a very long time. We
// only want to verify that there is no error here, so we could just
// figure out a way to terminate the child process after a short
// period of time.
// #[test]
#[allow(dead_code)]
fn test_dont_overflow() {
new_ucmd!()
.arg("9223372036854775808d")
.succeeds()
.no_stderr()
.no_stdout();
}
// #[test]
#[allow(dead_code)]
fn test_sum_overflow() {
new_ucmd!()
.args(&["100000000000000d", "100000000000000d", "100000000000000d"])
.succeeds()
.no_stderr()
.no_stdout();
}
#[test]
fn test_negative_interval() {
new_ucmd!()
.args(&["--", "-1"])
.fails()
.usage_error("invalid time interval '-1'");
}

View file

@ -571,6 +571,19 @@ fn test_elide_empty_files() {
assert!(!at.plus("xad").exists());
}
#[test]
#[cfg(unix)]
fn test_elide_dev_null() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["-e", "-n", "3", "/dev/null"])
.succeeds()
.no_stdout()
.no_stderr();
assert!(!at.plus("xaa").exists());
assert!(!at.plus("xab").exists());
assert!(!at.plus("xac").exists());
}
#[test]
fn test_lines() {
let (at, mut ucmd) = at_and_ucmd!();
@ -605,3 +618,40 @@ fn test_line_bytes() {
assert_eq!(at.read("xac"), "cccc\ndd\n");
assert_eq!(at.read("xad"), "ee\n");
}
#[test]
fn test_line_bytes_no_final_newline() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["-C", "2"])
.pipe_in("1\n2222\n3\n4")
.succeeds()
.no_stdout()
.no_stderr();
assert_eq!(at.read("xaa"), "1\n");
assert_eq!(at.read("xab"), "22");
assert_eq!(at.read("xac"), "22");
assert_eq!(at.read("xad"), "\n");
assert_eq!(at.read("xae"), "3\n");
assert_eq!(at.read("xaf"), "4");
}
#[test]
fn test_line_bytes_no_empty_file() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["-C", "1"])
.pipe_in("1\n2222\n3\n4")
.succeeds()
.no_stdout()
.no_stderr();
assert_eq!(at.read("xaa"), "1");
assert_eq!(at.read("xab"), "\n");
assert_eq!(at.read("xac"), "2");
assert_eq!(at.read("xad"), "2");
assert_eq!(at.read("xae"), "2");
assert_eq!(at.read("xaf"), "2");
assert_eq!(at.read("xag"), "\n");
assert_eq!(at.read("xah"), "3");
assert_eq!(at.read("xai"), "\n");
assert_eq!(at.read("xaj"), "4");
assert!(!at.plus("xak").exists());
}

View file

@ -1,3 +1,4 @@
// spell-checker:ignore dont
use crate::common::util::*;
// FIXME: this depends on the system having true and false in PATH
@ -10,6 +11,14 @@ fn test_subcommand_return_code() {
new_ucmd!().arg("1").arg("false").run().status_code(1);
}
#[test]
fn test_invalid_time_interval() {
new_ucmd!()
.args(&["xyz", "sleep", "0"])
.fails()
.usage_error("invalid time interval 'xyz'");
}
#[test]
fn test_command_with_args() {
new_ucmd!()
@ -64,3 +73,35 @@ fn test_preserve_status() {
.no_stderr()
.no_stdout();
}
#[test]
fn test_dont_overflow() {
new_ucmd!()
.args(&["9223372036854775808d", "sleep", "0"])
.succeeds()
.code_is(0)
.no_stderr()
.no_stdout();
new_ucmd!()
.args(&["-k", "9223372036854775808d", "10", "sleep", "0"])
.succeeds()
.code_is(0)
.no_stderr()
.no_stdout();
}
#[test]
fn test_negative_interval() {
new_ucmd!()
.args(&["--", "-1", "sleep", "0"])
.fails()
.usage_error("invalid time interval '-1'");
}
#[test]
fn test_invalid_signal() {
new_ucmd!()
.args(&["-s", "invalid", "1", "sleep", "0"])
.fails()
.usage_error("'invalid': invalid signal");
}

View file

@ -427,7 +427,7 @@ fn test_touch_mtime_dst_succeeds() {
let target_time = str_to_filetime("%Y%m%d%H%M", "202103140300");
let (_, mtime) = get_file_times(&at, file);
assert!(target_time == mtime);
assert_eq!(target_time, mtime);
}
// is_dst_switch_hour returns true if timespec ts is just before the switch

View file

@ -7,6 +7,7 @@ fn test_users_no_arg() {
#[test]
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
#[ignore = "issue #3219"]
fn test_users_check_name() {
#[cfg(target_os = "linux")]
let util_name = util_name!();

View file

@ -9,6 +9,7 @@ use crate::common::util::*;
#[cfg(unix)]
#[test]
#[ignore = "issue #3219"]
fn test_count() {
let ts = TestScenario::new(util_name!());
for opt in &["-q", "--count", "--c"] {
@ -29,6 +30,7 @@ fn test_boot() {
#[cfg(unix)]
#[test]
#[ignore = "issue #3219"]
fn test_heading() {
let ts = TestScenario::new(util_name!());
for opt in &["-H", "--heading", "--head"] {
@ -47,6 +49,7 @@ fn test_heading() {
#[cfg(unix)]
#[test]
#[ignore = "issue #3219"]
fn test_short() {
let ts = TestScenario::new(util_name!());
for opt in &["-s", "--short", "--s"] {
@ -108,6 +111,7 @@ fn test_time() {
#[cfg(unix)]
#[test]
#[ignore = "issue #3219"]
fn test_mesg() {
// -T, -w, --mesg
// add user's message status as +, - or ?
@ -150,6 +154,7 @@ fn test_too_many_args() {
#[cfg(unix)]
#[test]
#[ignore = "issue #3219"]
fn test_users() {
let ts = TestScenario::new(util_name!());
for opt in &["-u", "--users", "--us"] {
@ -175,6 +180,7 @@ fn test_users() {
#[cfg(unix)]
#[test]
#[ignore = "issue #3219"]
fn test_lookup() {
let opt = "--lookup";
let ts = TestScenario::new(util_name!());
@ -194,6 +200,7 @@ fn test_dead() {
#[cfg(unix)]
#[test]
#[ignore = "issue #3219"]
fn test_all_separately() {
if cfg!(target_os = "macos") {
// TODO: fix `-u`, see: test_users
@ -211,6 +218,7 @@ fn test_all_separately() {
#[cfg(unix)]
#[test]
#[ignore = "issue #3219"]
fn test_all() {
if cfg!(target_os = "macos") {
// TODO: fix `-u`, see: test_users

Binary file not shown.

Binary file not shown.