From 047d6626b01ccbe17e5ba5cf68bbde54ed19d345 Mon Sep 17 00:00:00 2001 From: SteveLauC Date: Sun, 5 May 2024 21:03:34 +0800 Subject: [PATCH] ci: fix CI by correcting wrong cfg value & removing cache with sudo (#2394) * refactor: correct wrong cfg value && remove ones that do not exist * debug ci * debug ci * debug ci * debug ci * test: disable test_mq module for Fuchsia * style: fmt --- .github/workflows/ci.yml | 8 ++++---- build.rs | 11 +++++++++++ src/sys/signal.rs | 2 +- test/common/mod.rs | 4 ++-- test/sys/test_signal.rs | 2 +- test/test.rs | 7 +------ test/test_fcntl.rs | 4 ---- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a56e7d2b7..ed51548a7a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: TARGET: '${{ env.TARGET }}' - name: before_cache_script - run: rm -rf $CARGO_HOME/registry/index + run: sudo rm -rf $CARGO_HOME/registry/index macos-aarch64: runs-on: macos-14 @@ -68,7 +68,7 @@ jobs: TARGET: "${{ env.TARGET }}" - name: before_cache_script - run: rm -rf $CARGO_HOME/registry/index + run: sudo rm -rf $CARGO_HOME/registry/index # Use cross for QEMU-based testing # cross needs to execute Docker, GitHub Action already has it installed @@ -162,7 +162,7 @@ jobs: TARGET: '${{ matrix.TARGET }}' - name: before_cache_script - run: rm -rf $CARGO_HOME/registry/index + run: sudo rm -rf $CARGO_HOME/registry/index; rust_stable: runs-on: ubuntu-20.04 @@ -188,7 +188,7 @@ jobs: TARGET: '${{ env.TARGET }}' - name: before_cache_script - run: rm -rf $CARGO_HOME/registry/index + run: sudo rm -rf $CARGO_HOME/registry/index diff --git a/build.rs b/build.rs index 70adacbd1f..226a32cccb 100644 --- a/build.rs +++ b/build.rs @@ -26,4 +26,15 @@ fn main() { netbsdlike: { any(netbsd, openbsd) }, solarish: { any(illumos, solaris) }, } + + // Below are Nix's custom cfg values that we need to let the compiler know + println!("cargo:rustc-check-cfg=cfg(apple_targets)"); + println!("cargo:rustc-check-cfg=cfg(bsd)"); + println!("cargo:rustc-check-cfg=cfg(bsd_without_apple)"); + println!("cargo:rustc-check-cfg=cfg(linux_android)"); + println!("cargo:rustc-check-cfg=cfg(freebsdlike)"); + println!("cargo:rustc-check-cfg=cfg(netbsdlike)"); + println!("cargo:rustc-check-cfg=cfg(solarish)"); + println!("cargo:rustc-check-cfg=cfg(fbsd14)"); + println!("cargo:rustc-check-cfg=cfg(qemu)"); } diff --git a/src/sys/signal.rs b/src/sys/signal.rs index 2a9c0027a9..8f41127e27 100644 --- a/src/sys/signal.rs +++ b/src/sys/signal.rs @@ -597,7 +597,7 @@ impl SigSet { target_os = "haiku", target_os = "hurd", target_os = "aix", - target_os = "fushsia" + target_os = "fuchsia" ))] #[doc(alias("sigsuspend"))] pub fn suspend(&self) -> Result<()> { diff --git a/test/common/mod.rs b/test/common/mod.rs index db4aed2598..ab0e746367 100644 --- a/test/common/mod.rs +++ b/test/common/mod.rs @@ -37,8 +37,8 @@ cfg_if! { #[macro_export] macro_rules! require_mount { ($name:expr) => { - use ::sysctl::{CtlValue, Sysctl}; use nix::unistd::Uid; + use sysctl::{CtlValue, Sysctl}; let ctl = ::sysctl::Ctl::new("vfs.usermount").unwrap(); if !Uid::current().is_root() && CtlValue::Int(0) == ctl.value().unwrap() @@ -65,7 +65,7 @@ macro_rules! skip_if_cirrus { #[macro_export] macro_rules! skip_if_jailed { ($name:expr) => { - use ::sysctl::{CtlValue, Sysctl}; + use sysctl::{CtlValue, Sysctl}; let ctl = ::sysctl::Ctl::new("security.jail.jailed").unwrap(); if let CtlValue::Int(1) = ctl.value().unwrap() { diff --git a/test/sys/test_signal.rs b/test/sys/test_signal.rs index 7494b71234..cd4bc3d9b9 100644 --- a/test/sys/test_signal.rs +++ b/test/sys/test_signal.rs @@ -350,7 +350,7 @@ fn test_sigwait() { target_os = "haiku", target_os = "hurd", target_os = "aix", - target_os = "fushsia" + target_os = "fuchsia" ))] #[test] fn test_sigsuspend() { diff --git a/test/test.rs b/test/test.rs index 4e0ffc8f9a..7401c95611 100644 --- a/test/test.rs +++ b/test/test.rs @@ -13,12 +13,7 @@ mod test_errno; mod test_fcntl; #[cfg(linux_android)] mod test_kmod; -#[cfg(any( - freebsdlike, - target_os = "fushsia", - target_os = "linux", - target_os = "netbsd" -))] +#[cfg(any(freebsdlike, target_os = "linux", target_os = "netbsd"))] mod test_mq; #[cfg(not(target_os = "redox"))] mod test_net; diff --git a/test/test_fcntl.rs b/test/test_fcntl.rs index 1d05b1e250..2131f46c5c 100644 --- a/test/test_fcntl.rs +++ b/test/test_fcntl.rs @@ -13,7 +13,6 @@ use nix::fcntl::{openat2, OpenHow, ResolveFlag}; target_env = "gnu", any( target_arch = "x86_64", - target_arch = "x32", target_arch = "powerpc", target_arch = "s390x" ) @@ -146,7 +145,6 @@ fn test_renameat() { target_env = "gnu", any( target_arch = "x86_64", - target_arch = "x32", target_arch = "powerpc", target_arch = "s390x" ) @@ -190,7 +188,6 @@ fn test_renameat2_behaves_like_renameat_with_no_flags() { target_env = "gnu", any( target_arch = "x86_64", - target_arch = "x32", target_arch = "powerpc", target_arch = "s390x" ) @@ -238,7 +235,6 @@ fn test_renameat2_exchange() { target_env = "gnu", any( target_arch = "x86_64", - target_arch = "x32", target_arch = "powerpc", target_arch = "s390x" )