From e013e30f03190684682736fc0bb6eb75eacee960 Mon Sep 17 00:00:00 2001 From: Christian Eltzschig Date: Thu, 21 Dec 2023 08:27:27 +0100 Subject: [PATCH] [#51] Full CI checks for mac os, fix shm size tests, ensure that null terminator is always present --- .cirrus.yml | 17 +---------------- iceoryx2-bb/posix/tests/shared_memory_tests.rs | 6 +++--- iceoryx2-pal/posix/src/macos/mman.rs | 7 ++++++- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 75d22f8e0..662357b05 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -269,19 +269,4 @@ macos_aarch64_stable_debug_task: - rustup component add clippy rustfmt set_toolchain_script: rustup default stable <<: *IOX2_CARGO_FMT_AND_CLIPPY - <<: *IOX2_COMMON_BUILD_DEBUG - test_script: - - cargo test -p iceoryx2-pal-concurrency-sync - -p iceoryx2-pal-posix - -p iceoryx2-bb-container - -p iceoryx2-bb-elementary - -p iceoryx2-bb-lock-free - -p iceoryx2-bb-log - -p iceoryx2-bb-memory - -p iceoryx2-bb-posix - -p iceoryx2-bb-system-types - -p iceoryx2-bb-testing - -p iceoryx2-bb-threadsafe - -p iceoryx2-bb-trait-tests - -p iceoryx2-cal - --lib --bins --tests --no-fail-fast + <<: *IOX2_COMMON_BUILD_AND_TEST_DEBUG diff --git a/iceoryx2-bb/posix/tests/shared_memory_tests.rs b/iceoryx2-bb/posix/tests/shared_memory_tests.rs index 3cdc66ef4..b4327290f 100644 --- a/iceoryx2-bb/posix/tests/shared_memory_tests.rs +++ b/iceoryx2-bb/posix/tests/shared_memory_tests.rs @@ -92,7 +92,7 @@ fn shared_memory_create_and_modify_open_works() { #[test] fn shared_memory_opening_with_non_fitting_size_fails() { let shm_name = generate_shm_name(); - let _sut_create = SharedMemoryBuilder::new(&shm_name) + let sut_create = SharedMemoryBuilder::new(&shm_name) .creation_mode(CreationMode::PurgeAndCreate) .size(1024) .permission(Permission::OWNER_ALL) @@ -102,14 +102,14 @@ fn shared_memory_opening_with_non_fitting_size_fails() { let sut_open1 = SharedMemoryBuilder::new(&shm_name) .creation_mode(CreationMode::OpenOrCreate) - .size(8192) + .size(sut_create.size() + 1) .permission(Permission::OWNER_ALL) .zero_memory(true) .create(); let sut_open2 = SharedMemoryBuilder::new(&shm_name) .creation_mode(CreationMode::OpenOrCreate) - .size(16384) + .size(sut_create.size() * 2) .permission(Permission::OWNER_ALL) .zero_memory(true) .create(); diff --git a/iceoryx2-pal/posix/src/macos/mman.rs b/iceoryx2-pal/posix/src/macos/mman.rs index 4f95f8c0c..77e86d07c 100644 --- a/iceoryx2-pal/posix/src/macos/mman.rs +++ b/iceoryx2-pal/posix/src/macos/mman.rs @@ -87,7 +87,12 @@ unsafe fn get_real_shm_name(name: *const char) -> Option<[u8; SHM_MAX_NAME_LEN]> let mut buffer = [0u8; SHM_MAX_NAME_LEN]; - if read(shm_state_fd, buffer.as_mut_ptr().cast(), SHM_MAX_NAME_LEN) <= 0 { + if read( + shm_state_fd, + buffer.as_mut_ptr().cast(), + SHM_MAX_NAME_LEN - 1, + ) <= 0 + { close(shm_state_fd); return None; }