Skip to content

Commit

Permalink
tests: disable tests for tools unsupported on OpenBSD
Browse files Browse the repository at this point in the history
pinky, uptime and who are not supported on OpenBSD (no support of utmpx feature) => disable tests
for these tools on OpenBSD with conditional compilation

Signed-off-by: Laurent Cheylus <[email protected]>
  • Loading branch information
lcheylus committed Jan 19, 2024
1 parent 746a7b1 commit 4589f63
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/by-util/test_pinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fn test_capitalize() {
}

#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_long_format() {
let login = "root";
let pw: Passwd = Passwd::locate(login).unwrap();
Expand All @@ -44,6 +45,7 @@ fn test_long_format() {

#[cfg(unix)]
#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_long_format_multiple_users() {
// multiple instances of one account we know exists,
// the account of the test runner,
Expand Down Expand Up @@ -71,6 +73,7 @@ fn test_long_format_wo_user() {

#[cfg(unix)]
#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_short_format_i() {
// allow whitespace variation
// * minor whitespace differences occur between platform built-in outputs; specifically, the number of trailing TABs may be variant
Expand All @@ -85,6 +88,7 @@ fn test_short_format_i() {

#[cfg(unix)]
#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_short_format_q() {
// allow whitespace variation
// * minor whitespace differences occur between platform built-in outputs; specifically, the number of trailing TABs may be variant
Expand All @@ -99,6 +103,7 @@ fn test_short_format_q() {

#[cfg(unix)]
#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_no_flag() {
let ts = TestScenario::new(util_name!());
let actual = ts.ucmd().succeeds().stdout_move_str();
Expand Down
2 changes: 2 additions & 0 deletions tests/by-util/test_uptime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ fn test_invalid_arg() {
}

#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_uptime() {
TestScenario::new(util_name!())
.ucmd()
Expand All @@ -22,6 +23,7 @@ fn test_uptime() {
}

#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_uptime_since() {
let re = Regex::new(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}").unwrap();

Expand Down
8 changes: 8 additions & 0 deletions tests/by-util/test_who.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fn test_count() {

#[cfg(unix)]
#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_boot() {
let ts = TestScenario::new(util_name!());
for opt in ["-b", "--boot", "--b"] {
Expand Down Expand Up @@ -65,6 +66,7 @@ fn test_short() {

#[cfg(unix)]
#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_login() {
let ts = TestScenario::new(util_name!());
for opt in ["-l", "--login", "--log"] {
Expand All @@ -75,6 +77,7 @@ fn test_login() {

#[cfg(unix)]
#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_m() {
let ts = TestScenario::new(util_name!());
let expected_stdout = unwrap_or_return!(expected_result(&ts, &["-m"])).stdout_move_str();
Expand All @@ -83,6 +86,7 @@ fn test_m() {

#[cfg(unix)]
#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_process() {
let ts = TestScenario::new(util_name!());
for opt in ["-p", "--process", "--p"] {
Expand All @@ -93,6 +97,7 @@ fn test_process() {

#[cfg(unix)]
#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_runlevel() {
let ts = TestScenario::new(util_name!());
for opt in ["-r", "--runlevel", "--r"] {
Expand All @@ -106,6 +111,7 @@ fn test_runlevel() {

#[cfg(unix)]
#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_time() {
let ts = TestScenario::new(util_name!());
for opt in ["-t", "--time", "--t"] {
Expand Down Expand Up @@ -141,6 +147,7 @@ fn test_mesg() {

#[cfg(unix)]
#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_arg1_arg2() {
let args = ["am", "i"];
let ts = TestScenario::new(util_name!());
Expand Down Expand Up @@ -195,6 +202,7 @@ fn test_lookup() {

#[cfg(unix)]
#[test]
#[cfg(not(target_os = "openbsd"))]
fn test_dead() {
let ts = TestScenario::new(util_name!());
for opt in ["-d", "--dead", "--de"] {
Expand Down

0 comments on commit 4589f63

Please sign in to comment.