Expand description
Interface for running capsule tests.
As Tock capsules are asynchronous, it is difficult for a test runner to
determine when a test has finished. This interface provides a done()
callback used by the test implementation to notify when the test has
completed.
A simple example of a test capsule using this interface:
ⓘ
pub struct TestSensorX {
client: OptionalCell<&'static dyn CapsuleTestClient>,
}
impl TestSensorX {
pub fn new() -> Self {
TestHmacSha256 {
client: OptionalCell::empty(),
}
}
}
impl CapsuleTest for TestSensorX {
fn set_client(&self, client: &'static dyn CapsuleTestClient) {
self.client.set(client);
}
}
impl AsyncClient for TestSensorX {
fn operation_complete(&self) {
// Test has finished at this point.
self.client.map(|client| {
client.done(Ok(()));
});
}
}
Enums§
- Errors for the result of a failed test.
Traits§
- Identify a test as a capsule test. This is only used for setting the client for test complete callbacks.
- Client for receiving test done events.