mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Merge pull request #2477 from dhodder/uname_target_env
uname: don't report OS as "GNU/Linux" without GNU
This commit is contained in:
commit
7018ff8925
2 changed files with 67 additions and 1 deletions
|
@ -30,12 +30,16 @@ pub mod options {
|
||||||
pub static OS: &str = "operating-system";
|
pub static OS: &str = "operating-system";
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "")))]
|
||||||
const HOST_OS: &str = "GNU/Linux";
|
const HOST_OS: &str = "GNU/Linux";
|
||||||
|
#[cfg(all(target_os = "linux", not(any(target_env = "gnu", target_env = ""))))]
|
||||||
|
const HOST_OS: &str = "Linux";
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
const HOST_OS: &str = "Windows NT";
|
const HOST_OS: &str = "Windows NT";
|
||||||
#[cfg(target_os = "freebsd")]
|
#[cfg(target_os = "freebsd")]
|
||||||
const HOST_OS: &str = "FreeBSD";
|
const HOST_OS: &str = "FreeBSD";
|
||||||
|
#[cfg(target_os = "netbsd")]
|
||||||
|
const HOST_OS: &str = "NetBSD";
|
||||||
#[cfg(target_os = "openbsd")]
|
#[cfg(target_os = "openbsd")]
|
||||||
const HOST_OS: &str = "OpenBSD";
|
const HOST_OS: &str = "OpenBSD";
|
||||||
#[cfg(target_vendor = "apple")]
|
#[cfg(target_vendor = "apple")]
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
use crate::common::util::*;
|
use crate::common::util::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_uname() {
|
||||||
|
new_ucmd!().succeeds();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uname_compatible() {
|
fn test_uname_compatible() {
|
||||||
new_ucmd!().arg("-a").succeeds();
|
new_ucmd!().arg("-a").succeeds();
|
||||||
|
@ -45,3 +50,60 @@ fn test_uname_kernel() {
|
||||||
#[cfg(not(target_os = "linux"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
ucmd.arg("-o").succeeds();
|
ucmd.arg("-o").succeeds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_uname_operating_system() {
|
||||||
|
#[cfg(target_vendor = "apple")]
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("--operating-system")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_is("Darwin\n");
|
||||||
|
#[cfg(target_os = "freebsd")]
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("--operating-system")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_is("FreeBSD\n");
|
||||||
|
#[cfg(target_os = "fuchsia")]
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("--operating-system")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_is("Fuchsia\n");
|
||||||
|
#[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "")))]
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("--operating-system")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_is("GNU/Linux\n");
|
||||||
|
#[cfg(all(target_os = "linux", not(any(target_env = "gnu", target_env = ""))))]
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("--operating-system")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_is("Linux\n");
|
||||||
|
#[cfg(target_os = "netbsd")]
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("--operating-system")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_is("NetBSD\n");
|
||||||
|
#[cfg(target_os = "openbsd")]
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("--operating-system")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_is("OpenBSD\n");
|
||||||
|
#[cfg(target_os = "redox")]
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("--operating-system")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_is("Redox\n");
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("--operating-system")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_is("Windows NT\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_uname_help() {
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("--help")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_contains("system information");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue