Skip to content

Commit

Permalink
Merge pull request #94 from 00xc/doc/tests
Browse files Browse the repository at this point in the history
tests: fix doctests and run in Makefile target
  • Loading branch information
joergroedel committed Sep 15, 2023
2 parents 23f902f + 651b3ca commit b8a5474
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
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

0 comments on commit b8a5474

Please sign in to comment.