Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,61 @@ jobs:
n_fails=$(echo "$output" | grep "^FAIL:\s" | wc --lines)
if [ $n_fails -gt 0 ] ; then echo "::warning ::${n_fails}+ test failures" ; fi

test_android:
name: Test Android builds
needs: [ min_version, deps ]
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
api-level: [28]
target: [default]
arch: [x86] # , arm64-v8a
env:
TERMUX: v0.118.0
steps:
- uses: actions/checkout@v2
- name: AVD cache
uses: actions/cache@v2
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/avd/*/snapshots/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-${{ matrix.arch }}+termux-${{ env.TERMUX }}
- name: Create and cache emulator image
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
ram-size: 2048M
disk-size: 5120M
force-avd-creation: true
emulator-options: -no-snapshot-load -noaudio -no-boot-anim -camera-back none
script: |
wget https://github.com/termux/termux-app/releases/download/${{ env.TERMUX }}/termux-app_${{ env.TERMUX }}+github-debug_${{ matrix.arch }}.apk
util/android-commands.sh snapshot termux-app_${{ env.TERMUX }}+github-debug_${{ matrix.arch }}.apk
adb -s emulator-5554 emu avd snapshot save ${{ matrix.api-level }}-${{ matrix.arch }}+termux-${{ env.TERMUX }}
echo "Emulator image created."
pkill -9 qemu-system-x86_64
- name: Build and Test on Android
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
ram-size: 2048M
disk-size: 5120M
force-avd-creation: false
emulator-options: -no-snapshot-save -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -snapshot ${{ matrix.api-level }}-${{ matrix.arch }}+termux-${{ env.TERMUX }}
script: |
util/android-commands.sh sync
util/android-commands.sh build
util/android-commands.sh tests

test_freebsd:
name: Tests/FreeBSD test suite
needs: [ min_version, deps ]
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coreutils (uutils)
# * see the repository LICENSE, README, and CONTRIBUTING files for more information

# spell-checker:ignore (libs) libselinux
# spell-checker:ignore (libs) libselinux gethostid

[package]
name = "coreutils"
Expand Down Expand Up @@ -120,6 +120,7 @@ feat_Tier1 = [
# "feat_os_macos" == set of utilities which can be built/run on the MacOS platform
feat_os_macos = [
"feat_os_unix", ## == a modern/usual *nix platform
"feat_require_hostid",
]
# "feat_os_unix" == set of utilities which can be built/run on modern/usual *nix platforms
feat_os_unix = [
Expand All @@ -140,12 +141,19 @@ feat_os_unix_gnueabihf = [
#
"feat_require_unix",
"feat_require_unix_utmpx",
"feat_require_hostid",
]
# "feat_os_unix_musl" == set of utilities which can be built/run on targets binding to the "musl" library (ref: <https://musl.libc.org/about.html>)
feat_os_unix_musl = [
"feat_Tier1",
#
"feat_require_unix",
"feat_require_hostid",
]
feat_os_unix_android = [
"feat_Tier1",
#
"feat_require_unix",
]
# "feat_selinux" == set of utilities providing support for SELinux Security Context if enabled with `--features feat_selinux`.
# NOTE:
Expand All @@ -172,7 +180,6 @@ feat_require_unix = [
"chown",
"chroot",
"groups",
"hostid",
"id",
"install",
"kill",
Expand All @@ -195,6 +202,10 @@ feat_require_unix_utmpx = [
"users",
"who",
]
# "feat_require_hostid" == set of utilities requiring gethostid in libc (only some unixes provide)
feat_require_hostid = [
"hostid",
]
# "feat_require_selinux" == set of utilities depending on SELinux.
feat_require_selinux = [
"chcon",
Expand Down Expand Up @@ -386,7 +397,7 @@ walkdir = "2.2"
atty = "0.2"
hex-literal = "0.3.1"

[target.'cfg(target_os = "linux")'.dev-dependencies]
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dev-dependencies]
rlimit = "0.8.3"

[target.'cfg(unix)'.dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/uu/chroot/src/chroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ fn set_groups(groups: &[libc::gid_t]) -> libc::c_int {
unsafe { setgroups(groups.len() as libc::c_int, groups.as_ptr()) }
}

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn set_groups(groups: &[libc::gid_t]) -> libc::c_int {
unsafe { setgroups(groups.len() as libc::size_t, groups.as_ptr()) }
}
Expand Down
2 changes: 1 addition & 1 deletion src/uu/cp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ selinux = { version="0.2", optional=true }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms", "mode"] }
walkdir = "2.2"

[target.'cfg(target_os = "linux")'.dependencies]
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
ioctl-sys = "0.8"

[target.'cfg(target_os = "windows")'.dependencies]
Expand Down
20 changes: 12 additions & 8 deletions src/uu/cp/src/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// spell-checker:ignore (ToDO) ficlone linkgs lstat nlink nlinks pathbuf reflink strs xattrs symlinked

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
#[macro_use]
extern crate ioctl_sys;
#[macro_use]
Expand Down Expand Up @@ -49,7 +49,7 @@ use std::mem;
use std::os::unix::ffi::OsStrExt;
#[cfg(unix)]
use std::os::unix::fs::{FileTypeExt, PermissionsExt};
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
use std::os::unix::io::AsRawFd;
#[cfg(windows)]
use std::os::windows::ffi::OsStrExt;
Expand All @@ -61,7 +61,7 @@ use uucore::error::{set_exit_code, ExitCode, UError, UResult};
use uucore::fs::{canonicalize, MissingHandling, ResolveMode};
use walkdir::WalkDir;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
ioctl!(write ficlone with 0x94, 9; std::os::raw::c_int);

quick_error! {
Expand Down Expand Up @@ -686,11 +686,15 @@ impl Options {
}
}
} else {
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[cfg(any(target_os = "linux", target_os = "android", target_os = "macos"))]
{
ReflinkMode::Auto
}
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
#[cfg(not(any(
target_os = "linux",
target_os = "android",
target_os = "macos"
)))]
{
ReflinkMode::Never
}
Expand Down Expand Up @@ -1467,14 +1471,14 @@ fn copy_helper(
} else if source_is_symlink {
copy_link(source, dest, symlinked_files)?;
} else if options.reflink_mode != ReflinkMode::Never {
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "macos")))]
return Err("--reflink is only supported on linux and macOS"
.to_string()
.into());

#[cfg(target_os = "macos")]
copy_on_write_macos(source, dest, options.reflink_mode, context)?;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
copy_on_write_linux(source, dest, options.reflink_mode, context)?;
} else {
fs::copy(source, dest).context(context)?;
Expand Down Expand Up @@ -1528,7 +1532,7 @@ fn copy_link(
}

/// Copies `source` to `dest` using copy-on-write if possible.
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn copy_on_write_linux(
source: &Path,
dest: &Path,
Expand Down
2 changes: 1 addition & 1 deletion src/uu/dd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ gcd = "2.0"
libc = "0.2"
uucore = { version=">=0.0.8", package="uucore", path="../../uucore" }

[target.'cfg(target_os = "linux")'.dependencies]
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
signal-hook = "0.3.9"

[[bin]]
Expand Down
10 changes: 5 additions & 5 deletions src/uu/dd/src/dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use std::cmp;
use std::env;
use std::fs::{File, OpenOptions};
use std::io::{self, Read, Seek, Write};
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
use std::os::unix::fs::OpenOptionsExt;
use std::path::Path;
use std::sync::mpsc;
Expand Down Expand Up @@ -88,7 +88,7 @@ impl Input<io::Stdin> {
}
}

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn make_linux_iflags(iflags: &IFlags) -> Option<libc::c_int> {
let mut flag = 0;

Expand Down Expand Up @@ -140,7 +140,7 @@ impl Input<File> {
let mut opts = OpenOptions::new();
opts.read(true);

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
if let Some(libc_flags) = make_linux_iflags(&iflags) {
opts.custom_flags(libc_flags);
}
Expand Down Expand Up @@ -455,7 +455,7 @@ where
}
}

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn make_linux_oflags(oflags: &OFlags) -> Option<libc::c_int> {
let mut flag = 0;

Expand Down Expand Up @@ -504,7 +504,7 @@ impl OutputTrait for Output<File> {
.create_new(cflags.excl)
.append(oflags.append);

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
if let Some(libc_flags) = make_linux_oflags(oflags) {
opts.custom_flags(libc_flags);
}
Expand Down
16 changes: 8 additions & 8 deletions src/uu/dd/src/parseargs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl std::str::FromStr for Flag {
"direct" =>
// Ok(Self::Direct),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::Direct)
} else {
Err(ParseError::Unimplemented(s.to_string()))
Expand All @@ -244,7 +244,7 @@ impl std::str::FromStr for Flag {
"directory" =>
// Ok(Self::Directory),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::Directory)
} else {
Err(ParseError::Unimplemented(s.to_string()))
Expand All @@ -253,7 +253,7 @@ impl std::str::FromStr for Flag {
"dsync" =>
// Ok(Self::Dsync),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::Dsync)
} else {
Err(ParseError::Unimplemented(s.to_string()))
Expand All @@ -262,7 +262,7 @@ impl std::str::FromStr for Flag {
"sync" =>
// Ok(Self::Sync),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::Sync)
} else {
Err(ParseError::Unimplemented(s.to_string()))
Expand All @@ -276,7 +276,7 @@ impl std::str::FromStr for Flag {
"nonblock" =>
// Ok(Self::NonBlock),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::NonBlock)
} else {
Err(ParseError::Unimplemented(s.to_string()))
Expand All @@ -285,7 +285,7 @@ impl std::str::FromStr for Flag {
"noatime" =>
// Ok(Self::NoATime),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::NoATime)
} else {
Err(ParseError::Unimplemented(s.to_string()))
Expand All @@ -294,7 +294,7 @@ impl std::str::FromStr for Flag {
"noctty" =>
// Ok(Self::NoCtty),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::NoCtty)
} else {
Err(ParseError::Unimplemented(s.to_string()))
Expand All @@ -303,7 +303,7 @@ impl std::str::FromStr for Flag {
"nofollow" =>
// Ok(Self::NoFollow),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::NoFollow)
} else {
Err(ParseError::Unimplemented(s.to_string()))
Expand Down
6 changes: 3 additions & 3 deletions src/uu/dd/src/parseargs/unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::*;

use crate::StatusLevel;

#[cfg(not(target_os = "linux"))]
#[cfg(not(any(target_os = "linux", target_os = "android")))]
#[test]
fn unimplemented_flags_should_error_non_linux() {
let mut succeeded = Vec::new();
Expand Down Expand Up @@ -617,7 +617,7 @@ fn parse_oflag_tokens() {
}
}

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
#[test]
fn parse_iflag_tokens_linux() {
let exp = vec![
Expand Down Expand Up @@ -645,7 +645,7 @@ fn parse_iflag_tokens_linux() {
}
}

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
#[test]
fn parse_oflag_tokens_linux() {
let exp = vec![
Expand Down
Loading