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

tests: fix doctests and run in Makefile target #94

Merged
merged 2 commits into from
Sep 15, 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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ all: svsm.bin

test:
cargo test --target=x86_64-unknown-linux-gnu
RUSTFLAGS="--cfg doctest" cargo test --target=x86_64-unknown-linux-gnu --doc

utils/gen_meta: utils/gen_meta.c
cc -O3 -Wall -o $@ $<
Expand Down
2 changes: 1 addition & 1 deletion src/mm/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ unsafe impl GlobalAlloc for SvsmAllocator {
}
}

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

pub fn root_mem_init(pstart: PhysAddr, vstart: VirtAddr, page_count: usize) {
Expand Down
23 changes: 2 additions & 21 deletions src/utils/immut_after_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,27 +203,8 @@ unsafe impl<T> Sync for ImmutAfterInitCell<T> {}
/// }
/// ```
///
/// Also, a `ImmutAfterInitRef` can get initialized by dereferencing another,
/// possibly temporary `ImmutAfterInitRef`, with the temporary again either
/// dereferencing a [`ImmutAfterInitCell`]'s contents,
/// ```
/// # use svsm::utils::immut_after_init::{ImmutAfterInitCell, ImmutAfterInitRef};
/// static RX : ImmutAfterInitRef::<'static, i32> = ImmutAfterInitRef::uninit();
///
/// fn init_rx(r : ImmutAfterInitRef<'static, i32>) {
/// unsafe { RX.init_from_ref(r.get()) };
/// }
///
/// static X : ImmutAfterInitCell<i32> = ImmutAfterInitCell::uninit();
///
/// fn main() {
/// unsafe { X.init(&123) };
///
/// init_rx(ImmutAfterInitRef::new_from_cell(&X));
/// assert_eq!(*RX, 123);
/// }
/// ```
/// or a plain value directly:
/// Also, an `ImmutAfterInitRef` can be initialized by obtaining a reference
/// from another `ImmutAfterInitRef`:
/// ```
/// # use svsm::utils::immut_after_init::ImmutAfterInitRef;
/// static RX : ImmutAfterInitRef::<'static, i32> = ImmutAfterInitRef::uninit();
Expand Down
Loading