Skip to content

Commit

Permalink
mm/alloc: don't set global_allocator attribute for test builds
Browse files Browse the repository at this point in the history
The SvsmAllocator is specific to the embedded SVSM environment and not
functional on the 'cargo test' host environment. Make it the global_allocator
only if the 'test' configuration predicate evaluates to false.

Signed-off-by: Nicolai Stange <[email protected]>
  • Loading branch information
nicstange committed Jan 9, 2023
1 parent 4499eb6 commit 0bf5892
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mm/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ unsafe impl GlobalAlloc for SvsmAllocator {
}
}

#[global_allocator]
#[cfg_attr(not(test), global_allocator)]
pub static mut ALLOCATOR: SvsmAllocator = SvsmAllocator::new();

pub fn root_mem_init(pstart: PhysAddr, vstart: VirtAddr, page_count: usize) {
Expand Down

0 comments on commit 0bf5892

Please sign in to comment.