Skip to content

Commit

Permalink
Merge pull request #856 from mkroening/lib-tests
Browse files Browse the repository at this point in the history
fix: support lib tests on Apple Silicon
  • Loading branch information
mkroening authored Aug 23, 2023
2 parents 752c2d7 + 2710e87 commit bd9f223
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
- uses: mkroening/rust-toolchain-toml@main
- uses: Swatinem/rust-cache@v2
- name: Unit tests
run: cargo test --lib --target x86_64-unknown-linux-gnu
run: cargo test --lib
env:
RUSTFLAGS: -Awarnings
- name: Download loader
Expand Down
1 change: 1 addition & 0 deletions src/arch/aarch64/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub(crate) static CPU_ONLINE: AtomicU32 = AtomicU32::new(0);

pub(crate) static CURRENT_STACK_ADDRESS: AtomicU64 = AtomicU64::new(0);

#[cfg(target_os = "none")]
global_asm!(include_str!("start.s"));

/// Kernel header to announce machine features
Expand Down
18 changes: 0 additions & 18 deletions src/arch/x86_64/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ pub fn message_output_init() {
*COM1.lock() = Some(serial_port);
}

#[cfg(target_os = "none")]
pub fn output_message_buf(buf: &[u8]) {
// Output messages to the serial port and VGA screen in unikernel mode.
COM1.lock().as_mut().unwrap().send(buf);
Expand All @@ -201,13 +200,6 @@ pub fn output_message_buf(buf: &[u8]) {
}
}

#[cfg(not(target_os = "none"))]
pub fn output_message_buf(buf: &[u8]) {
use std::io::Write;

std::io::stderr().write_all(buf).unwrap();
}

/// Real Boot Processor initialization as soon as we have put the first Welcome message on the screen.
#[cfg(target_os = "none")]
pub fn boot_processor_init() {
Expand Down Expand Up @@ -333,13 +325,3 @@ unsafe extern "C" fn pre_init(boot_info: &'static RawBootInfo, cpu_id: u32) -> !
crate::application_processor_main();
}
}

#[cfg(all(test, not(target_os = "none")))]
mod tests {
use super::*;

#[test]
fn test_output() {
output_message_buf(b"test message\n");
}
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ mod scheduler;
mod synch;
mod syscalls;

#[cfg(target_os = "none")]
hermit_entry::define_entry_version!();

#[doc(hidden)]
Expand Down
3 changes: 3 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/// Adapted from [`std::print`].
///
/// [`std::print`]: https://doc.rust-lang.org/stable/std/macro.print.html
#[cfg(target_os = "none")]
#[macro_export]
macro_rules! print {
($($arg:tt)*) => {{
Expand All @@ -15,6 +16,7 @@ macro_rules! print {
/// Adapted from [`std::println`].
///
/// [`std::println`]: https://doc.rust-lang.org/stable/std/macro.println.html
#[cfg(target_os = "none")]
#[macro_export]
macro_rules! println {
() => {
Expand All @@ -28,6 +30,7 @@ macro_rules! println {
/// Prints and returns the value of a given expression for quick and dirty
/// debugging.
// Copied from std/macros.rs
#[cfg(target_os = "none")]
#[macro_export]
macro_rules! dbg {
// NOTE: We cannot use `concat!` to make a static string as a format argument
Expand Down

0 comments on commit bd9f223

Please sign in to comment.