diff --git a/.github/test-projects/step-executor.sh b/.github/test-projects/step-executor.sh index 19b0a28..710f21d 100755 --- a/.github/test-projects/step-executor.sh +++ b/.github/test-projects/step-executor.sh @@ -1,7 +1,43 @@ -#!/bin/sh -set -e -set -x +#!/bin/bash -/home/probe-rs-runner/probe-rs run "$TARGET" $TARGET_CONFIG +touch stdout +touch stderr -exit 1 \ No newline at end of file +/home/probe-rs-runner/probe-rs run --disable-progressbars "$TARGET" $TARGET_CONFIG --format=json 2> stderr | jq -c 'del(.exec_time)' >stdout + +# only fetch log rtt logs from stderr, ignore backtraces for now, remove function addresses +cat stderr | sed -nE 's/^[0-9]{1,2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}: (TRACE|DEBUG|INFO|WARN|ERROR)/\1/p' | sed 's/ function: 0x[0-9a-fA-F]\{1,\},//g'> rtt_logs + +echo "Stdout" >&2 +echo "------------------------------------------------" >&2 +cat stdout >&2 +echo "Stderr" >&2 +echo "------------------------------------------------" >&2 +cat stderr >&2 +echo "Rtt logs" >&2 +echo "------------------------------------------------" >&2 +cat rtt_logs >&2 + +res=0 + +# Output markers around diff to render it nicely in markdown +echo "Test Results diff:" +echo "\`\`\`diff" +if ! diff expected_test_results.txt stdout; then + res=1 +fi + + +echo "\`\`\`" + +echo "Stderr diff:" +echo "\`\`\`diff" +if ! diff expected_rtt_logs.txt rtt_logs; then + res=1 +fi +cat rtt_logs +echo "\`\`\`" + +rm -f stdout stderr rtt_logs + +exit $res \ No newline at end of file diff --git a/.github/test-projects/stm32/Cargo.lock b/.github/test-projects/stm32/Cargo.lock index d27cd1b..ab3a283 100644 --- a/.github/test-projects/stm32/Cargo.lock +++ b/.github/test-projects/stm32/Cargo.lock @@ -40,9 +40,21 @@ checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" [[package]] name = "bitflags" -version = "2.6.0" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bxcan" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ac3d0c0a542d0ab5521211f873f62706a7136df415676f676d347e5a41dd80" +dependencies = [ + "bitflags", + "embedded-hal 0.2.7", + "nb 1.1.0", + "vcell", +] [[package]] name = "byteorder" @@ -142,7 +154,8 @@ dependencies = [ [[package]] name = "embassy-embedded-hal" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy?rev=ed3da1721a4f704d3f2a8a1cf84d9fc051c71945#ed3da1721a4f704d3f2a8a1cf84d9fc051c71945" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca4a9380d03e61063067b8239f67d2fa9f108ede7c46b4273804f6b79e59a1d" dependencies = [ "embassy-futures", "embassy-sync", @@ -155,15 +168,43 @@ dependencies = [ "nb 1.1.0", ] +[[package]] +name = "embassy-executor" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f64f84599b0f4296b92a4b6ac2109bc02340094bda47b9766c5f9ec6a318ebf8" +dependencies = [ + "cortex-m", + "critical-section", + "document-features", + "embassy-executor-macros", + "embassy-time-driver", + "embassy-time-queue-driver", +] + +[[package]] +name = "embassy-executor-macros" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3577b1e9446f61381179a330fc5324b01d511624c55f25e3c66c9e3c626dbecf" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.68", +] + [[package]] name = "embassy-futures" version = "0.1.1" -source = "git+https://github.com/embassy-rs/embassy?rev=ed3da1721a4f704d3f2a8a1cf84d9fc051c71945#ed3da1721a4f704d3f2a8a1cf84d9fc051c71945" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f878075b9794c1e4ac788c95b728f26aa6366d32eeb10c7051389f898f7d067" [[package]] name = "embassy-hal-internal" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy?rev=ed3da1721a4f704d3f2a8a1cf84d9fc051c71945#ed3da1721a4f704d3f2a8a1cf84d9fc051c71945" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0ec47cf8bab914018d4bd2b4f0aaeb46e4f52ab1e7985df88aeef2c6eda5aed" dependencies = [ "cortex-m", "critical-section", @@ -173,15 +214,17 @@ dependencies = [ [[package]] name = "embassy-net-driver" version = "0.2.0" -source = "git+https://github.com/embassy-rs/embassy?rev=ed3da1721a4f704d3f2a8a1cf84d9fc051c71945#ed3da1721a4f704d3f2a8a1cf84d9fc051c71945" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524eb3c489760508f71360112bca70f6e53173e6fe48fc5f0efd0f5ab217751d" [[package]] name = "embassy-stm32" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy?rev=ed3da1721a4f704d3f2a8a1cf84d9fc051c71945#ed3da1721a4f704d3f2a8a1cf84d9fc051c71945" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32bc0257b5ade13a1b93e8b9949268f44d57e8ce03e599ef1c5a62024a0fbff9" dependencies = [ "bit_field", - "bitflags", + "bxcan", "cfg-if", "cortex-m", "cortex-m-rt", @@ -195,8 +238,6 @@ dependencies = [ "embassy-time", "embassy-time-driver", "embassy-usb-driver", - "embassy-usb-synopsys-otg", - "embedded-can", "embedded-hal 0.2.7", "embedded-hal 1.0.0", "embedded-hal-async", @@ -205,23 +246,22 @@ dependencies = [ "embedded-io-async", "embedded-storage", "embedded-storage-async", - "futures-util", + "futures", "nb 1.1.0", "proc-macro2", "quote", "rand_core", "sdio-host", - "static_assertions", "stm32-fmc", "stm32-metapac", "vcell", - "volatile-register", ] [[package]] name = "embassy-sync" -version = "0.6.0" -source = "git+https://github.com/embassy-rs/embassy?rev=ed3da1721a4f704d3f2a8a1cf84d9fc051c71945#ed3da1721a4f704d3f2a8a1cf84d9fc051c71945" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd938f25c0798db4280fcd8026bf4c2f48789aebf8f77b6e5cf8a7693ba114ec" dependencies = [ "cfg-if", "critical-section", @@ -232,8 +272,9 @@ dependencies = [ [[package]] name = "embassy-time" -version = "0.3.1" -source = "git+https://github.com/embassy-rs/embassy?rev=ed3da1721a4f704d3f2a8a1cf84d9fc051c71945#ed3da1721a4f704d3f2a8a1cf84d9fc051c71945" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "158080d48f824fad101d7b2fae2d83ac39e3f7a6fa01811034f7ab8ffc6e7309" dependencies = [ "cfg-if", "critical-section", @@ -250,7 +291,8 @@ dependencies = [ [[package]] name = "embassy-time-driver" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy?rev=ed3da1721a4f704d3f2a8a1cf84d9fc051c71945#ed3da1721a4f704d3f2a8a1cf84d9fc051c71945" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e0c214077aaa9206958b16411c157961fb7990d4ea628120a78d1a5a28aed24" dependencies = [ "document-features", ] @@ -258,31 +300,14 @@ dependencies = [ [[package]] name = "embassy-time-queue-driver" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy?rev=ed3da1721a4f704d3f2a8a1cf84d9fc051c71945#ed3da1721a4f704d3f2a8a1cf84d9fc051c71945" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1177859559ebf42cd24ae7ba8fe6ee707489b01d0bf471f8827b7b12dcb0bc0" [[package]] name = "embassy-usb-driver" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy?rev=ed3da1721a4f704d3f2a8a1cf84d9fc051c71945#ed3da1721a4f704d3f2a8a1cf84d9fc051c71945" - -[[package]] -name = "embassy-usb-synopsys-otg" -version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy?rev=ed3da1721a4f704d3f2a8a1cf84d9fc051c71945#ed3da1721a4f704d3f2a8a1cf84d9fc051c71945" -dependencies = [ - "critical-section", - "embassy-sync", - "embassy-usb-driver", -] - -[[package]] -name = "embedded-can" -version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9d2e857f87ac832df68fa498d18ddc679175cf3d2e4aa893988e5601baf9438" -dependencies = [ - "nb 1.1.0", -] +checksum = "4fc247028eae04174b6635104a35b1ed336aabef4654f5e87a8f32327d231970" [[package]] name = "embedded-hal" @@ -351,12 +376,12 @@ dependencies = [ [[package]] name = "embedded-test" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3219cca16cfb5c7e4d3676d884b4533b51e6f5987f181b07d2b0bcffde973790" +version = "0.6.0" dependencies = [ + "embassy-executor", "embedded-test-macros", "heapless 0.8.0", + "log", "semihosting", "serde", "serde-json-core", @@ -364,9 +389,7 @@ dependencies = [ [[package]] name = "embedded-test-macros" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b49686c76a247e8a814281412e0f7a1d146653b529dbbc61a54dbe99aca7d793" +version = "0.6.0" dependencies = [ "darling", "proc-macro2", @@ -380,12 +403,59 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + [[package]] name = "futures-core" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.68", +] + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + [[package]] name = "futures-task" version = "0.3.30" @@ -399,6 +469,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", + "futures-macro", + "futures-sink", "futures-task", "pin-project-lite", "pin-utils", @@ -680,19 +752,15 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "stm32-embedded-test" version = "0.1.0" dependencies = [ "cortex-m", "cortex-m-rt", + "embassy-executor", "embassy-stm32", + "embassy-time", "embedded-test", "log", "panic-probe", @@ -711,7 +779,8 @@ dependencies = [ [[package]] name = "stm32-metapac" version = "15.0.0" -source = "git+https://github.com/embassy-rs/stm32-data-generated?tag=stm32-data-e0cfd165fd8fffaa0df66a35eeca83b228496645#bf02c35d063e1823a156468497b448ae3350a255" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deabea56a8821dcea05d0109f3ab3135f31eb572444e5da203d06149c594c8c6" dependencies = [ "cortex-m", "cortex-m-rt", diff --git a/.github/test-projects/stm32/Cargo.toml b/.github/test-projects/stm32/Cargo.toml index 7360c34..0b4f7ba 100644 --- a/.github/test-projects/stm32/Cargo.toml +++ b/.github/test-projects/stm32/Cargo.toml @@ -10,12 +10,13 @@ cortex-m = { version = "0.7.7", features = ["inline-asm", "critical-section-sing cortex-m-rt = "0.7.3" panic-probe = "0.3" rtt-target = { version = "0.6.1", features = ["log"] } - -embassy-stm32 = { git = "https://github.com/embassy-rs/embassy", rev = "ed3da1721a4f704d3f2a8a1cf84d9fc051c71945", features = ["time-driver-any", "memory-x", "unstable-pac", "exti"] } +embassy-executor = { version = "0.6.3", features = ["arch-cortex-m", "executor-thread", "integrated-timers"] } +embassy-stm32 = { version = "0.1.0", features = ["time-driver-any", "memory-x", "unstable-pac", "exti"] } +embassy-time = "0.3.2" log = "0.4.22" [dev-dependencies] -embedded-test = { version = "0.5.0" } +embedded-test = { path = "../../..", features = ["embassy", "log"] } [[test]] name = "example_test" diff --git a/.github/test-projects/stm32/build.sh b/.github/test-projects/stm32/build.sh index f27e075..c06409b 100755 --- a/.github/test-projects/stm32/build.sh +++ b/.github/test-projects/stm32/build.sh @@ -9,9 +9,11 @@ set -x set -e # to show a possible error in the output -cargo test --target "$2" --features embassy-stm32/"$1" --release --test example_test --no-run +cargo test --locked --target "$2" --features embassy-stm32/"$1" --release --test example_test --no-run # Copy artifact to output directory -exec=$(cargo test --target "$2" --features embassy-stm32/"$1" --release --test example_test --no-run --message-format=json | jq -r 'select(.executable and .target.kind==["test"])|.executable') +exec=$(cargo test --locked --target "$2" --features embassy-stm32/"$1" --release --test example_test --no-run --message-format=json | jq -r 'select(.executable and .target.kind==["test"])|.executable') mkdir -p output -cp "$exec" output/"$1" \ No newline at end of file +cp "$exec" output/"$1" +cp expected_test_results.txt output/ +cp expected_rtt_logs.txt output/ \ No newline at end of file diff --git a/.github/test-projects/stm32/expected_rtt_logs.txt b/.github/test-projects/stm32/expected_rtt_logs.txt new file mode 100644 index 0000000..b9f6699 --- /dev/null +++ b/.github/test-projects/stm32/expected_rtt_logs.txt @@ -0,0 +1,17 @@ +INFO [embedded_test::export] tests available: [Test { name: "test::test", should_panic: false, ignored: false, timeout: None }, Test { name: "test::it_fails1", should_panic: false, ignored: false, timeout: None }, Test { name: "test::it_fails2", should_panic: false, ignored: false, timeout: None }, Test { name: "test::it_passes", should_panic: true, ignored: false, timeout: None }, Test { name: "test::it_fails3", should_panic: true, ignored: false, timeout: None }, Test { name: "test::it_timeouts", should_panic: false, ignored: false, timeout: Some(3) }, Test { name: "test::async_test", should_panic: false, ignored: false, timeout: None }] +INFO [embedded_test::export] Running test: Test { name: "test::test", should_panic: false, ignored: false, timeout: None } +ERROR [example_test::test] Hello, log! +INFO [embedded_test::export] Test exited with () or Ok(..) +INFO [embedded_test::export] Running test: Test { name: "test::it_fails1", should_panic: false, ignored: false, timeout: None } +ERROR [embedded_test] ====================== PANIC ====================== +ERROR [embedded_test] panicked at tests/example_test.rs:22:9: +INFO [embedded_test::export] Running test: Test { name: "test::it_fails2", should_panic: false, ignored: false, timeout: None } +INFO [embedded_test::export] Test exited with Err(..): Err("It failed because ...") +INFO [embedded_test::export] Running test: Test { name: "test::it_passes", should_panic: true, ignored: false, timeout: None } +ERROR [embedded_test] ====================== PANIC ====================== +ERROR [embedded_test] panicked at tests/example_test.rs:33:9: +INFO [embedded_test::export] Running test: Test { name: "test::it_fails3", should_panic: true, ignored: false, timeout: None } +INFO [embedded_test::export] Test exited with () or Ok(..) +INFO [embedded_test::export] Running test: Test { name: "test::it_timeouts", should_panic: false, ignored: false, timeout: Some(3) } +INFO [embedded_test::export] Running test: Test { name: "test::async_test", should_panic: false, ignored: false, timeout: None } +INFO [embedded_test::export] Test exited with () or Ok(..) diff --git a/.github/test-projects/stm32/expected_test_results.txt b/.github/test-projects/stm32/expected_test_results.txt new file mode 100644 index 0000000..8bd7f02 --- /dev/null +++ b/.github/test-projects/stm32/expected_test_results.txt @@ -0,0 +1,16 @@ +{"type":"suite","event":"started","test_count":7} +{"type":"test","event":"started","name":"test::test"} +{"type":"test","name":"test::test","event":"ok"} +{"type":"test","event":"started","name":"test::it_fails1"} +{"type":"test","name":"test::it_fails1","event":"failed","stdout":"Error: \"Test should Pass but it did Panic\"\n"} +{"type":"test","event":"started","name":"test::it_fails2"} +{"type":"test","name":"test::it_fails2","event":"failed","stdout":"Error: \"Test should Pass but it did Panic\"\n"} +{"type":"test","event":"started","name":"test::it_passes"} +{"type":"test","name":"test::it_passes","event":"ok"} +{"type":"test","event":"started","name":"test::it_fails3"} +{"type":"test","name":"test::it_fails3","event":"failed","stdout":"Error: \"Test should Panic but it did Pass\"\n"} +{"type":"test","event":"started","name":"test::it_timeouts"} +{"type":"test","name":"test::it_timeouts","event":"failed","stdout":"Error: \"Test timed out after 3s\"\n"} +{"type":"test","event":"started","name":"test::async_test"} +{"type":"test","name":"test::async_test","event":"ok"} +{"type":"suite","event":"failed","passed":3,"failed":4,"ignored":0,"measured":0,"filtered_out":0} diff --git a/.github/test-projects/stm32/tests/example_test.rs b/.github/test-projects/stm32/tests/example_test.rs index 67f53ae..55678c3 100644 --- a/.github/test-projects/stm32/tests/example_test.rs +++ b/.github/test-projects/stm32/tests/example_test.rs @@ -2,9 +2,9 @@ #![no_main] #[cfg(test)] -#[embedded_test::tests] +#[embedded_test::tests(setup=rtt_target::rtt_init_log!())] mod test { - + use embassy_time::{Duration, Timer}; #[init] fn init() -> () { @@ -13,10 +13,40 @@ mod test { #[test] fn test() { - rtt_target::rtt_init_log!(); log::error!("Hello, log!"); + assert_eq!(1 + 1, 2); + } + #[test] + fn it_fails1() { + assert!(false) + } + #[test] + fn it_fails2() -> Result<(), &'static str> { + Err("It failed because ...") + } + + #[test] + #[should_panic] + fn it_passes() { + assert!(false) + } + + // This test should panic, but doesn't => it fails + #[test] + #[should_panic] + fn it_fails3() {} + + #[test] + #[timeout(3)] + fn it_timeouts() { + loop {} // should run into the 3s timeout + } + + #[test] + async fn async_test() { + Timer::after(Duration::from_millis(100)).await; assert_eq!(1 + 1, 2); } } diff --git a/.github/workflows/smoketest.yml b/.github/workflows/smoketest.yml index 8e420fa..903895a 100644 --- a/.github/workflows/smoketest.yml +++ b/.github/workflows/smoketest.yml @@ -40,7 +40,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: ${{inputs.soc}} - path: .github/test-projects/${{inputs.project}}/output/${{inputs.soc}} + path: .github/test-projects/${{inputs.project}}/output run: runs-on: [ "self-hosted", "linux", "ARM64", "smoke-tester-2" ] @@ -61,6 +61,4 @@ jobs: - name: Run embedded-tests - run: | - ls -lah - python ${ORCHESTRATOR} --target ${{inputs.soc}} --step-executor .github/test-projects/step-executor.sh \ No newline at end of file + run: python ${ORCHESTRATOR} --target ${{inputs.soc}} --step-executor .github/test-projects/step-executor.sh \ No newline at end of file diff --git a/.idea/embedded-test.iml b/.idea/embedded-test.iml index 7520542..fa29e32 100644 --- a/.idea/embedded-test.iml +++ b/.idea/embedded-test.iml @@ -10,10 +10,13 @@ + + +