Skip to content

Commit 4065c46

Browse files
committed
Expose utsname on all platforms
1 parent 97caa0c commit 4065c46

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/sys/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ pub mod reboot;
3939

4040
pub mod termios;
4141

42-
#[cfg(any(target_os = "linux", target_os = "android"))]
4342
pub mod utsname;
4443

4544
pub mod wait;

src/sys/utsname.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,21 @@ fn to_str<'a>(s: *const *const c_char) -> &'a str {
5050

5151
#[cfg(test)]
5252
mod test {
53-
use super::uname;
53+
#[cfg(target_os = "linux")]
54+
#[test]
55+
pub fn test_uname_linux() {
56+
assert_eq!(super::uname().sysname(), "Linux");
57+
}
58+
59+
#[cfg(any(target_os = "macos", target_os = "ios"))]
60+
#[test]
61+
pub fn test_uname_darwin() {
62+
assert_eq!(super::uname().sysname(), "Darwin");
63+
}
5464

65+
#[cfg(target_os = "freebsd")]
5566
#[test]
56-
pub fn test_uname() {
57-
assert_eq!(uname().sysname(), "Linux");
67+
pub fn test_uname_freebsd() {
68+
assert_eq!(super::uname().sysname(), "FreeBSD");
5869
}
5970
}

0 commit comments

Comments
 (0)