2023-08-21 08:49:27 +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.
|
2023-03-20 13:51:19 +00:00
|
|
|
use crate::common::util::TestScenario;
|
2018-04-19 13:20:23 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_hostname() {
|
|
|
|
let ls_default_res = new_ucmd!().succeeds();
|
|
|
|
let ls_short_res = new_ucmd!().arg("-s").succeeds();
|
|
|
|
let ls_domain_res = new_ucmd!().arg("-d").succeeds();
|
|
|
|
|
2021-04-05 20:03:43 +00:00
|
|
|
assert!(ls_default_res.stdout().len() >= ls_short_res.stdout().len());
|
|
|
|
assert!(ls_default_res.stdout().len() >= ls_domain_res.stdout().len());
|
2018-04-19 13:20:23 +00:00
|
|
|
}
|
2020-05-18 21:07:21 +00:00
|
|
|
|
2024-07-07 16:31:08 +00:00
|
|
|
// FixME: fails for "MacOS" => "failed to lookup address information"
|
|
|
|
#[cfg(not(target_os = "macos"))]
|
2020-05-18 21:07:21 +00:00
|
|
|
#[test]
|
|
|
|
fn test_hostname_ip() {
|
2021-04-17 23:28:06 +00:00
|
|
|
let result = new_ucmd!().arg("-i").succeeds();
|
2021-04-05 20:03:43 +00:00
|
|
|
assert!(!result.stdout_str().trim().is_empty());
|
2020-05-18 21:07:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_hostname_full() {
|
|
|
|
let ls_short_res = new_ucmd!().arg("-s").succeeds();
|
2021-04-05 20:03:43 +00:00
|
|
|
assert!(!ls_short_res.stdout_str().trim().is_empty());
|
|
|
|
|
2021-04-17 09:22:49 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.arg("-f")
|
|
|
|
.succeeds()
|
2021-04-05 20:03:43 +00:00
|
|
|
.stdout_contains(ls_short_res.stdout_str().trim());
|
2020-05-18 21:07:21 +00:00
|
|
|
}
|
2022-09-10 16:38:14 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_invalid_arg() {
|
|
|
|
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
|
|
|
}
|