Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix up build on macos #1477

Merged
merged 3 commits into from
Nov 9, 2023
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
24 changes: 24 additions & 0 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,30 @@ jobs:
target/release/nydus-image
target/release/nydusd

nydusd-build-macos:
runs-on: macos-11
strategy:
matrix:
arch: [amd64, arm64]
steps:
- uses: actions/checkout@v3
- name: Cache cargo
uses: Swatinem/rust-cache@v2.2.0
with:
cache-on-failure: true
key: ${{ runner.os }}-cargo-${{ matrix.arch }}
- name: build
run: |
if [[ "${{matrix.arch}}" == "amd64" ]]; then
RUST_TARGET="x86_64-apple-darwin"
else
RUST_TARGET="aarch64-apple-darwin"
fi
cargo install --version 0.2.4 cross
rustup target add ${RUST_TARGET}
rustup component add rustfmt clippy
make -e RUST_TARGET_STATIC=$RUST_TARGET -e CARGO=cross static-release

nydus-integration-test:
runs-on: ubuntu-latest
needs: [contrib-build, nydus-build]
Expand Down
10 changes: 5 additions & 5 deletions builder/src/core/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ mod tests {
#[test]
fn test_node() {
let mut inode = InodeWrapper::V5(RafsV5Inode::default());
inode.set_mode(libc::S_IFCHR);
inode.set_mode(libc::S_IFCHR as u32);
let node = Node::new(inode, NodeInfo::default(), 0);
assert!(!node.is_overlayfs_whiteout(WhiteoutSpec::None));
assert!(node.is_overlayfs_whiteout(WhiteoutSpec::Overlayfs));
Expand All @@ -270,7 +270,7 @@ mod tests {
.xattrs
.add(OVERLAYFS_WHITEOUT_OPAQUE.into(), "y".into())
.is_ok());
inode.set_mode(libc::S_IFDIR);
inode.set_mode(libc::S_IFDIR as u32);
let node = Node::new(inode, info, 0);
assert!(!node.is_overlayfs_opaque(WhiteoutSpec::None));
assert!(node.is_overlayfs_opaque(WhiteoutSpec::Overlayfs));
Expand All @@ -285,7 +285,7 @@ mod tests {
.xattrs
.add(OVERLAYFS_WHITEOUT_OPAQUE.into(), "n".into())
.is_ok());
inode.set_mode(libc::S_IFDIR);
inode.set_mode(libc::S_IFDIR as u32);
let node = Node::new(inode, info, 0);
assert!(!node.is_overlayfs_opaque(WhiteoutSpec::None));
assert!(!node.is_overlayfs_opaque(WhiteoutSpec::Overlayfs));
Expand All @@ -296,7 +296,7 @@ mod tests {
.xattrs
.add(OVERLAYFS_WHITEOUT_OPAQUE.into(), "y".into())
.is_ok());
inode.set_mode(libc::S_IFCHR);
inode.set_mode(libc::S_IFCHR as u32);
let node = Node::new(inode, info, 0);
assert!(!node.is_overlayfs_opaque(WhiteoutSpec::None));
assert!(!node.is_overlayfs_opaque(WhiteoutSpec::Overlayfs));
Expand All @@ -307,7 +307,7 @@ mod tests {
.xattrs
.add(OVERLAYFS_WHITEOUT_OPAQUE.into(), "n".into())
.is_ok());
inode.set_mode(libc::S_IFDIR);
inode.set_mode(libc::S_IFDIR as u32);
let node = Node::new(inode, info, 0);
assert!(!node.is_overlayfs_opaque(WhiteoutSpec::None));
assert!(!node.is_overlayfs_opaque(WhiteoutSpec::Overlayfs));
Expand Down
14 changes: 7 additions & 7 deletions rafs/src/metadata/layout/v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2636,31 +2636,31 @@ mod tests {
assert_eq!(dir.e_nameoff, 2048);

assert_eq!(
RafsV6Dirent::file_type(libc::S_IFREG),
RafsV6Dirent::file_type(libc::S_IFREG as u32),
EROFS_FILE_TYPE::EROFS_FT_REG_FILE as u8
);
assert_eq!(
RafsV6Dirent::file_type(libc::S_IFDIR),
RafsV6Dirent::file_type(libc::S_IFDIR as u32),
EROFS_FILE_TYPE::EROFS_FT_DIR as u8
);
assert_eq!(
RafsV6Dirent::file_type(libc::S_IFCHR),
RafsV6Dirent::file_type(libc::S_IFCHR as u32),
EROFS_FILE_TYPE::EROFS_FT_CHRDEV as u8
);
assert_eq!(
RafsV6Dirent::file_type(libc::S_IFBLK),
RafsV6Dirent::file_type(libc::S_IFBLK as u32),
EROFS_FILE_TYPE::EROFS_FT_BLKDEV as u8
);
assert_eq!(
RafsV6Dirent::file_type(libc::S_IFIFO),
RafsV6Dirent::file_type(libc::S_IFIFO as u32),
EROFS_FILE_TYPE::EROFS_FT_FIFO as u8
);
assert_eq!(
RafsV6Dirent::file_type(libc::S_IFSOCK),
RafsV6Dirent::file_type(libc::S_IFSOCK as u32),
EROFS_FILE_TYPE::EROFS_FT_SOCK as u8
);
assert_eq!(
RafsV6Dirent::file_type(libc::S_IFLNK),
RafsV6Dirent::file_type(libc::S_IFLNK as u32),
EROFS_FILE_TYPE::EROFS_FT_SYMLINK as u8
);
}
Expand Down
2 changes: 1 addition & 1 deletion rafs/src/mock/mock_inode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ mod tests {

let mut node = MockInode::mock(13, size, chunks);
node.i_flags = RafsInodeFlags::XATTR;
node.i_mode = libc::S_IFDIR;
node.i_mode = libc::S_IFDIR as u32;
node.i_name = "foo".into();
node.i_digest = digest;
node.i_parent = RAFS_V5_ROOT_INODE;
Expand Down
4 changes: 1 addition & 3 deletions service/src/singleton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ pub fn create_daemon(
Ok(daemon)
}

#[cfg(test)]
#[cfg(all(test, target_os = "linux"))]
mod tests {
use crate::blob_cache::generate_blob_key;

Expand Down Expand Up @@ -317,13 +317,11 @@ mod tests {
waker: Arc::new(waker),
blob_cache_mgr: Arc::new(BlobCacheMgr::new()),
fscache_enabled: AtomicBool::new(false),
#[cfg(target_os = "linux")]
fscache: Mutex::new(None),
}
}

#[test]
#[cfg(target_os = "linux")]
fn test_initialize_fscache_service() {
let service_controller = create_service_controller();

Expand Down
3 changes: 1 addition & 2 deletions utils/src/compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ pub fn minor_dev(dev: u64) -> u64 {
}
}

#[cfg(test)]
#[cfg(all(test, target_os = "linux"))]
mod tests {

use super::*;

#[test]
#[cfg(target_os = "linux")]
fn test_dev() {
let major: u64 = 0xffff_ffff_ffff_abcd;
let minor: u64 = 0xffff_ffff_abcd_ffff;
Expand Down
Loading