2021-11-03 20:19:22 +08:00
|
|
|
MCUboot simulator
|
2017-01-10 03:23:09 +08:00
|
|
|
#################
|
|
|
|
|
|
|
|
This is a small simulator designed to exercise the mcuboot upgrade
|
|
|
|
code, specifically testing untimely reset scenarios to make sure the
|
|
|
|
code is robust.
|
|
|
|
|
|
|
|
Prerequisites
|
|
|
|
=============
|
|
|
|
|
|
|
|
The simulator is written in Rust_, and you will need to install it to
|
|
|
|
build it. The installation_ page describes this process. The
|
|
|
|
simulator can be built with the stable release of Rust.
|
|
|
|
|
|
|
|
.. _Rust: https://www.rust-lang.org/
|
|
|
|
|
|
|
|
.. _installation: https://www.rust-lang.org/en-US/install.html
|
|
|
|
|
2017-07-21 22:28:28 +08:00
|
|
|
Dependent code
|
|
|
|
--------------
|
|
|
|
|
|
|
|
The simulator depends on some external modules. These are stored as
|
|
|
|
submodules within git. To fetch these dependencies the first time::
|
|
|
|
|
2020-05-12 04:08:53 +08:00
|
|
|
$ git submodule update --init --recursive
|
2017-07-21 22:28:28 +08:00
|
|
|
|
|
|
|
will clone and check out these trees in the appropriate place.
|
|
|
|
|
2017-11-07 15:42:09 +08:00
|
|
|
Testing
|
|
|
|
=======
|
2017-01-10 03:23:09 +08:00
|
|
|
|
2017-11-07 15:42:09 +08:00
|
|
|
The tests are written as unit tests in Rust, and can be built and run
|
|
|
|
automatically::
|
2017-01-10 03:23:09 +08:00
|
|
|
|
2017-11-07 15:42:09 +08:00
|
|
|
$ cargo test
|
2017-01-10 03:23:09 +08:00
|
|
|
|
|
|
|
this should download and compile the necessary dependencies, compile
|
2017-11-07 15:42:09 +08:00
|
|
|
the relevant modules from mcuboot, build the simulator, and run the
|
|
|
|
tests.
|
2017-01-10 03:23:09 +08:00
|
|
|
|
2018-04-26 05:22:55 +08:00
|
|
|
There are several different features you can test. For example,
|
|
|
|
testing RSA signatures can be done with::
|
|
|
|
|
|
|
|
$ cargo test --features sig-rsa
|
|
|
|
|
|
|
|
For a complete list of features, see Cargo.toml.
|
|
|
|
|
2017-01-10 03:23:09 +08:00
|
|
|
Debugging
|
|
|
|
=========
|
|
|
|
|
|
|
|
If the simulator indicates a failure, you can turn on additional
|
|
|
|
logging by setting ``RUST_LOG=warn`` or ``RUST_LOG=error`` in the
|
|
|
|
environment::
|
|
|
|
|
|
|
|
$ RUST_LOG=warn ./target/release/bootsim run ...
|
2017-11-07 15:42:09 +08:00
|
|
|
|
|
|
|
It is also possible to run specific tests, for example::
|
|
|
|
|
|
|
|
$ cargo test -- basic_revert
|
|
|
|
|
|
|
|
which will run only the `basic_revert` test.
|