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

User mode testing example #57

Merged
merged 1 commit into from
Dec 13, 2024
Merged

User mode testing example #57

merged 1 commit into from
Dec 13, 2024

Conversation

swenson
Copy link
Collaborator

@swenson swenson commented Dec 12, 2024

Reworked the example Tock user mode app to support running both in RISC-V in the emulator as well as using the libtock_unittest's fake kernel. I also moved the executor and TockSubscribe impl Future into a common crate, libtockasync, to make it easier to use from other libraries and apps.

This allows us test directly from the host without the emulator:

cargo t -p example-app

And to run the app directly:

cargo run --bin example-app

This should make it much easier to develop and test apps with a rapid development cycle.

I added some simple tests to demonstrate how to test the async code. It's a little tricky since the fake kernel and the Embassy executor need to be in the same lexical scope as the test so that they don't get dropped and cause a segfault.

A future TODO is to have integration tests using the real Tock kernel using a similar framework to tests/integration for our Tock code.

Reworked the example Tock user mode app to support running both in
RISC-V in the emulator as well as using the `libtock_unittest`'s fake
kernel. I also moved the executor and `TockSubscribe` `impl Future` into
a common crate, `libtockasync`, to make it easier to use from other
libraries and apps.

This allows us test directly from the host without the emulator:

```shell
cargo t -p example-app
```

And to run the app directly:
```shell
cargo run --bin example-app
```

This should make it much easier to develop and test apps with a rapid
development cycle.

I added some simple tests to demonstrate how to test the async code.
It's a little tricky since the fake kernel and the Embassy executor need
to be in the same lexical scope as the test so that they don't get
dropped and cause a segfault.

A future TODO is to have integration tests using the real Tock kernel
using a similar framework to `tests/integration` for our Tock code.
Copy link
Collaborator

@mlvisaya mlvisaya 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
Collaborator

@parvathib parvathib left a comment

Choose a reason for hiding this comment

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

LGTMToo!

@swenson
Copy link
Collaborator Author

swenson commented Dec 13, 2024

Thanks!

@swenson swenson merged commit de7af76 into main Dec 13, 2024
1 check passed
@swenson swenson deleted the user-mode-testing branch December 13, 2024 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants