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 HIL testing #1297

Merged
merged 45 commits into from
Mar 21, 2024
Merged

Add HIL testing #1297

merged 45 commits into from
Mar 21, 2024

Conversation

SergioGasquez
Copy link
Member

@SergioGasquez SergioGasquez commented Mar 15, 2024

This PR adds the foundations for HIL, It's still in an early phase and might be draft for a while or get merged and get some follow-up PRs.

See the workflow runs in https://github.com/esp-rs/esp-hal/actions/workflows/hil.yml

For instructions on how the testing works, see the hil-test readme

Current board support

Current tests

Todo

Please, feel free to report any feedback or input that you have!

hil-test/src/lib.rs Outdated Show resolved Hide resolved
hil-test/tests/aes.rs Show resolved Hide resolved
hil-test/README.md Outdated Show resolved Hide resolved
hil-test/tests/spi_full_duplex.rs Outdated Show resolved Hide resolved
@SergioGasquez
Copy link
Member Author

Just pushed 700a86b which shows a way to configure away tests of peripherals for targets that dont support that peripheral. Not an ideal solution imo, but couldn't find any other way (thanks @t-moe for the suggestion)

hil-test/.cargo/config.toml Outdated Show resolved Hide resolved
hil-test/.cargo/config.toml Outdated Show resolved Hide resolved
Copy link
Member

@jessebraham jessebraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, especially for our first iteration, this is looking really good! Thank you so much for all your work here, this is a huge win for us.

We should probably expand the section in README.md regarding adding tests, but that is absolutely beyond this scope of this PR and can be tackled separately.

So I'll say LGTM, but let's wait for confirmation from @MabezDev and/or @bjoernQ as well :)

@jessebraham
Copy link
Member

jessebraham commented Mar 20, 2024

Also I guess we will need to wait until this is merged until we can add the relevant jobs to the required merge queue checks, so HIL will probably not run when this is merged (but will for the next PR)?

Just kidding I see them, I guess because the branch belongs to this repo. So I will add them as soon as I'm ready to merge!

@SergioGasquez SergioGasquez force-pushed the feat/hil-testing branch 5 times, most recently from 593a0cc to 1e6c16f Compare March 21, 2024 09:26
@SergioGasquez
Copy link
Member Author

Sorry for adding late changes.

  • I stole the alias idea and implemented it here to have a simple way of running all the tests for a target
  • Pinned the moving dependencies (semihosting, embedded-test and probe-rs)
  • Updated the README

After the pinning/alias changes, I ran the CI to verify that everything was working, here is the run https://github.com/esp-rs/esp-hal/actions/runs/8372136967 (I amended the commit and removed the push trigger of the workflow afterward)

Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ❤️

Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @SergioGasquez!

@jessebraham jessebraham added this pull request to the merge queue Mar 21, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 21, 2024
@SergioGasquez
Copy link
Member Author

SergioGasquez commented Mar 21, 2024

Just tested all the targets locally:

  • ESP32C3:
Results
❯ cargo esp32c3
warning: method `into_result` is never used
   --> /home/sergio/Documents/Espressif/esp-rs/esp-hal/esp-hal/src/fmt.rs:204:8
    |
