2023-08-21 10:49:27 +02:00
|
|
|
// This file is part of the uutils coreutils package.
|
|
|
|
|
//
|
|
|
|
|
// For the full copyright and license information, please view the LICENSE
|
|
|
|
|
// file that was distributed with this source code.
|
2025-03-28 09:51:51 +01:00
|
|
|
use uutests::new_ucmd;
|
2025-08-16 16:57:43 +02:00
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
|
|
|
|
use uutests::{util::TestScenario, util_name};
|
2020-05-03 22:38:46 +02:00
|
|
|
|
2026-01-11 00:43:26 +09:00
|
|
|
#[ignore = "does not work as same as users > /dev/full"]
|
|
|
|
|
#[test]
|
|
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
|
fn test_full_panic() {
|
|
|
|
|
let full = std::fs::OpenOptions::new()
|
|
|
|
|
.write(true)
|
|
|
|
|
.open("/dev/full")
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
new_ucmd!()
|
|
|
|
|
.set_stdout(full)
|
|
|
|
|
.fails()
|
|
|
|
|
.stderr_contains("No space");
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-10 18:38:14 +02:00
|
|
|
#[test]
|
|
|
|
|
fn test_invalid_arg() {
|
2025-03-01 15:29:11 +01:00
|
|
|
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
2022-09-10 18:38:14 +02:00
|
|
|
}
|
|
|
|
|
|
2020-05-03 22:38:46 +02:00
|
|
|
#[test]
|
2021-05-30 00:10:54 -05:00
|
|
|
fn test_users_no_arg() {
|
2021-04-18 02:28:06 +03:00
|
|
|
new_ucmd!().succeeds();
|
2020-05-03 22:38:46 +02:00
|
|
|
}
|
2021-05-29 01:51:00 +02:00
|
|
|
|
2020-05-03 22:38:46 +02:00
|
|
|
#[test]
|
2021-05-29 01:51:00 +02:00
|
|
|
#[cfg(any(target_vendor = "apple", target_os = "linux"))]
|
2022-03-06 17:46:52 -05:00
|
|
|
#[ignore = "issue #3219"]
|
2020-05-03 22:38:46 +02:00
|
|
|
fn test_users_check_name() {
|
2021-05-29 01:51:00 +02:00
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
|
let util_name = util_name!();
|
|
|
|
|
#[cfg(target_vendor = "apple")]
|
2023-11-16 16:02:38 +01:00
|
|
|
let util_name = &format!("g{}", util_name!());
|
2020-05-03 22:38:46 +02:00
|
|
|
|
2023-11-16 16:02:38 +01:00
|
|
|
let expected = TestScenario::new(util_name)
|
2023-01-25 03:40:39 +01:00
|
|
|
.cmd(util_name)
|
2021-06-22 00:22:30 +02:00
|
|
|
.env("LC_ALL", "C")
|
2021-05-29 01:51:00 +02:00
|
|
|
.succeeds()
|
|
|
|
|
.stdout_move_str();
|
2020-05-03 22:38:46 +02:00
|
|
|
|
2021-05-29 01:51:00 +02:00
|
|
|
new_ucmd!().succeeds().stdout_is(&expected);
|
2020-05-03 22:38:46 +02:00
|
|
|
}
|
2024-05-16 17:54:22 +03:30
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
#[cfg(target_os = "openbsd")]
|
|
|
|
|
fn test_users_check_name_openbsd() {
|
|
|
|
|
new_ucmd!()
|
|
|
|
|
.args(&["openbsd_utmp"])
|
2025-03-09 16:53:56 +01:00
|
|
|
.succeeds()
|
2024-05-16 17:54:22 +03:30
|
|
|
.stdout_contains("test");
|
|
|
|
|
}
|