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 | e513324 | 2019-02-28 11:05:19 -0700 | [diff] [blame] | 5 | use bootsim::{ImagesBuilder, 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 { |
David Brown | eebf502 | 2019-07-30 15:01:07 -0600 | [diff] [blame^] | 8 | ($name:ident, $maker:ident($($margs:expr),*), $test:ident($($targs:expr),*)) => { |
David Brown | a4167ef | 2017-11-06 14:30:05 -0700 | [diff] [blame] | 9 | #[test] |
| 10 | fn $name() { |
| 11 | testlog::setup(); |
David Brown | ca7b5d3 | 2017-11-03 08:37:38 -0600 | [diff] [blame] | 12 | |
David Brown | e513324 | 2019-02-28 11:05:19 -0700 | [diff] [blame] | 13 | ImagesBuilder::each_device(|r| { |
David Brown | eebf502 | 2019-07-30 15:01:07 -0600 | [diff] [blame^] | 14 | let image = r.$maker($($margs),*); |
| 15 | assert!(!image.$test($($targs),*)); |
David Brown | a4167ef | 2017-11-06 14:30:05 -0700 | [diff] [blame] | 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 Brown | eebf502 | 2019-07-30 15:01:07 -0600 | [diff] [blame^] | 21 | sim_test!(bad_secondary_slot, make_bad_secondary_slot_image(), run_signfail_upgrade()); |
| 22 | sim_test!(norevert_newimage, make_no_upgrade_image(), run_norevert_newimage()); |
| 23 | sim_test!(basic_revert, make_image(true), run_basic_revert()); |
| 24 | sim_test!(revert_with_fails, make_image(false), run_revert_with_fails()); |
| 25 | sim_test!(perm_with_fails, make_image(true), run_perm_with_fails()); |
| 26 | sim_test!(perm_with_random_fails, make_image(true), run_perm_with_random_fails(5)); |
| 27 | sim_test!(norevert, make_image(true), run_norevert()); |
| 28 | sim_test!(status_write_fails_complete, make_image(true), run_with_status_fails_complete()); |
| 29 | sim_test!(status_write_fails_with_reset, make_image(true), run_with_status_fails_with_reset()); |