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.
|
2020-05-07 23:01:47 +00:00
|
|
|
|
2021-06-23 10:27:01 +00:00
|
|
|
// spell-checker:ignore (ToDO) coreutil
|
2021-06-13 13:39:31 +00:00
|
|
|
|
2021-07-07 14:19:58 +00:00
|
|
|
use crate::common::util::*;
|
|
|
|
|
2021-06-23 10:27:01 +00:00
|
|
|
const VERSION_MIN_MULTIPLE_USERS: &str = "8.31"; // this feature was introduced in GNU's coreutils 8.31
|
2020-11-21 08:52:50 +00:00
|
|
|
|
2020-05-07 23:01:47 +00:00
|
|
|
#[test]
|
2021-06-11 10:00:26 +00:00
|
|
|
#[cfg(unix)]
|
2021-06-13 09:11:04 +00:00
|
|
|
fn test_id_no_specified_user() {
|
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-13 13:39:31 +00:00
|
|
|
let mut _exp_stdout = exp_result.stdout_str().to_string();
|
2021-06-11 10:00:26 +00:00
|
|
|
|
2021-06-13 13:39:31 +00:00
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
{
|
2021-06-16 18:45:46 +00:00
|
|
|
// NOTE: (SELinux NotImplemented) strip 'context' part from exp_stdout:
|
2021-07-07 20:46:16 +00:00
|
|
|
// example:
|
|
|
|
// uid=1001(runner) gid=121(docker) groups=121(docker),4(adm),101(systemd-journal) \
|
|
|
|
// context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
|
2021-06-16 18:45:46 +00:00
|
|
|
if let Some(context_offset) = exp_result.stdout_str().find(" context=") {
|
|
|
|
_exp_stdout.replace_range(context_offset.._exp_stdout.len() - 1, "");
|
|
|
|
}
|
2021-06-13 13:39:31 +00:00
|
|
|
}
|
2020-05-07 23:01:47 +00:00
|
|
|
|
2021-06-11 10:00:26 +00:00
|
|
|
result
|
2021-06-13 13:39:31 +00:00
|
|
|
.stdout_is(_exp_stdout)
|
|
|
|
.stderr_is(exp_result.stderr_str())
|
|
|
|
.code_is(exp_result.code());
|
2021-06-11 10:00:26 +00:00
|
|
|
}
|
2021-04-05 20:03:43 +00:00
|
|
|
|
2021-06-11 10:00:26 +00:00
|
|
|
#[test]
|
|
|
|
#[cfg(unix)]
|
|
|
|
fn test_id_single_user() {
|
2021-06-13 09:11:04 +00:00
|
|
|
let test_users = [&whoami()[..]];
|
|
|
|
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
|
|
|
let mut exp_result = unwrap_or_return!(expected_result(&ts, &test_users));
|
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&test_users)
|
|
|
|
.run()
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
2021-06-13 13:39:31 +00:00
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
2021-06-13 09:11:04 +00:00
|
|
|
.code_is(exp_result.code());
|
|
|
|
|
|
|
|
// u/g/G z/n
|
|
|
|
for &opt in &["--user", "--group", "--groups"] {
|
|
|
|
let mut args = vec![opt];
|
|
|
|
args.extend_from_slice(&test_users);
|
2021-07-07 20:46:16 +00:00
|
|
|
exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&args)
|
|
|
|
.run()
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
2021-06-13 13:39:31 +00:00
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
2021-06-13 09:11:04 +00:00
|
|
|
.code_is(exp_result.code());
|
|
|
|
args.push("--zero");
|
2021-07-07 20:46:16 +00:00
|
|
|
exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&args)
|
|
|
|
.run()
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
2021-06-13 13:39:31 +00:00
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
2021-06-13 09:11:04 +00:00
|
|
|
.code_is(exp_result.code());
|
|
|
|
args.push("--name");
|
2021-07-07 20:46:16 +00:00
|
|
|
exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&args)
|
|
|
|
.run()
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
2021-06-13 13:39:31 +00:00
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
2021-06-13 09:11:04 +00:00
|
|
|
.code_is(exp_result.code());
|
|
|
|
args.pop();
|
2021-07-07 20:46:16 +00:00
|
|
|
exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&args)
|
|
|
|
.run()
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
2021-06-13 13:39:31 +00:00
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
2021-06-13 09:11:04 +00:00
|
|
|
.code_is(exp_result.code());
|
|
|
|
}
|
2020-05-07 23:01:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-06-11 10:00:26 +00:00
|
|
|
#[cfg(unix)]
|
2021-06-13 09:11:04 +00:00
|
|
|
fn test_id_single_user_non_existing() {
|
2021-06-11 10:00:26 +00:00
|
|
|
let args = &["hopefully_non_existing_username"];
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
|
|
|
let result = ts.ucmd().args(args).run();
|
|
|
|
let exp_result = unwrap_or_return!(expected_result(&ts, args));
|
2021-06-13 13:39:31 +00:00
|
|
|
|
2021-06-16 18:45:46 +00:00
|
|
|
// It is unknown why on macOS (and possibly others?) `id` adds "Invalid argument".
|
2021-06-13 13:39:31 +00:00
|
|
|
// coreutils 8.32: $ LC_ALL=C id foobar
|
|
|
|
// macOS: stderr: "id: 'foobar': no such user: Invalid argument"
|
|
|
|
// linux: stderr: "id: 'foobar': no such user"
|
2021-06-11 10:00:26 +00:00
|
|
|
result
|
2021-06-13 13:39:31 +00:00
|
|
|
.stdout_is(exp_result.stdout_str())
|
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
|
|
|
.code_is(exp_result.code());
|
2021-06-11 10:00:26 +00:00
|
|
|
}
|
2021-04-17 20:29:07 +00:00
|
|
|
|
2021-06-11 10:00:26 +00:00
|
|
|
#[test]
|
|
|
|
#[cfg(unix)]
|
|
|
|
fn test_id_name() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2021-06-11 10:00:26 +00:00
|
|
|
for &opt in &["--user", "--group", "--groups"] {
|
|
|
|
let args = [opt, "--name"];
|
2021-07-07 20:46:16 +00:00
|
|
|
let result = ts.ucmd().args(&args).run();
|
|
|
|
let exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
2021-06-11 10:00:26 +00:00
|
|
|
result
|
2021-06-13 13:39:31 +00:00
|
|
|
.stdout_is(exp_result.stdout_str())
|
|
|
|
.stderr_is(exp_result.stderr_str())
|
|
|
|
.code_is(exp_result.code());
|
2021-06-11 10:00:26 +00:00
|
|
|
|
|
|
|
if opt == "--user" {
|
|
|
|
assert_eq!(result.stdout_str().trim_end(), whoami());
|
|
|
|
}
|
2021-04-17 20:29:07 +00:00
|
|
|
}
|
2020-05-07 23:01:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-06-11 10:00:26 +00:00
|
|
|
#[cfg(unix)]
|
|
|
|
fn test_id_real() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2021-06-11 10:00:26 +00:00
|
|
|
for &opt in &["--user", "--group", "--groups"] {
|
|
|
|
let args = [opt, "--real"];
|
2021-07-07 20:46:16 +00:00
|
|
|
let result = ts.ucmd().args(&args).run();
|
|
|
|
let exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
2021-06-11 10:00:26 +00:00
|
|
|
result
|
2021-06-13 13:39:31 +00:00
|
|
|
.stdout_is(exp_result.stdout_str())
|
|
|
|
.stderr_is(exp_result.stderr_str())
|
|
|
|
.code_is(exp_result.code());
|
2020-05-07 23:01:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-21 08:52:50 +00:00
|
|
|
#[test]
|
2021-06-11 10:00:26 +00:00
|
|
|
#[cfg(all(unix, not(target_os = "linux")))]
|
2020-11-21 08:52:50 +00:00
|
|
|
fn test_id_pretty_print() {
|
2021-06-11 10:00:26 +00:00
|
|
|
// `-p` is BSD only and not supported on GNU's `id`
|
|
|
|
let username = whoami();
|
2020-11-21 08:52:50 +00:00
|
|
|
|
2021-06-11 10:00:26 +00:00
|
|
|
let result = new_ucmd!().arg("-p").run();
|
2021-04-17 20:29:07 +00:00
|
|
|
if result.stdout_str().trim().is_empty() {
|
|
|
|
// this fails only on: "MinRustV (ubuntu-latest, feat_os_unix)"
|
|
|
|
// `rustc 1.40.0 (73528e339 2019-12-16)`
|
|
|
|
// run: /home/runner/work/coreutils/coreutils/target/debug/coreutils id -p
|
|
|
|
// thread 'test_id::test_id_pretty_print' panicked at 'Command was expected to succeed.
|
|
|
|
// stdout =
|
|
|
|
// stderr = ', tests/common/util.rs:157:13
|
|
|
|
println!("test skipped:");
|
2021-06-11 10:00:26 +00:00
|
|
|
} else {
|
|
|
|
result.success().stdout_contains(username);
|
2020-11-21 08:52:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-06-11 10:00:26 +00:00
|
|
|
#[cfg(all(unix, not(target_os = "linux")))]
|
2020-11-21 08:52:50 +00:00
|
|
|
fn test_id_password_style() {
|
2021-06-11 10:00:26 +00:00
|
|
|
// `-P` is BSD only and not supported on GNU's `id`
|
|
|
|
let username = whoami();
|
|
|
|
let result = new_ucmd!().arg("-P").arg(&username).succeeds();
|
2021-04-05 20:03:43 +00:00
|
|
|
assert!(result.stdout_str().starts_with(&username));
|
2020-11-21 08:52:50 +00:00
|
|
|
}
|
2021-06-05 22:03:53 +00:00
|
|
|
|
2021-06-11 10:00:26 +00:00
|
|
|
#[test]
|
|
|
|
#[cfg(unix)]
|
|
|
|
fn test_id_multiple_users() {
|
2021-07-07 13:53:26 +00:00
|
|
|
unwrap_or_return!(check_coreutil_version(
|
|
|
|
util_name!(),
|
|
|
|
VERSION_MIN_MULTIPLE_USERS
|
|
|
|
));
|
2021-06-16 18:45:46 +00:00
|
|
|
|
2021-06-23 10:27:01 +00:00
|
|
|
// Same typical users that GNU test suite is using.
|
2021-06-11 10:00:26 +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 mut exp_result = unwrap_or_return!(expected_result(&ts, &test_users));
|
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&test_users)
|
|
|
|
.run()
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
2021-06-13 13:39:31 +00:00
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
2021-06-13 09:11:04 +00:00
|
|
|
.code_is(exp_result.code());
|
|
|
|
|
|
|
|
// u/g/G z/n
|
|
|
|
for &opt in &["--user", "--group", "--groups"] {
|
|
|
|
let mut args = vec![opt];
|
|
|
|
args.extend_from_slice(&test_users);
|
2021-07-07 20:46:16 +00:00
|
|
|
exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&args)
|
|
|
|
.run()
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
2021-06-13 13:39:31 +00:00
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
2021-06-13 09:11:04 +00:00
|
|
|
.code_is(exp_result.code());
|
|
|
|
args.push("--zero");
|
2021-07-07 20:46:16 +00:00
|
|
|
exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&args)
|
|
|
|
.run()
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
2021-06-13 13:39:31 +00:00
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
2021-06-13 09:11:04 +00:00
|
|
|
.code_is(exp_result.code());
|
|
|
|
args.push("--name");
|
2021-07-07 20:46:16 +00:00
|
|
|
exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&args)
|
|
|
|
.run()
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
2021-06-13 13:39:31 +00:00
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
2021-06-13 09:11:04 +00:00
|
|
|
.code_is(exp_result.code());
|
|
|
|
args.pop();
|
2021-07-07 20:46:16 +00:00
|
|
|
exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&args)
|
|
|
|
.run()
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
2021-06-13 13:39:31 +00:00
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
2021-06-13 09:11:04 +00:00
|
|
|
.code_is(exp_result.code());
|
|
|
|
}
|
2021-06-11 10:00:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[cfg(unix)]
|
2021-06-13 09:11:04 +00:00
|
|
|
fn test_id_multiple_users_non_existing() {
|
2021-07-07 13:53:26 +00:00
|
|
|
unwrap_or_return!(check_coreutil_version(
|
|
|
|
util_name!(),
|
|
|
|
VERSION_MIN_MULTIPLE_USERS
|
|
|
|
));
|
2021-06-16 18:45:46 +00:00
|
|
|
|
2021-06-11 10:00:26 +00:00
|
|
|
let test_users = [
|
|
|
|
"root",
|
|
|
|
"hopefully_non_existing_username1",
|
2021-06-13 09:11:04 +00:00
|
|
|
&whoami(),
|
2021-06-11 10:00:26 +00:00
|
|
|
"man",
|
2021-06-13 09:11:04 +00:00
|
|
|
"hopefully_non_existing_username2",
|
|
|
|
"hopefully_non_existing_username3",
|
2021-06-11 10:00:26 +00:00
|
|
|
"postfix",
|
|
|
|
"sshd",
|
2021-06-13 09:11:04 +00:00
|
|
|
"hopefully_non_existing_username4",
|
2021-06-11 10:00:26 +00:00
|
|
|
&whoami(),
|
|
|
|
];
|
|
|
|
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
|
|
|
let mut exp_result = unwrap_or_return!(expected_result(&ts, &test_users));
|
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&test_users)
|
|
|
|
.run()
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
2021-06-13 13:39:31 +00:00
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
2021-06-13 09:11:04 +00:00
|
|
|
.code_is(exp_result.code());
|
|
|
|
|
|
|
|
// u/g/G z/n
|
|
|
|
for &opt in &["--user", "--group", "--groups"] {
|
|
|
|
let mut args = vec![opt];
|
|
|
|
args.extend_from_slice(&test_users);
|
2021-07-07 20:46:16 +00:00
|
|
|
exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&args)
|
|
|
|
.run()
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
2021-06-13 13:39:31 +00:00
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
2021-06-13 09:11:04 +00:00
|
|
|
.code_is(exp_result.code());
|
|
|
|
args.push("--zero");
|
2021-07-07 20:46:16 +00:00
|
|
|
exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&args)
|
|
|
|
.run()
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
2021-06-13 13:39:31 +00:00
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
2021-06-13 09:11:04 +00:00
|
|
|
.code_is(exp_result.code());
|
|
|
|
args.push("--name");
|
2021-07-07 20:46:16 +00:00
|
|
|
exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&args)
|
|
|
|
.run()
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
2021-06-13 13:39:31 +00:00
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
2021-06-13 09:11:04 +00:00
|
|
|
.code_is(exp_result.code());
|
|
|
|
args.pop();
|
2021-07-07 20:46:16 +00:00
|
|
|
exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&args)
|
|
|
|
.run()
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
2021-06-13 13:39:31 +00:00
|
|
|
.stderr_is(exp_result.stderr_str().replace(": Invalid argument", ""))
|
2021-06-13 09:11:04 +00:00
|
|
|
.code_is(exp_result.code());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[cfg(unix)]
|
|
|
|
fn test_id_default_format() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2021-06-13 09:11:04 +00:00
|
|
|
for &opt1 in &["--name", "--real"] {
|
|
|
|
// id: cannot print only names or real IDs in default format
|
|
|
|
let args = [opt1];
|
2021-07-07 20:46:16 +00:00
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&args)
|
|
|
|
.fails()
|
2021-07-07 20:46:16 +00:00
|
|
|
.stderr_only(unwrap_or_return!(expected_result(&ts, &args)).stderr_str());
|
2021-06-13 09:11:04 +00:00
|
|
|
for &opt2 in &["--user", "--group", "--groups"] {
|
|
|
|
// u/g/G n/r
|
|
|
|
let args = [opt2, opt1];
|
2021-07-07 20:46:16 +00:00
|
|
|
let result = ts.ucmd().args(&args).run();
|
|
|
|
let exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
2021-06-13 09:11:04 +00:00
|
|
|
result
|
|
|
|
.stdout_is(exp_result.stdout_str())
|
|
|
|
.stderr_is(exp_result.stderr_str())
|
|
|
|
.code_is(exp_result.code());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for &opt2 in &["--user", "--group", "--groups"] {
|
|
|
|
// u/g/G
|
|
|
|
let args = [opt2];
|
2021-07-07 20:46:16 +00:00
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&args)
|
|
|
|
.succeeds()
|
2021-07-07 20:46:16 +00:00
|
|
|
.stdout_only(unwrap_or_return!(expected_result(&ts, &args)).stdout_str());
|
2021-06-13 09:11:04 +00:00
|
|
|
}
|
2021-06-11 10:00:26 +00:00
|
|
|
}
|
|
|
|
|
2021-06-05 22:03:53 +00:00
|
|
|
#[test]
|
2021-06-10 08:33:22 +00:00
|
|
|
#[cfg(unix)]
|
2021-06-05 22:03:53 +00:00
|
|
|
fn test_id_zero() {
|
2021-07-07 20:46:16 +00:00
|
|
|
let ts = TestScenario::new(util_name!());
|
2021-06-05 22:03:53 +00:00
|
|
|
for z_flag in &["-z", "--zero"] {
|
2021-06-13 09:11:04 +00:00
|
|
|
// id: option --zero not permitted in default format
|
2021-07-07 20:46:16 +00:00
|
|
|
ts.ucmd()
|
2021-06-13 09:11:04 +00:00
|
|
|
.args(&[z_flag])
|
|
|
|
.fails()
|
2021-07-07 20:46:16 +00:00
|
|
|
.stderr_only(unwrap_or_return!(expected_result(&ts, &[z_flag])).stderr_str());
|
2021-06-09 11:24:28 +00:00
|
|
|
for &opt1 in &["--name", "--real"] {
|
|
|
|
// id: cannot print only names or real IDs in default format
|
|
|
|
let args = [opt1, z_flag];
|
2021-07-07 20:46:16 +00:00
|
|
|
ts.ucmd()
|
2021-06-05 22:03:53 +00:00
|
|
|
.args(&args)
|
|
|
|
.fails()
|
2021-07-07 20:46:16 +00:00
|
|
|
.stderr_only(unwrap_or_return!(expected_result(&ts, &args)).stderr_str());
|
2021-06-09 11:24:28 +00:00
|
|
|
for &opt2 in &["--user", "--group", "--groups"] {
|
|
|
|
// u/g/G n/r z
|
|
|
|
let args = [opt2, z_flag, opt1];
|
2021-07-07 20:46:16 +00:00
|
|
|
let result = ts.ucmd().args(&args).run();
|
|
|
|
let exp_result = unwrap_or_return!(expected_result(&ts, &args));
|
2021-06-10 08:33:22 +00:00
|
|
|
result
|
2021-06-13 09:11:04 +00:00
|
|
|
.stdout_is(exp_result.stdout_str())
|
|
|
|
.stderr_is(exp_result.stderr_str())
|
|
|
|
.code_is(exp_result.code());
|
2021-06-09 11:24:28 +00:00
|
|
|
}
|
2021-06-05 22:03:53 +00:00
|
|
|
}
|
2021-06-09 11:24:28 +00:00
|
|
|
for &opt2 in &["--user", "--group", "--groups"] {
|
2021-06-13 09:11:04 +00:00
|
|
|
// u/g/G z
|
2021-06-09 11:24:28 +00:00
|
|
|
let args = [opt2, z_flag];
|
2021-07-07 20:46:16 +00:00
|
|
|
ts.ucmd()
|
2021-06-05 22:03:53 +00:00
|
|
|
.args(&args)
|
|
|
|
.succeeds()
|
2021-07-07 20:46:16 +00:00
|
|
|
.stdout_only(unwrap_or_return!(expected_result(&ts, &args)).stdout_str());
|
2021-06-05 22:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|