David Brown | 841d73a | 2017-01-09 12:23:09 -0700 | [diff] [blame] | 1 | MCUboot Simulator |
| 2 | ################# |
| 3 | |
| 4 | This is a small simulator designed to exercise the mcuboot upgrade |
| 5 | code, specifically testing untimely reset scenarios to make sure the |
| 6 | code is robust. |
| 7 | |
| 8 | Prerequisites |
| 9 | ============= |
| 10 | |
| 11 | The simulator is written in Rust_, and you will need to install it to |
| 12 | build it. The installation_ page describes this process. The |
| 13 | simulator can be built with the stable release of Rust. |
| 14 | |
| 15 | .. _Rust: https://www.rust-lang.org/ |
| 16 | |
| 17 | .. _installation: https://www.rust-lang.org/en-US/install.html |
| 18 | |
David Brown | 9600ec8 | 2017-07-21 08:28:28 -0600 | [diff] [blame] | 19 | Dependent code |
| 20 | -------------- |
| 21 | |
| 22 | The simulator depends on some external modules. These are stored as |
| 23 | submodules within git. To fetch these dependencies the first time:: |
| 24 | |
David Brown | a3a96fe | 2020-05-11 14:08:53 -0600 | [diff] [blame] | 25 | $ git submodule update --init --recursive |
David Brown | 9600ec8 | 2017-07-21 08:28:28 -0600 | [diff] [blame] | 26 | |
| 27 | will clone and check out these trees in the appropriate place. |
| 28 | |
David Brown | da21ad7 | 2017-11-07 00:42:09 -0700 | [diff] [blame] | 29 | Testing |
| 30 | ======= |
David Brown | 841d73a | 2017-01-09 12:23:09 -0700 | [diff] [blame] | 31 | |
David Brown | da21ad7 | 2017-11-07 00:42:09 -0700 | [diff] [blame] | 32 | The tests are written as unit tests in Rust, and can be built and run |
| 33 | automatically:: |
David Brown | 841d73a | 2017-01-09 12:23:09 -0700 | [diff] [blame] | 34 | |
David Brown | da21ad7 | 2017-11-07 00:42:09 -0700 | [diff] [blame] | 35 | $ cargo test |
David Brown | 841d73a | 2017-01-09 12:23:09 -0700 | [diff] [blame] | 36 | |
| 37 | this should download and compile the necessary dependencies, compile |
David Brown | da21ad7 | 2017-11-07 00:42:09 -0700 | [diff] [blame] | 38 | the relevant modules from mcuboot, build the simulator, and run the |
| 39 | tests. |
David Brown | 841d73a | 2017-01-09 12:23:09 -0700 | [diff] [blame] | 40 | |
Marti Bolivar | 4ec7f76 | 2018-04-25 17:22:55 -0400 | [diff] [blame] | 41 | There are several different features you can test. For example, |
| 42 | testing RSA signatures can be done with:: |
| 43 | |
| 44 | $ cargo test --features sig-rsa |
| 45 | |
| 46 | For a complete list of features, see Cargo.toml. |
| 47 | |
David Brown | 841d73a | 2017-01-09 12:23:09 -0700 | [diff] [blame] | 48 | Debugging |
| 49 | ========= |
| 50 | |
| 51 | If the simulator indicates a failure, you can turn on additional |
| 52 | logging by setting ``RUST_LOG=warn`` or ``RUST_LOG=error`` in the |
| 53 | environment:: |
| 54 | |
| 55 | $ RUST_LOG=warn ./target/release/bootsim run ... |
David Brown | da21ad7 | 2017-11-07 00:42:09 -0700 | [diff] [blame] | 56 | |
| 57 | It is also possible to run specific tests, for example:: |
| 58 | |
| 59 | $ cargo test -- basic_revert |
| 60 | |
| 61 | which will run only the `basic_revert` test. |