uucore: do not use Linux specific fn at tests (#12128)

This commit is contained in:
oech3
2026-05-03 16:57:43 +09:00
committed by GitHub
parent 9de73ef9be
commit af09954d5a
2 changed files with 5 additions and 6 deletions
+3 -3
View File
@@ -50,7 +50,7 @@ mod tests {
}
#[test]
#[cfg(unix)]
#[cfg(target_os = "linux")]
fn test_copy_stream() {
let mut dest_file = new_temp_file();
@@ -72,8 +72,8 @@ mod tests {
}
#[test]
#[cfg(not(unix))]
// Test for non-unix platforms. We use regular files instead.
#[cfg(not(target_os = "linux"))]
// Test for non-linux platforms. We use regular files instead.
fn test_copy_stream() {
let temp_dir = tempdir().unwrap();
let src_path = temp_dir.path().join("src.txt");
+2 -3
View File
@@ -7,7 +7,7 @@
#[cfg(any(target_os = "linux", target_os = "android"))]
use rustix::pipe::{SpliceFlags, fcntl_setpipe_size};
#[cfg(any(target_os = "linux", target_os = "android", test))]
#[cfg(any(target_os = "linux", target_os = "android"))]
use std::fs::File;
#[cfg(any(target_os = "linux", target_os = "android"))]
use std::{io::Read, os::fd::AsFd, sync::OnceLock};
@@ -22,11 +22,10 @@ const KERNEL_DEFAULT_PIPE_SIZE: usize = 64 * 1024;
/// from the first.
/// used for resolving the limitation for splice: one of a input or output should be pipe
#[inline]
#[cfg(any(target_os = "linux", target_os = "android", test))]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub fn pipe() -> std::io::Result<(File, File)> {
let (read, write) = rustix::pipe::pipe()?;
// improve performance for splice
#[cfg(any(target_os = "linux", target_os = "android"))]
let _ = fcntl_setpipe_size(&read, MAX_ROOTLESS_PIPE_SIZE);
Ok((File::from(read), File::from(write)))