summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/sys/mod.rs2
-rw-r--r--test/sys/test_sysinfo.rs18
2 files changed, 20 insertions, 0 deletions
diff --git a/test/sys/mod.rs b/test/sys/mod.rs
index 1b3e67aa..bdc079d8 100644
--- a/test/sys/mod.rs
+++ b/test/sys/mod.rs
@@ -16,6 +16,8 @@ mod test_signalfd;
mod test_socket;
mod test_sockopt;
mod test_select;
+#[cfg(any(target_os = "android", target_os = "linux"))]
+mod test_sysinfo;
mod test_termios;
mod test_ioctl;
mod test_wait;
diff --git a/test/sys/test_sysinfo.rs b/test/sys/test_sysinfo.rs
new file mode 100644
index 00000000..73e6586f
--- /dev/null
+++ b/test/sys/test_sysinfo.rs
@@ -0,0 +1,18 @@
+use nix::sys::sysinfo::*;
+
+#[test]
+fn sysinfo_works() {
+ let info = sysinfo().unwrap();
+
+ let (l1, l5, l15) = info.load_average();
+ assert!(l1 >= 0.0);
+ assert!(l5 >= 0.0);
+ assert!(l15 >= 0.0);
+
+ info.uptime(); // just test Duration construction
+
+ assert!(info.swap_free() <= info.swap_total(),
+ "more swap available than installed (free: {}, total: {})",
+ info.swap_free(),
+ info.swap_total());
+}