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

fix: support lib tests on Apple Silicon #856

Merged
merged 5 commits into from
Aug 23, 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
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