Skip to content

Commit

Permalink
[#525] Add debug_assertions; reduce parallel test threads so that sys…
Browse files Browse the repository at this point in the history
…tems with many CPU cores can handle them as well
  • Loading branch information
elfenpiff committed Dec 4, 2024
1 parent 4b58bec commit 47b476d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions iceoryx2-cal/src/zero_copy_connection/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ pub mod details {

let segment_id = ptr.segment_id().value() as usize;
let sample_size = storage.sample_size;
debug_assert!(ptr.offset() % sample_size == 0);
let index = ptr.offset() / sample_size;

debug_assert!(segment_id < storage.number_of_segments as usize);
Expand All @@ -550,6 +551,7 @@ pub mod details {
match unsafe { storage.submission_channel.push(ptr.as_value()) } {
Some(v) => {
let pointer_offset = PointerOffset::from_value(v);
debug_assert!(pointer_offset.offset() % sample_size == 0);
if !storage.used_chunk_list[pointer_offset.segment_id().value() as usize]
.remove(pointer_offset.offset() / sample_size)
{
Expand Down Expand Up @@ -596,6 +598,7 @@ pub mod details {
msg, pointer_offset);
}

debug_assert!(pointer_offset.offset() % storage.sample_size == 0);
if !storage.used_chunk_list[segment_id]
.remove(pointer_offset.offset() / storage.sample_size)
{
Expand Down
12 changes: 6 additions & 6 deletions iceoryx2/tests/service_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ mod service {
Factory: SutFactory<Sut>,
>() {
let _watch_dog = Watchdog::new();
let number_of_threads = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 1024);
let number_of_threads = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 4);
const NUMBER_OF_ITERATIONS: usize = 25;
let test = Factory::new();

Expand Down Expand Up @@ -291,7 +291,7 @@ mod service {
Factory: SutFactory<Sut>,
>() {
let _watch_dog = Watchdog::new();
let number_of_threads = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 1024);
let number_of_threads = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 4);
const NUMBER_OF_ITERATIONS: usize = 25;
let test = Factory::new();

Expand Down Expand Up @@ -343,7 +343,7 @@ mod service {
set_log_level(LogLevel::Debug);
let _watch_dog = Watchdog::new_with_timeout(Duration::from_secs(120));
const NUMBER_OF_CLOSE_THREADS: usize = 1;
let number_of_open_threads = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 1024);
let number_of_open_threads = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 4);
let number_of_threads = NUMBER_OF_CLOSE_THREADS + number_of_open_threads;
let test = Factory::new();

Expand Down Expand Up @@ -681,7 +681,7 @@ mod service {
fn concurrent_service_creation_and_listing_works<Sut: Service, Factory: SutFactory<Sut>>() {
let _watch_dog = Watchdog::new_with_timeout(Duration::from_secs(120));
let test = Factory::new();
let number_of_creators = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 1024);
let number_of_creators = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 4);
const NUMBER_OF_ITERATIONS: usize = 40;
let barrier = Barrier::new(number_of_creators);

Expand Down Expand Up @@ -726,7 +726,7 @@ mod service {
>() {
let _watch_dog = Watchdog::new_with_timeout(Duration::from_secs(120));
let test = Factory::new();
let number_of_creators = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 1024);
let number_of_creators = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 4);
const NUMBER_OF_ITERATIONS: usize = 30;
let barrier = Barrier::new(number_of_creators);

Expand Down Expand Up @@ -790,7 +790,7 @@ mod service {
>() {
let _watch_dog = Watchdog::new_with_timeout(Duration::from_secs(120));
let test = Factory::new();
let number_of_creators = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 1024);
let number_of_creators = (SystemInfo::NumberOfCpuCores.value()).clamp(2, 4);
const NUMBER_OF_ITERATIONS: usize = 30;
let barrier = Barrier::new(number_of_creators);

Expand Down

0 comments on commit 47b476d

Please sign in to comment.