From c0a3662b630d48a48507d6b241126073ddcb4fe6 Mon Sep 17 00:00:00 2001 From: Laurent Cheylus Date: Sun, 30 Jun 2024 15:39:54 +0200 Subject: [PATCH] tests: enable tests for uptime on OpenBSD Signed-off-by: Laurent Cheylus --- tests/by-util/test_uptime.rs | 25 +++++++++++++++---------- tests/fixtures/uptime/openbsd_utmp | Bin 0 -> 9728 bytes 2 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 tests/fixtures/uptime/openbsd_utmp diff --git a/tests/by-util/test_uptime.rs b/tests/by-util/test_uptime.rs index 382d5f2ef..247f93317 100644 --- a/tests/by-util/test_uptime.rs +++ b/tests/by-util/test_uptime.rs @@ -7,16 +7,16 @@ use crate::common::util::TestScenario; -#[cfg(not(target_os = "macos"))] +#[cfg(not(any(target_os = "macos", target_os = "openbsd")))] use bincode::serialize; use regex::Regex; -#[cfg(not(target_os = "macos"))] +#[cfg(not(any(target_os = "macos", target_os = "openbsd")))] use serde::Serialize; -#[cfg(not(target_os = "macos"))] +#[cfg(not(any(target_os = "macos", target_os = "openbsd")))] use serde_big_array::BigArray; -#[cfg(not(target_os = "macos"))] +#[cfg(not(any(target_os = "macos", target_os = "openbsd")))] use std::fs::File; -#[cfg(not(target_os = "macos"))] +#[cfg(not(any(target_os = "macos", target_os = "openbsd")))] use std::{io::Write, path::PathBuf}; #[test] @@ -25,7 +25,6 @@ fn test_invalid_arg() { } #[test] -#[cfg(not(target_os = "openbsd"))] fn test_uptime() { TestScenario::new(util_name!()) .ucmd() @@ -82,7 +81,7 @@ fn test_uptime_with_fifo() { } #[test] -#[cfg(not(any(target_os = "openbsd", target_os = "freebsd")))] +#[cfg(not(target_os = "freebsd"))] fn test_uptime_with_non_existent_file() { // Disabled for freebsd, since it doesn't use the utmpxname() sys call to change the default utmpx // file that is accessed using getutxent() @@ -230,7 +229,6 @@ fn test_uptime_with_file_containing_valid_boot_time_utmpx_record() { } #[test] -#[cfg(not(target_os = "openbsd"))] fn test_uptime_with_extra_argument() { let ts = TestScenario::new(util_name!()); @@ -242,7 +240,6 @@ fn test_uptime_with_extra_argument() { } /// Checks whether uptime displays the correct stderr msg when its called with a directory #[test] -#[cfg(not(target_os = "openbsd"))] fn test_uptime_with_dir() { let ts = TestScenario::new(util_name!()); let at = &ts.fixtures; @@ -256,7 +253,15 @@ fn test_uptime_with_dir() { } #[test] -#[cfg(not(target_os = "openbsd"))] +#[cfg(target_os = "openbsd")] +fn test_uptime_check_users_openbsd() { + new_ucmd!() + .args(&["openbsd_utmp"]) + .run() + .stdout_contains("4 users"); +} + +#[test] fn test_uptime_since() { let re = Regex::new(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}").unwrap(); diff --git a/tests/fixtures/uptime/openbsd_utmp b/tests/fixtures/uptime/openbsd_utmp new file mode 100644 index 0000000000000000000000000000000000000000..958d7510c380ac9faed61f2898d65bdb83192be1 GIT binary patch literal 9728 zcmZP=1*0J_8UlkR1WHOOoedcn7)nx$O9qXj2BAZm-nyiLoCOLmBL)VBqWt{P@B#%0 z4lMS?1Rh?-IMj>^BSPR3vnx2f5F(?j(GVC7fzc2c4S~@R7!85Z5Eu=C(GVC7fzc2c z4S~@R7!85Z5Eu=C(GVC7fsq~pB_)*wpz-_C;?yF1VPR-#q-SVmp=V^IXJ}-APv!8G z%bD!~9$y887ij!`c>0ohz7pUwg@+et{GQPKkfD*eo`If$9w;qR&lN+*q~BV^pu2<{xIF;?tcxoT literal 0 HcmV?d00001