Skip to content

Commit

Permalink
add test script and end of test conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
tullom committed Jan 23, 2025
1 parent 092dca8 commit 693cba2
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/rt685s-evk/src/bin/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ async fn main(_spawner: Spawner) {

info!("ADC sample = {:#x}", data);

#[cfg(feature = "test-parser")]
test_parser_macros::pass_test();

Timer::after_millis(1000).await;
}
}
4 changes: 4 additions & 0 deletions examples/rt685s-evk/src/bin/clocks-blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ async fn main(_spawner: Spawner) {
loop {
info!("Toggling LED");
led.toggle();

#[cfg(feature = "test-parser")]
test_parser_macros::pass_test();

Timer::after_millis(1000).await;
}
}
3 changes: 3 additions & 0 deletions examples/rt685s-evk/src/bin/crc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ async fn main(_spawner: Spawner) {

defmt::assert_eq!(output, 0xebfebe9a);

#[cfg(feature = "test-parser")]
test_parser_macros::pass_test();

cortex_m::asm::bkpt();
}
3 changes: 3 additions & 0 deletions examples/rt685s-evk/src/bin/dma-mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,7 @@ async fn main(_spawner: Spawner) {
test_dma_channel!(p, DMA0_CH31, 31);

info!("DMA transfer tests completed");

#[cfg(feature = "test-parser")]
test_parser_macros::pass_test();
}
4 changes: 4 additions & 0 deletions examples/rt685s-evk/src/bin/gpio-blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ async fn main(_spawner: Spawner) {
loop {
info!("Toggling LED");
led.toggle();

#[cfg(feature = "test-parser")]
test_parser_macros::pass_test();

Timer::after_millis(1000).await;
}
}
3 changes: 3 additions & 0 deletions examples/rt685s-evk/src/bin/gpio-flex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ async fn main(_spawner: Spawner) {
// check pin level is high
assert!(flex.is_high());

#[cfg(feature = "test-parser")]
test_parser_macros::pass_test();

loop {
Timer::after_millis(1000).await;
}
Expand Down
3 changes: 3 additions & 0 deletions examples/rt685s-evk/src/bin/hello-world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ async fn main(_spawner: Spawner) {

info!("Hello world");

#[cfg(feature = "test-parser")]
test_parser_macros::pass_test();

loop {
Timer::after_millis(1000).await;
}
Expand Down
5 changes: 5 additions & 0 deletions examples/rt685s-evk/src/bin/i2c-loopback-async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ async fn master_service(mut master: I2cMaster<'static, Async>) {
.unwrap();
}
i += 1;

#[cfg(feature = "test-parser")]
if i == 300 {
test_parser_macros::pass_test();
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions examples/rt685s-evk/src/bin/i2c-master-async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ async fn main(_spawner: Spawner) {
}

info!("i2c example - Done! Busy Loop...");

#[cfg(feature = "test-parser")]
test_parser_macros::pass_test();

loop {
Timer::after_millis(1000).await;
}
Expand Down
4 changes: 4 additions & 0 deletions examples/rt685s-evk/src/bin/i2c-master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ async fn main(_spawner: Spawner) {
}

info!("i2c example - Done! Busy Loop...");

#[cfg(feature = "test-parser")]
test_parser_macros::pass_test();

loop {
Timer::after_millis(1000).await;
}
Expand Down
3 changes: 3 additions & 0 deletions examples/rt685s-evk/src/bin/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ async fn main(_spawner: Spawner) {
Timer::after_millis(100).await;
}

#[cfg(feature = "test-parser")]
test_parser_macros::pass_test();

Timer::after_millis(1000).await;
}
}
3 changes: 3 additions & 0 deletions examples/rt685s-evk/src/bin/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ async fn main(_spawner: Spawner) {
info!("random_u32 {}", random_u32);
info!("random_u64 {}", random_u64);
info!("random_bytes {}", random_bytes);

#[cfg(feature = "test-parser")]
test_parser_macros::pass_test();
}
3 changes: 3 additions & 0 deletions examples/rt685s-evk/src/bin/rtc-time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ async fn main(_spawner: Spawner) {
let (time, result) = r.get_datetime();
assert!(result.is_ok());
info!("RTC get time: {:?}", time);

#[cfg(feature = "test-parser")]
test_parser_macros::pass_test();
}
3 changes: 3 additions & 0 deletions examples/rt685s-evk/src/bin/sha256-async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,7 @@ async fn main(_spawner: Spawner) {
]
);
trace!("Hashes complete");

#[cfg(feature = "test-parser")]
test_parser_macros::pass_test();
}
3 changes: 3 additions & 0 deletions examples/rt685s-evk/src/bin/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,7 @@ async fn main(_spawner: Spawner) {
]
);
trace!("Hashes complete");

#[cfg(feature = "test-parser")]
test_parser_macros::pass_test();
}
4 changes: 4 additions & 0 deletions examples/rt685s-evk/src/bin/time-driver-blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ async fn main(_spawner: Spawner) -> ! {
loop {
info!("Toggling GPIO0_26 (Blue LED)");
led.toggle();

#[cfg(feature = "test-parser")]
test_parser_macros::pass_test();

Timer::after_millis(5000).await;
}
}
35 changes: 35 additions & 0 deletions examples/rt685s-evk/src/tests/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Get all .rs files in the current directory
files=(../bin/*.rs)

testCounter=1
failed=false
failedArr=()

# Loop through each file and add its name without the .rs extension to the array
for file in "${files[@]}"; do
strippedName="${file%.rs}"
echo "Executing test ${testCounter}: ${strippedName}"
((testCounter++))

cargo run --bin "$strippedName" --features test-parser | test-parser -s TEST-SUCCESS -f TEST-FAIL

if [ $? -eq 1 ]; then
echo "The last command failed with exit code 1."
failedArr+=("$strippedName")
failed=true
fi
done

echo -e "\n========END OF TESTS SUMMARY========"
if [ "$failed" = true ]; then
echo "Some tests failed: "
for failure in "${failedArr[@]}"; do
echo "${failure}"
done
exit 1
else
echo "All tests passed!"
exit 0
fi

0 comments on commit 693cba2

Please sign in to comment.