From 4fca5a99aab7d7d6486e4c66b84a5a251c6976f5 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 3 Nov 2026 06:32:40 +0000 Subject: [PATCH] test: cover processor groups at the pointer width Exercise a full group of usize::BITS processors and an active count of usize::BITS + 1 on every pointer width. Masks shift only when the bit index is below usize::BITS, and a wider group returns OutOfRangeAffinityMask. Co-authored-by: jameslincn --- src/system/cpu_topology.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/system/cpu_topology.rs b/src/system/cpu_topology.rs index a54508e..a070197 100644 --- a/src/system/cpu_topology.rs +++ b/src/system/cpu_topology.rs @@ -951,6 +951,35 @@ mod tests { ); } + #[test] + fn pointer_width_group_builds_one_bit_per_processor() { + let count = usize::BITS as usize; + let ids = (0..usize::BITS) + .map(|number| id(0, number as u8)) + .collect::>(); + let records = (0..usize::BITS) + .map(|number| { + // A shift of `usize::BITS` is out of range for this pointer width. + let mask = if number < usize::BITS { + 1usize << number + } else { + 0 + }; + record(0, &[(0, mask)]) + }) + .collect::>(); + + let topology = build_topology(&ids, &[usize::BITS], records).unwrap(); + assert!(topology.matches_sample_len(count)); + } + + #[test] + fn active_count_above_pointer_width_is_out_of_range() { + let active_count = usize::BITS + 1; + let topology = build_topology(&[id(0, 0)], &[active_count], vec![record(0, &[(0, 1)])]); + assert_eq!(topology, Err(CpuTopologyError::OutOfRangeAffinityMask)); + } + #[test] fn malformed_variable_records_are_rejected() { let valid = encoded_record(0, &[(0, 1)]);