David Brown | dd2b118 | 2017-11-02 15:39:21 -0600 | [diff] [blame] | 1 | //! Core tests |
| 2 | //! |
| 3 | //! Run the existing testsuite as a Rust unit test. |
| 4 | |
David Brown | a4167ef | 2017-11-06 14:30:05 -0700 | [diff] [blame] | 5 | use bootsim::{Run, testlog}; |
David Brown | dd2b118 | 2017-11-02 15:39:21 -0600 | [diff] [blame] | 6 | |
David Brown | a4167ef | 2017-11-06 14:30:05 -0700 | [diff] [blame] | 7 | macro_rules! sim_test { |
| 8 | ($name:ident, $maker:ident, $test:ident) => { |
| 9 | #[test] |
| 10 | fn $name() { |
| 11 | testlog::setup(); |
David Brown | ca7b5d3 | 2017-11-03 08:37:38 -0600 | [diff] [blame] | 12 | |
David Brown | a4167ef | 2017-11-06 14:30:05 -0700 | [diff] [blame] | 13 | Run::each_device(|r| { |
| 14 | let image = r.$maker(); |
| 15 | assert!(!image.$test()); |
| 16 | }); |
David Brown | dd2b118 | 2017-11-02 15:39:21 -0600 | [diff] [blame] | 17 | } |
David Brown | a4167ef | 2017-11-06 14:30:05 -0700 | [diff] [blame] | 18 | }; |
David Brown | dd2b118 | 2017-11-02 15:39:21 -0600 | [diff] [blame] | 19 | } |
David Brown | a4167ef | 2017-11-06 14:30:05 -0700 | [diff] [blame] | 20 | |
David Vincze | 2d736ad | 2019-02-18 11:50:22 +0100 | [diff] [blame^] | 21 | sim_test!(bad_secondary_slot, make_bad_secondary_slot_image, run_signfail_upgrade); |
David Brown | a4167ef | 2017-11-06 14:30:05 -0700 | [diff] [blame] | 22 | sim_test!(norevert_newimage, make_no_upgrade_image, run_norevert_newimage); |
| 23 | sim_test!(basic_revert, make_image, run_basic_revert); |
| 24 | sim_test!(revert_with_fails, make_image, run_revert_with_fails); |
| 25 | sim_test!(perm_with_fails, make_image, run_perm_with_fails); |
| 26 | sim_test!(perm_with_random_fails, make_image, run_perm_with_random_fails_5); |
| 27 | sim_test!(norevert, make_image, run_norevert); |
Fabio Utzig | b841f0a | 2017-11-24 08:11:05 -0200 | [diff] [blame] | 28 | sim_test!(status_write_fails_complete, make_image, run_with_status_fails_complete); |
Fabio Utzig | eedcc45 | 2017-11-24 10:48:52 -0200 | [diff] [blame] | 29 | sim_test!(status_write_fails_with_reset, make_image, run_with_status_fails_with_reset); |