From 818b273f497c0fb4f35e7bc31aec14df32d41ec3 Mon Sep 17 00:00:00 2001 From: Henri Lunnikivi Date: Wed, 20 Mar 2024 16:57:11 +0200 Subject: [PATCH] sysctrl: print example names --- examples/sysctrl/hello-sysctrl/examples/uart0.rs | 2 ++ examples/sysctrl/hello-sysctrl/src/lib.rs | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/examples/sysctrl/hello-sysctrl/examples/uart0.rs b/examples/sysctrl/hello-sysctrl/examples/uart0.rs index 7b87ad85..60532683 100644 --- a/examples/sysctrl/hello-sysctrl/examples/uart0.rs +++ b/examples/sysctrl/hello-sysctrl/examples/uart0.rs @@ -2,10 +2,12 @@ #![no_main] use headsail_bsp::{rt::entry, uart::uart_write}; +use hello_sysctrl::print_example_name; use panic_halt as _; #[entry] fn main() -> ! { + print_example_name!(); uart_write("Hello world!"); loop {} } diff --git a/examples/sysctrl/hello-sysctrl/src/lib.rs b/examples/sysctrl/hello-sysctrl/src/lib.rs index ce0e5f5c..84d58d8c 100644 --- a/examples/sysctrl/hello-sysctrl/src/lib.rs +++ b/examples/sysctrl/hello-sysctrl/src/lib.rs @@ -1,2 +1,14 @@ #![no_std] #![no_main] + +/// Print the name of the current file, i.e., test name. +/// +/// This must be a macro to make sure core::file matches the file this is +/// invoked in. +#[macro_export] +macro_rules! print_example_name { + () => { + use headsail_bsp::sprintln; + sprintln!("[{}]", core::file!()); + }; +}