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

Add filepath to code block #893

Merged
merged 1 commit into from Dec 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion blog/content/edition-2/posts/04-testing/index.md
Expand Up @@ -214,6 +214,8 @@ For specifying the exit status, we create a `QemuExitCode` enum. The idea is to
We can now update our `test_runner` to exit QEMU after all tests ran:

```rust
// in src/main.rs

fn test_runner(tests: &[&dyn Fn()]) {
println!("Running {} tests", tests.len());
for test in tests {
Expand Down Expand Up @@ -246,6 +248,8 @@ The problem is that `cargo test` considers all error codes other than `0` as fai
To work around this, `bootimage` provides a `test-success-exit-code` configuration key that maps a specified exit code to the exit code `0`:

```toml
# in Cargo.toml

[package.metadata.bootimage]
test-args = […]
test-success-exit-code = 33 # (0x10 << 1) | 1
Expand Down Expand Up @@ -315,6 +319,8 @@ Like the `isa-debug-exit` device, the UART is programmed using port I/O. Since t
To make the serial port easily usable, we add `serial_print!` and `serial_println!` macros:

```rust
// in src/serial.rs

#[doc(hidden)]
pub fn _print(args: ::core::fmt::Arguments) {
use core::fmt::Write;
Expand Down Expand Up @@ -406,6 +412,8 @@ To exit QEMU with an error message on a panic, we can use [conditional compilati
[conditional compilation]: https://doc.rust-lang.org/1.30.0/book/first-edition/conditional-compilation.html

```rust
// in src/main.rs

// our existing panic handler
#[cfg(not(test))] // new attribute
#[panic_handler]
Expand Down Expand Up @@ -786,7 +794,7 @@ We make the modules public to make them usable from outside of our library. This
Now we can update our `main.rs` to use the library:

```rust
// src/main.rs
// in src/main.rs

#![no_std]
#![no_main]
Expand Down