201 | pub trait Try {
    |           --- method in this trait
...
204 |     fn into_result(self) -> Result<Self::Ok, Self::Error>;
    |        ^^^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

warning: `esp-hal` (lib) generated 1 warning
    Finished `release` profile [optimized + debuginfo] target(s) in 0.06s
     Running tests/aes.rs (target/riscv32imc-unknown-none-elf/release/deps/aes-40fe1a1875ed0f4c)
      Erasing ✔ [00:00:00] [#####################################################################################################################################################################################] 192.00 KiB/192.00 KiB @ 239.08 KiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 35.52 KiB/35.52 KiB @ 64.83 KiB/s (eta 0s )    Finished in 1.363s

running 2 tests
test tests::test_aes_encryption ... ok
test tests::test_aes_decryption ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.87s

     Running tests/gpio.rs (target/riscv32imc-unknown-none-elf/release/deps/gpio-3ace83cd88ceff7c)
      Erasing ✔ [00:00:00] [#####################################################################################################################################################################################] 192.00 KiB/192.00 KiB @ 238.35 KiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 35.26 KiB/35.26 KiB @ 64.59 KiB/s (eta 0s )    Finished in 1.363s

running 2 tests
test tests::test_gpio_input  ... ok
test tests::test_gpio_output ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.86s

     Running tests/spi_full_duplex.rs (target/riscv32imc-unknown-none-elf/release/deps/spi_full_duplex-28d01ab612584813)
      Erasing ✔ [00:00:00] [#####################################################################################################################################################################################] 192.00 KiB/192.00 KiB @ 240.25 KiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 37.06 KiB/37.06 KiB @ 66.70 KiB/s (eta 0s )    Finished in 1.367s

running 4 tests
test tests::test_symestric_transfer                      ... ok
test tests::test_asymestric_transfer                     ... ok
test tests::test_symestric_transfer_huge_buffer          ... ok
test tests::test_symestric_transfer_huge_buffer_no_alloc ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.72s

     Running tests/uart.rs (target/riscv32imc-unknown-none-elf/release/deps/uart-12ebab303e43539b)
      Erasing ✔ [00:00:00] [#####################################################################################################################################################################################] 192.00 KiB/192.00 KiB @ 236.60 KiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 35.19 KiB/35.19 KiB @ 64.28 KiB/s (eta 0s )    Finished in 1.37s

running 1 test
test tests::test_send_receive ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.44s
  • ESP32-C6:
Results
   Compiling hil-test v0.0.0 (/home/sergio/Documents/Espressif/esp-rs/esp-hal/hil-test)
    Finished `release` profile [optimized + debuginfo] target(s) in 6.21s
     Running tests/aes.rs (target/riscv32imac-unknown-none-elf/release/deps/aes-79d2fe8d6b7de728)
      Erasing ✔ [00:00:00] [#####################################################################################################################################################################################] 128.00 KiB/128.00 KiB @ 634.74 KiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 36.33 KiB/36.33 KiB @ 96.69 KiB/s (eta 0s )    Finished in 0.589s

running 2 tests
test tests::test_aes_encryption ... ok
test tests::test_aes_decryption ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.86s

     Running tests/gpio.rs (target/riscv32imac-unknown-none-elf/release/deps/gpio-92410ef5e9f8728d)
      Erasing ✔ [00:00:00] [#####################################################################################################################################################################################] 128.00 KiB/128.00 KiB @ 646.24 KiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 36.06 KiB/36.06 KiB @ 96.54 KiB/s (eta 0s )    Finished in 0.583s

running 2 tests
test tests::test_gpio_input  ... ok
test tests::test_gpio_output ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.86s

     Running tests/spi_full_duplex.rs (target/riscv32imac-unknown-none-elf/release/deps/spi_full_duplex-5f2314b91cd414c3)
      Erasing ✔ [00:00:00] [#####################################################################################################################################################################################] 128.00 KiB/128.00 KiB @ 649.48 KiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 37.98 KiB/37.98 KiB @ 97.06 KiB/s (eta 0s )    Finished in 0.6s

running 4 tests
test tests::test_symestric_transfer                      ... ok
test tests::test_asymestric_transfer                     ... ok
test tests::test_symestric_transfer_huge_buffer          ... ok
test tests::test_symestric_transfer_huge_buffer_no_alloc ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.71s

     Running tests/uart.rs (target/riscv32imac-unknown-none-elf/release/deps/uart-456906ed79152f2a)
      Erasing ✔ [00:00:00] [#####################################################################################################################################################################################] 128.00 KiB/128.00 KiB @ 653.25 KiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 36.02 KiB/36.02 KiB @ 96.73 KiB/s (eta 0s )    Finished in 0.579s

running 1 test
test tests::test_send_receive ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.43s
  • ESP32-H2:
Results
   Compiling hil-test v0.0.0 (/home/sergio/Documents/Espressif/esp-rs/esp-hal/hil-test)
    Finished `release` profile [optimized + debuginfo] target(s) in 9.01s
     Running tests/aes.rs (target/riscv32imac-unknown-none-elf/release/deps/aes-de854d1506d0a923)
      Erasing ✔ [00:00:00] [#######################################################################################################################################################################################] 192.00 KiB/192.00 KiB @ 1.03 MiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 35.34 KiB/35.34 KiB @ 67.38 KiB/s (eta 0s )    Finished in 0.718s

running 2 tests
test tests::test_aes_encryption ... ok
test tests::test_aes_decryption ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.86s

     Running tests/gpio.rs (target/riscv32imac-unknown-none-elf/release/deps/gpio-46b476d876631f56)
      Erasing ✔ [00:00:00] [####################################################################################################################################################################################] 192.00 KiB/192.00 KiB @ 1018.32 KiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 35.06 KiB/35.06 KiB @ 66.54 KiB/s (eta 0s )    Finished in 0.727s

running 2 tests
test tests::test_gpio_input  ... ok
test tests::test_gpio_output ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.86s

     Running tests/spi_full_duplex.rs (target/riscv32imac-unknown-none-elf/release/deps/spi_full_duplex-2b0143ea09f9469e)
      Erasing ✔ [00:00:00] [#######################################################################################################################################################################################] 192.00 KiB/192.00 KiB @ 1.00 MiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 37.05 KiB/37.05 KiB @ 66.30 KiB/s (eta 0s )    Finished in 0.758s

running 4 tests
test tests::test_symestric_transfer                      ... ok
test tests::test_asymestric_transfer                     ... ok
test tests::test_symestric_transfer_huge_buffer          ... ok
test tests::test_symestric_transfer_huge_buffer_no_alloc ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.71s

     Running tests/uart.rs (target/riscv32imac-unknown-none-elf/release/deps/uart-1ce1290e074c134a)
      Erasing ✔ [00:00:00] [#######################################################################################################################################################################################] 192.00 KiB/192.00 KiB @ 1.01 MiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 35.01 KiB/35.01 KiB @ 66.46 KiB/s (eta 0s )    Finished in 0.723s

running 1 test
test tests::test_send_receive ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.43s
  • ESP32-S3:
Results
   Compiling hil-test v0.0.0 (/home/sergio/Documents/Espressif/esp-rs/esp-hal/hil-test)
    Finished release [optimized + debuginfo] target(s) in 18.56s
     Running tests/aes.rs (target/xtensa-esp32s3-none-elf/release/deps/aes-e68628e057fe0ffb)
      Erasing ✔ [00:00:00] [#####################################################################################################################################################################################] 192.00 KiB/192.00 KiB @ 336.62 KiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 39.93 KiB/39.93 KiB @ 58.32 KiB/s (eta 0s )    Finished in 1.268s

running 2 tests
test tests::test_aes_encryption ... ok
test tests::test_aes_decryption ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.84s

     Running tests/gpio.rs (target/xtensa-esp32s3-none-elf/release/deps/gpio-e3b788197b823785)
      Erasing ✔ [00:00:00] [#####################################################################################################################################################################################] 192.00 KiB/192.00 KiB @ 333.05 KiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 39.64 KiB/39.64 KiB @ 58.17 KiB/s (eta 0s )    Finished in 1.27s

running 2 tests
test tests::test_gpio_input  ... ok
test tests::test_gpio_output ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.85s

     Running tests/spi_full_duplex.rs (target/xtensa-esp32s3-none-elf/release/deps/spi_full_duplex-737c4179a9571d7f)
      Erasing ✔ [00:00:00] [#####################################################################################################################################################################################] 192.00 KiB/192.00 KiB @ 333.78 KiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 41.73 KiB/41.73 KiB @ 59.56 KiB/s (eta 0s )    Finished in 1.289s

running 4 tests
test tests::test_symestric_transfer                      ... ok
test tests::test_asymestric_transfer                     ... ok
test tests::test_symestric_transfer_huge_buffer          ... ok
test tests::test_symestric_transfer_huge_buffer_no_alloc ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.69s

     Running tests/uart.rs (target/xtensa-esp32s3-none-elf/release/deps/uart-0c3c6e9f8846253d)
      Erasing ✔ [00:00:00] [#####################################################################################################################################################################################] 192.00 KiB/192.00 KiB @ 331.86 KiB/s (eta 0s )
  Programming ✔ [00:00:00] [########################################################################################################################################################################################] 39.71 KiB/39.71 KiB @ 58.35 KiB/s (eta 0s )    Finished in 1.272s

running 1 test
test tests::test_send_receive ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.42s

@jessebraham jessebraham added this pull request to the merge queue Mar 21, 2024
Merged via the queue into main with commit baea915 Mar 21, 2024
17 checks passed
@SergioGasquez SergioGasquez deleted the feat/hil-testing branch March 21, 2024 14:55
yanshay pushed a commit to yanshay/esp-hal that referenced this pull request Mar 25, 2024
* Create the `hil-test` package

* Add a simple integration test to verify basic GPIO functionality

* WIP

* feat: Update with esp-hal unification

* build: Update dependencies

* feat: Add a simple CI workflow test

* ci: Avoid using a gh-hosted-runner to build

* ci: Remove building bins in gh-hosted-runner

* ci: Remove HIL Gpio CI test

* ci: Test all the available tests

* test: Add spi_full_duplex test

* docs: Add documentation

* test: Add uart test

* style: Remove unused imports

* docs: Update wiring, document H2 VM

* ci: Enable H2 tests

* ci: Add rust-cache action

* docs: Document H2 vm

* test: Add timeout

* ci: Enable ESP32-C3 tests

* feat: Add timeouts

* feat: Add aes test

* ci: Avoid running CI workflow when we change hil-test stuff

* test: Remove warnings

* feat: Address feedback

* feat: Update features names and spi methods

* ci: Remove rust-cache action

* Update HIL to probe-rs#2292 (esp-rs#1307)

* feat: Update probe-rs/embedded-test to probe-rs#2292

* feat: Remove lib

* ci: Use a matrix

* ci: Enable ESP32C3

* feat: Add a way to cfg away test for unsuported peripherals

* ci: Update trigger conditions

* feat: Update pins to make it work on s3

* feat: Changes enabling S3

* feat: Remove log feature

* feat: Adapt for rebase

* feat: Remove env

* feat: enable S3

* chore: Remove todo

* build: Pin dependencies

* feat: Add target alias

* docs: Update readme

* fix: Fix traits imports after rebase. Use debug

* build: Remove lto

* feat: Build tests on release mode

---------

Co-authored-by: Jesse Braham <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog No changelog modification needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants