Skip to content

Commit 363bda0

Browse files
authored
Merge pull request #9200 from lcheylus/openbsd-fix_tests
Fix tests on OpenBSD for unix feature
2 parents bb24195 + 6130a33 commit 363bda0

File tree

6 files changed

+35
-11
lines changed

6 files changed

+35
-11
lines changed

tests/by-util/test_cp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6949,7 +6949,7 @@ fn test_cp_current_directory_verbose() {
69496949
// Test copying current directory (.) with preserve attributes.
69506950
// This ensures attributes are preserved when copying the current directory.
69516951
#[test]
6952-
#[cfg(all(not(windows), not(target_os = "freebsd")))]
6952+
#[cfg(all(not(windows), not(target_os = "freebsd"), not(target_os = "openbsd")))]
69536953
fn test_cp_current_directory_preserve_attributes() {
69546954
use filetime::FileTime;
69556955
use std::os::unix::prelude::MetadataExt;

tests/by-util/test_df.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ fn test_type_option() {
326326
}
327327

328328
#[test]
329-
#[cfg(not(any(target_os = "freebsd", target_os = "windows")))] // FIXME: fix test for FreeBSD & Win
329+
#[cfg(not(any(target_os = "freebsd", target_os = "openbsd", target_os = "windows")))] // FIXME: fix test for FreeBSD, OpenBSD & Win
330330
#[cfg(not(feature = "feat_selinux"))]
331331
fn test_type_option_with_file() {
332332
let fs_type = new_ucmd!()

tests/by-util/test_du.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ fn du_basics(s: &str) {
6969
assert_eq!(s, answer);
7070
}
7171

72-
#[cfg(all(not(target_vendor = "apple"), not(target_os = "windows")))]
72+
#[cfg(all(
73+
not(target_vendor = "apple"),
74+
not(target_os = "windows"),
75+
not(target_os = "openbsd")
76+
))]
7377
fn du_basics(s: &str) {
7478
let answer = concat!(
7579
"8\t./subdir/deeper/deeper_dir\n",
@@ -119,7 +123,8 @@ fn du_basics_subdir(s: &str) {
119123
#[cfg(all(
120124
not(target_vendor = "apple"),
121125
not(target_os = "windows"),
122-
not(target_os = "freebsd")
126+
not(target_os = "freebsd"),
127+
not(target_os = "openbsd")
123128
))]
124129
fn du_basics_subdir(s: &str) {
125130
// MS-WSL linux has altered expected output
@@ -447,7 +452,8 @@ fn du_d_flag(s: &str) {
447452
#[cfg(all(
448453
not(target_vendor = "apple"),
449454
not(target_os = "windows"),
450-
not(target_os = "freebsd")
455+
not(target_os = "freebsd"),
456+
not(target_os = "openbsd")
451457
))]
452458
fn du_d_flag(s: &str) {
453459
// MS-WSL linux has altered expected output
@@ -520,7 +526,8 @@ fn du_dereference(s: &str) {
520526
#[cfg(all(
521527
not(target_vendor = "apple"),
522528
not(target_os = "windows"),
523-
not(target_os = "freebsd")
529+
not(target_os = "freebsd"),
530+
not(target_os = "openbsd")
524531
))]
525532
fn du_dereference(s: &str) {
526533
// MS-WSL linux has altered expected output

tests/by-util/test_expr.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,11 +582,17 @@ fn test_eager_evaluation() {
582582
#[test]
583583
fn test_long_input() {
584584
// Giving expr an arbitrary long expression should succeed rather than end with a segfault due to a stack overflow.
585-
#[cfg(not(windows))]
585+
#[cfg(all(not(windows), not(target_os = "openbsd")))]
586586
const MAX_NUMBER: usize = 40000;
587-
#[cfg(not(windows))]
587+
#[cfg(all(not(windows), not(target_os = "openbsd")))]
588588
const RESULT: &str = "800020000\n";
589589

590+
// On OpenBSD, crash with default MAX_NUMBER
591+
#[cfg(target_os = "openbsd")]
592+
const MAX_NUMBER: usize = 10000;
593+
#[cfg(target_os = "openbsd")]
594+
const RESULT: &str = "50005000\n";
595+
590596
// On windows there is 8192 characters input limit
591597
#[cfg(windows)]
592598
const MAX_NUMBER: usize = 1300; // 7993 characters (with spaces)

tests/by-util/test_nohup.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55
// spell-checker:ignore winsize Openpty openpty xpixel ypixel ptyprocess
6-
#[cfg(not(target_os = "openbsd"))]
76
use std::thread::sleep;
87
use uutests::at_and_ucmd;
98
use uutests::new_ucmd;
@@ -24,6 +23,7 @@ fn test_invalid_arg() {
2423
target_os = "linux",
2524
target_os = "android",
2625
target_os = "freebsd",
26+
target_os = "openbsd",
2727
target_vendor = "apple"
2828
))]
2929
fn test_nohup_multiple_args_and_flags() {
@@ -42,6 +42,7 @@ fn test_nohup_multiple_args_and_flags() {
4242
target_os = "linux",
4343
target_os = "android",
4444
target_os = "freebsd",
45+
target_os = "openbsd",
4546
target_vendor = "apple"
4647
))]
4748
fn test_nohup_with_pseudo_terminal_emulation_on_stdin_stdout_stderr_get_replaced() {
@@ -77,6 +78,7 @@ fn test_nohup_with_pseudo_terminal_emulation_on_stdin_stdout_stderr_get_replaced
7778
target_os = "linux",
7879
target_os = "android",
7980
target_os = "freebsd",
81+
target_os = "openbsd",
8082
target_vendor = "apple"
8183
))]
8284
fn test_nohup_creates_output_in_cwd() {
@@ -103,6 +105,7 @@ fn test_nohup_creates_output_in_cwd() {
103105
target_os = "linux",
104106
target_os = "android",
105107
target_os = "freebsd",
108+
target_os = "openbsd",
106109
target_vendor = "apple"
107110
))]
108111
fn test_nohup_appends_to_existing_file() {
@@ -128,7 +131,12 @@ fn test_nohup_appends_to_existing_file() {
128131
// Test that nohup falls back to $HOME/nohup.out when cwd is not writable
129132
// Skipped on macOS as the permissions test is unreliable
130133
#[test]
131-
#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))]
134+
#[cfg(any(
135+
target_os = "linux",
136+
target_os = "android",
137+
target_os = "freebsd",
138+
target_os = "openbsd"
139+
))]
132140
fn test_nohup_fallback_to_home() {
133141
use std::fs;
134142
use std::os::unix::fs::PermissionsExt;
@@ -204,6 +212,7 @@ fn test_nohup_command_not_found() {
204212
target_os = "linux",
205213
target_os = "android",
206214
target_os = "freebsd",
215+
target_os = "openbsd",
207216
target_vendor = "apple"
208217
))]
209218
fn test_nohup_stderr_to_stdout() {

tests/by-util/test_pinky.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55

66
#[cfg(not(target_os = "openbsd"))]
77
use uucore::entries::{Locate, Passwd};
8+
use uutests::new_ucmd;
89
#[cfg(not(target_os = "openbsd"))]
910
use uutests::util::{TestScenario, expected_result};
10-
use uutests::{new_ucmd, unwrap_or_return, util_name};
11+
#[cfg(not(target_os = "openbsd"))]
12+
use uutests::{unwrap_or_return, util_name};
1113

1214
#[test]
1315
fn test_invalid_arg() {

0 commit comments

Comments
 (0)