| 1 |
// This file is part of the uutils coreutils package. |
| 2 |
// |
| 3 |
// For the full copyright and license information, please view the LICENSE |
| 4 |
// file that was distributed with this source code. |
| 5 |
|
| 6 |
use uutests::new_ucmd; |
| 7 |
#[cfg(any(target_vendor = "apple", target_os = "linux"))] |
| 8 |
use uutests::{util::TestScenario, util_name}; |
| 9 |
|
| 10 |
#[ignore = "does not work as same as users > /dev/full"] |
| 11 |
#[test] |
| 12 |
#[cfg(target_os = "linux")] |
| 13 |
fn test_full_panic() { |
| 14 |
let full = std::fs::OpenOptions::new() |
| 15 |
.write(true) |
| 16 |
.open("/dev/full") |
| 17 |
.unwrap(); |
| 18 |
|
| 19 |
new_ucmd!() |
| 20 |
.set_stdout(full) |
| 21 |
.fails() |
| 22 |
.stderr_contains("No space"); |
| 23 |
} |
| 24 |
|
| 25 |
#[test] |
| 26 |
fn test_invalid_arg() { |
| 27 |
new_ucmd!().arg("--definitely-invalid").fails_with_code(1); |
| 28 |
} |
| 29 |
|
| 30 |
#[test] |
| 31 |
fn test_users_no_arg() { |
| 32 |
new_ucmd!().succeeds(); |
| 33 |
} |
| 34 |
|
| 35 |
#[test] |
| 36 |
#[cfg(any(target_vendor = "apple", target_os = "linux"))] |
| 37 |
#[ignore = "issue #3219"] |
| 38 |
fn test_users_check_name() { |
| 39 |
#[cfg(target_os = "linux")] |
| 40 |
let util_name = util_name!(); |
| 41 |
#[cfg(target_vendor = "apple")] |
| 42 |
let util_name = &format!("g{}", util_name!()); |
| 43 |
|
| 44 |
let expected = TestScenario::new(util_name) |
| 45 |
.cmd(util_name) |
| 46 |
.env("LC_ALL", "C") |
| 47 |
.succeeds() |
| 48 |
.stdout_move_str(); |
| 49 |
|
| 50 |
new_ucmd!().succeeds().stdout_is(&expected); |
| 51 |
} |
| 52 |
|
| 53 |
#[test] |
| 54 |
#[cfg(target_os = "openbsd")] |
| 55 |
fn test_users_check_name_openbsd() { |
| 56 |
new_ucmd!() |
| 57 |
.args(&["openbsd_utmp"]) |
| 58 |
.succeeds() |
| 59 |
.stdout_contains("test"); |
| 60 |
} |