2021-07-07 14:19:58 +00: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.
|
|
|
|
|
2021-07-07 23:32:39 +00:00
|
|
|
//spell-checker: ignore coreutil
|
|
|
|
|
2020-06-02 20:14:35 +00:00
|
|
|
use crate::common::util::*;
|
|
|
|
|
2021-06-21 18:55:57 +00:00
|
|
|
const VERSION_MIN_MULTIPLE_USERS: &str = "8.31"; // this feature was introduced in GNU's coreutils 8.31
|
|
|
|
|
2020-06-02 20:14:35 +00:00
|
|
|
#[test]
|
2021-06-08 20:53:48 +00:00
|
|
|
#[cfg(unix)]
|
2020-06-02 20:14:35 +00:00
|
|
|
fn test_groups() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
|
|
|
let result = ts.ucmd().run();
|
|
|
|
let exp_result = unwrap_or_return!(expected_result(&ts, &[]));
|
2021-06-21 18:55:57 +00:00
|
|
|
|
|
|
|
result
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
|
|
|
.stderr_is(exp_result.stderr_str())
|
|
|
|
.code_is(exp_result.code());
|
2020-06-02 20:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-06-08 20:53:48 +00:00
|
|
|
#[cfg(unix)]
|
2021-06-07 17:52:49 +00:00
|
|
|
fn test_groups_username() {
|
2021-06-21 18:55:57 +00:00
|
|
|
let test_users = [&whoami()[..]];
|
2021-06-07 17:52:49 +00:00
|
|
|
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
|
|
|
let result = ts.ucmd().args(&test_users).run();
|
|
|
|
let exp_result = unwrap_or_return!(expected_result(&ts, &test_users));
|
2021-06-21 18:55:57 +00:00
|
|
|
|
|
|
|
result
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
|
|
|
.stderr_is(exp_result.stderr_str())
|
|
|
|
.code_is(exp_result.code());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[cfg(unix)]
|
|
|
|
fn test_groups_username_multiple() {
|
2021-07-07 13:52:56 +00:00
|
|
|
unwrap_or_return!(check_coreutil_version(
|
|
|
|
util_name!(),
|
|
|
|
VERSION_MIN_MULTIPLE_USERS
|
|
|
|
));
|
2021-06-21 18:55:57 +00:00
|
|
|
let test_users = ["root", "man", "postfix", "sshd", &whoami()];
|
|
|
|
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
|
|
|
let result = ts.ucmd().args(&test_users).run();
|
|
|
|
let exp_result = unwrap_or_return!(expected_result(&ts, &test_users));
|
2021-06-07 17:52:49 +00:00
|
|
|
|
2021-06-21 18:55:57 +00:00
|
|
|
result
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
|
|
|
.stderr_is(exp_result.stderr_str())
|
|
|
|
.code_is(exp_result.code());
|
|
|
|
}
|