Skip to content

Commit

Permalink
Revert "tests: Clean up AVR test"
Browse files Browse the repository at this point in the history
This reverts commit 18716b8.
  • Loading branch information
taiki-e committed Jul 31, 2023
1 parent 18716b8 commit ef3299b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/.cspell/project-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ lqarx
lrcpc
lwsync
machdep
metavar
mfence
mgba
mipsn
Expand Down
84 changes: 57 additions & 27 deletions tests/avr/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![no_std]
#![warn(rust_2018_idioms, single_use_lifetimes, unsafe_op_in_unsafe_fn)]
#![feature(lang_items)]
#![feature(macro_metavar_expr)]
#![feature(panic_info_message)]
#![allow(clippy::empty_loop)] // this test crate is #![no_std]

Expand All @@ -19,59 +20,88 @@ fn main() -> ! {
let pins = arduino_hal::pins!(dp);
let mut serial = arduino_hal::default_serial!(dp, pins, 57600);

macro_rules! print {
($($tt:tt)*) => {{
let _ = ufmt::uwrite!(serial, $($tt)*);
}};
}
macro_rules! println {
($($tt:tt)*) => {{
let _ = ufmt::uwriteln!(serial, $($tt)*);
}};
}

macro_rules! test_atomic_int {
($int_type:ident) => {
paste::paste! {
fn [<test_atomic_ $int_type>]() {
fn [<test_atomic_ $int_type>](serial: &mut impl ufmt::uWrite) {
macro_rules! print {
($$($tt:tt)*) => {{
let _ = ufmt::uwrite!(serial, $$($tt)*);
}};
}
macro_rules! println {
($$($tt:tt)*) => {{
let _ = ufmt::uwriteln!(serial, $$($tt)*);
}};
}
print!("test test_atomic_{} ... ", stringify!($int_type));
__test_atomic_int!([<Atomic $int_type:camel>], $int_type);
println!("ok");
}
print!("test test_atomic_{} ... ", stringify!($int_type));
[<test_atomic_ $int_type>]();
println!("ok");
[<test_atomic_ $int_type>](&mut serial);
}
};
}
macro_rules! test_atomic_float {
($float_type:ident) => {
paste::paste! {
fn [<test_atomic_ $float_type>]() {
fn [<test_atomic_ $float_type>](serial: &mut impl ufmt::uWrite) {
macro_rules! print {
($$($tt:tt)*) => {{
let _ = ufmt::uwrite!(serial, $$($tt)*);
}};
}
macro_rules! println {
($$($tt:tt)*) => {{
let _ = ufmt::uwriteln!(serial, $$($tt)*);
}};
}
print!("test test_atomic_{} ... ", stringify!($float_type));
__test_atomic_float!([<Atomic $float_type:camel>], $float_type);
println!("ok");
}
print!("test test_atomic_{} ... ", stringify!($float_type));
[<test_atomic_ $float_type>]();
println!("ok");
[<test_atomic_ $float_type>](&mut serial);
}
};
}
macro_rules! test_atomic_bool {
() => {
fn test_atomic_bool() {
fn test_atomic_bool(serial: &mut impl ufmt::uWrite) {
macro_rules! print {
($$($tt:tt)*) => {{
let _ = ufmt::uwrite!(serial, $$($tt)*);
}};
}
macro_rules! println {
($$($tt:tt)*) => {{
let _ = ufmt::uwriteln!(serial, $$($tt)*);
}};
}
print!("test test_atomic_bool ... ");
__test_atomic_bool!(AtomicBool);
println!("ok");
}
print!("test test_atomic_bool ... ");
test_atomic_bool();
println!("ok");
test_atomic_bool(&mut serial);
};
}
macro_rules! test_atomic_ptr {
() => {
fn test_atomic_ptr() {
fn test_atomic_ptr(serial: &mut impl ufmt::uWrite) {
macro_rules! print {
($$($tt:tt)*) => {{
let _ = ufmt::uwrite!(serial, $$($tt)*);
}};
}
macro_rules! println {
($$($tt:tt)*) => {{
let _ = ufmt::uwriteln!(serial, $$($tt)*);
}};
}
print!("test test_atomic_ptr ... ");
__test_atomic_ptr!(AtomicPtr<u8>);
println!("ok");
}
print!("test test_atomic_ptr ... ");
test_atomic_ptr();
println!("ok");
test_atomic_ptr(&mut serial);
};
}

Expand Down

0 comments on commit ef3299b

Please sign in to comment.