coreutils/tests/by-util/test_cksum.rs
Sylvestre Ledru 9ae4928b7b
Ignore a test (#2053)
* Disable chksum: test_arg_overrides_stdin
fails often with:

---- test_cksum::test_arg_overrides_stdin stdout ----
current_directory_resolved:
touch: /tmp/.tmpv9hydc/a
run: /target/x86_64-unknown-linux-gnu/debug/coreutils cksum a
thread 'test_cksum::test_arg_overrides_stdin' panicked at 'Broken pipe (os error 32)', tests/common/util.rs:742:37
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

* rustfmt the recent change
2021-04-09 10:14:41 +02:00

103 lines
2.4 KiB
Rust

use crate::common::util::*;
#[test]
fn test_single_file() {
new_ucmd!()
.arg("lorem_ipsum.txt")
.succeeds()
.stdout_is_fixture("single_file.expected");
}
#[test]
fn test_multiple_files() {
new_ucmd!()
.arg("lorem_ipsum.txt")
.arg("alice_in_wonderland.txt")
.succeeds()
.stdout_is_fixture("multiple_files.expected");
}
#[test]
fn test_stdin() {
new_ucmd!()
.pipe_in_fixture("lorem_ipsum.txt")
.succeeds()
.stdout_is_fixture("stdin.expected");
}
#[test]
fn test_empty() {
let (at, mut ucmd) = at_and_ucmd!();
at.touch("a");
ucmd.arg("a").succeeds().stdout.ends_with("0 a");
}
#[test]
#[ignore]
fn test_arg_overrides_stdin() {
let (at, mut ucmd) = at_and_ucmd!();
let input = "foobarfoobar";
at.touch("a");
let result = ucmd.arg("a").pipe_in(input.as_bytes()).run();
println!("{}, {}", result.stdout, result.stderr);
assert!(result.stdout.ends_with("0 a\n"))
}
#[test]
fn test_invalid_file() {
let (_, mut ucmd) = at_and_ucmd!();
let ls = TestScenario::new("ls");
let files = ls.cmd("ls").arg("-l").run();
println!("{:?}", files.stdout);
println!("{:?}", files.stderr);
let folder_name = "asdf".to_string();
let result = ucmd.arg(&folder_name).run();
println!("stdout: {:?}", result.stdout);
println!("stderr: {:?}", result.stderr);
assert!(result.stderr.contains("cksum: error: 'asdf'"));
assert!(!result.success);
}
// Make sure crc is correct for files larger than 32 bytes
// but <128 bytes (1 fold pclmul)
#[test]
fn test_crc_for_bigger_than_32_bytes() {
let (_, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg("chars.txt").run();
let mut stdout_splitted = result.stdout.split(" ");
let cksum: i64 = stdout_splitted.next().unwrap().parse().unwrap();
let bytes_cnt: i64 = stdout_splitted.next().unwrap().parse().unwrap();
assert!(result.success);
assert_eq!(cksum, 586047089);
assert_eq!(bytes_cnt, 16);
}
#[test]
fn test_stdin_larger_than_128_bytes() {
let (_, mut ucmd) = at_and_ucmd!();
let result = ucmd.arg("larger_than_2056_bytes.txt").run();
let mut stdout_splitted = result.stdout.split(" ");
let cksum: i64 = stdout_splitted.next().unwrap().parse().unwrap();
let bytes_cnt: i64 = stdout_splitted.next().unwrap().parse().unwrap();
assert!(result.success);
assert_eq!(cksum, 945881979);
assert_eq!(bytes_cnt, 2058);
}