1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

get android builds to compile and pass tests

This commit is contained in:
Justin Tracey 2022-02-09 13:08:28 -05:00 committed by Sylvestre Ledru
parent 5e7d58650d
commit 2a0d58d060
47 changed files with 244 additions and 165 deletions

View file

@ -14,15 +14,15 @@ use std::os::unix::fs::PermissionsExt;
#[cfg(windows)]
use std::os::windows::fs::symlink_file;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
use filetime::FileTime;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
use rlimit::Resource;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
use std::fs as std_fs;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
use std::thread::sleep;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
use std::time::Duration;
static TEST_EXISTING_FILE: &str = "existing_file.txt";
@ -38,11 +38,11 @@ static TEST_COPY_FROM_FOLDER: &str = "hello_dir_with_file/";
static TEST_COPY_FROM_FOLDER_FILE: &str = "hello_dir_with_file/hello_world.txt";
static TEST_COPY_TO_FOLDER_NEW: &str = "hello_dir_new";
static TEST_COPY_TO_FOLDER_NEW_FILE: &str = "hello_dir_new/hello_world.txt";
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))]
static TEST_MOUNT_COPY_FROM_FOLDER: &str = "dir_with_mount";
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))]
static TEST_MOUNT_MOUNTPOINT: &str = "mount";
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))]
static TEST_MOUNT_OTHER_FILESYSTEM_FILE: &str = "mount/DO_NOT_copy_me.txt";
#[cfg(unix)]
static TEST_NONEXISTENT_FILE: &str = "nonexistent_file.txt";
@ -1062,7 +1062,7 @@ fn test_cp_archive() {
}
#[test]
#[cfg(unix)]
#[cfg(all(unix, not(target_os = "android")))]
fn test_cp_archive_recursive() {
let (at, mut ucmd) = at_and_ucmd!();
@ -1132,7 +1132,7 @@ fn test_cp_archive_recursive() {
}
#[test]
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn test_cp_preserve_timestamps() {
let (at, mut ucmd) = at_and_ucmd!();
let ts = time::now().to_timespec();
@ -1165,7 +1165,7 @@ fn test_cp_preserve_timestamps() {
}
#[test]
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn test_cp_no_preserve_timestamps() {
let (at, mut ucmd) = at_and_ucmd!();
let ts = time::now().to_timespec();
@ -1206,7 +1206,7 @@ fn test_cp_no_preserve_timestamps() {
}
#[test]
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn test_cp_target_file_dev_null() {
let (at, mut ucmd) = at_and_ucmd!();
let file1 = "/dev/null";
@ -1219,7 +1219,7 @@ fn test_cp_target_file_dev_null() {
}
#[test]
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))]
fn test_cp_one_file_system() {
use crate::common::util::AtPath;
use walkdir::WalkDir;
@ -1283,7 +1283,7 @@ fn test_cp_one_file_system() {
}
#[test]
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[cfg(any(target_os = "linux", target_os = "android", target_os = "macos"))]
fn test_cp_reflink_always() {
let (at, mut ucmd) = at_and_ucmd!();
let result = ucmd
@ -1301,7 +1301,7 @@ fn test_cp_reflink_always() {
}
#[test]
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[cfg(any(target_os = "linux", target_os = "android", target_os = "macos"))]
fn test_cp_reflink_auto() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.arg("--reflink=auto")
@ -1314,7 +1314,7 @@ fn test_cp_reflink_auto() {
}
#[test]
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[cfg(any(target_os = "linux", target_os = "android", target_os = "macos"))]
fn test_cp_reflink_never() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.arg("--reflink=never")
@ -1327,7 +1327,7 @@ fn test_cp_reflink_never() {
}
#[test]
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[cfg(any(target_os = "linux", target_os = "android", target_os = "macos"))]
fn test_cp_reflink_bad() {
let (_, mut ucmd) = at_and_ucmd!();
let _result = ucmd
@ -1339,7 +1339,7 @@ fn test_cp_reflink_bad() {
}
#[test]
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn test_cp_reflink_insufficient_permission() {
let (at, mut ucmd) = at_and_ucmd!();
@ -1355,7 +1355,7 @@ fn test_cp_reflink_insufficient_permission() {
.stderr_only("cp: 'unreadable' -> 'existing_file.txt': Permission denied (os error 13)");
}
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
#[test]
fn test_closes_file_descriptors() {
new_ucmd!()
@ -1520,6 +1520,7 @@ fn test_cp_archive_on_nonexistent_file() {
}
#[test]
#[cfg(not(target_os = "android"))]
fn test_cp_link_backup() {
let (at, mut ucmd) = at_and_ucmd!();
at.touch("file2");
@ -1613,6 +1614,7 @@ fn test_cp_overriding_arguments() {
("--force", "--remove-destination"),
("--interactive", "--no-clobber"),
("--link", "--symbolic-link"),
#[cfg(not(target_os = "android"))]
("--symbolic-link", "--link"),
("--dereference", "--no-dereference"),
("--no-dereference", "--dereference"),