Skip to content

Commit 4ee90b3

Browse files
ShadowCurseroypat
authored andcommitted
chore: adjust doc tests to work without features
If no features are specified, do nothing in the doc test. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent 9da7eb7 commit 4ee90b3

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

src/lib.rs

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,34 @@
3333
//! # extern crate linux_loader;
3434
//! # extern crate vm_memory;
3535
//! # use std::{io::{Cursor, Read}, fs::File};
36-
//! # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
37-
//! # use linux_loader::configurator::{BootConfigurator, BootParams};
38-
//! # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
39-
//! # use linux_loader::configurator::pvh::PvhBootConfigurator;
40-
//! # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
41-
//! # use linux_loader::loader::elf::start_info::{hvm_memmap_table_entry, hvm_start_info};
42-
//! # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
43-
//! # use linux_loader::loader::elf::Elf;
36+
//!
37+
//! # #[cfg(all(
38+
//! # any(target_arch = "x86", target_arch = "x86_64"),
39+
//! # any(feature = "elf", feature = "pe", feature = "bzimage")
40+
//! # ))]
41+
//! # mod imports {
42+
//! # pub use linux_loader::configurator::{BootConfigurator, BootParams};
43+
//! # pub use linux_loader::configurator::pvh::PvhBootConfigurator;
44+
//! # pub use linux_loader::loader::elf::start_info::{hvm_memmap_table_entry, hvm_start_info};
45+
//! # pub use linux_loader::loader::elf::Elf;
46+
//! # }
47+
//!
48+
//! # #[cfg(all(
49+
//! # any(target_arch = "x86", target_arch = "x86_64"),
50+
//! # any(feature = "elf", feature = "pe", feature = "bzimage")
51+
//! # ))]
52+
//! # pub use imports::*;
53+
//!
4454
//! # use linux_loader::loader::KernelLoader;
4555
//! # use vm_memory::{Address, GuestAddress, GuestMemoryMmap};
4656
//! # const E820_RAM: u32 = 1;
4757
//! # const MEM_SIZE: usize = 0x100_0000;
4858
//! # const XEN_HVM_START_MAGIC_VALUE: u32 = 0x336ec578;
4959
//!
50-
//! # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
60+
//! # #[cfg(all(
61+
//! # any(target_arch = "x86", target_arch = "x86_64"),
62+
//! # any(feature = "elf", feature = "pe", feature = "bzimage")
63+
//! # ))]
5164
//! fn build_boot_params() -> (hvm_start_info, Vec<hvm_memmap_table_entry>) {
5265
//! let mut start_info = hvm_start_info::default();
5366
//! let memmap_entry = hvm_memmap_table_entry {
@@ -63,7 +76,10 @@
6376
//! (start_info, vec![memmap_entry])
6477
//! }
6578
//!
66-
//! # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
79+
//! # #[cfg(all(
80+
//! # any(target_arch = "x86", target_arch = "x86_64"),
81+
//! # any(feature = "elf", feature = "pe", feature = "bzimage")
82+
//! # ))]
6783
//! fn main() {
6884
//! let guest_mem = GuestMemoryMmap::from_ranges(&[(GuestAddress(0x0), MEM_SIZE)]).unwrap();
6985
//!
@@ -93,7 +109,13 @@
93109
//! PvhBootConfigurator::write_bootparams::<GuestMemoryMmap>(&boot_params, &guest_mem).unwrap();
94110
//! }
95111
//!
96-
//! # #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
112+
//! # #[cfg(all(
113+
//! # any(target_arch = "aarch64", target_arch = "riscv64"),
114+
//! # any(feature = "elf", feature = "pe", feature = "bzimage")
115+
//! # ))]
116+
//! # fn main() {}
117+
//!
118+
//! # #[cfg(not(any(feature = "elf", feature = "pe", feature = "bzimage")))]
97119
//! # fn main() {}
98120
//! ```
99121
//!

0 commit comments

Comments
 (0)