diff options
| author | Robin Krahl <robin.krahl@ireas.org> | 2020-01-14 16:15:40 +0100 | 
|---|---|---|
| committer | Robin Krahl <robin.krahl@ireas.org> | 2020-01-14 16:53:52 +0100 | 
| commit | 2e543445c3059fa9decdbef718caf84696bb8786 (patch) | |
| tree | 1e4af2a6a12e587d3c84756eeb592504ecc4c4f1 /tests | |
| parent | f266ea63039c87886f871b068ef3dcdf851a1eca (diff) | |
| download | nitrokey-rs-2e543445c3059fa9decdbef718caf84696bb8786.tar.gz nitrokey-rs-2e543445c3059fa9decdbef718caf84696bb8786.tar.bz2 | |
Add the fill_sd_card function to Storage
This patch adds support for libnitrokey’s
NK_fill_SD_card_with_random_data function.  It is executed by the
fill_sd_card function of the Storage struct.  We also add a new test
case that is set to ignore because it takes between 30 and 60 minutes to
run.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/device.rs | 39 | 
1 files changed, 39 insertions, 0 deletions
| diff --git a/tests/device.rs b/tests/device.rs index 7296372..a88c956 100644 --- a/tests/device.rs +++ b/tests/device.rs @@ -653,6 +653,45 @@ fn get_operation_status(device: Storage) {  }  #[test_device] +#[ignore] +fn fill_sd_card(device: Storage) { +    // This test takes up to 60 min to execute and is therefore ignored by default.  Use `cargo +    // test -- --ignored fill_sd_card` to run the test. + +    let mut device = device; +    assert_ok!((), device.factory_reset(DEFAULT_ADMIN_PIN)); +    thread::sleep(time::Duration::from_secs(3)); +    assert_ok!((), device.build_aes_key(DEFAULT_ADMIN_PIN)); + +    let status = unwrap_ok!(device.get_storage_status()); +    assert!(!status.filled_with_random); + +    assert_ok!((), device.fill_sd_card(DEFAULT_ADMIN_PIN)); +    assert_cmd_err!(CommandError::WrongCrc, device.get_status()); + +    let mut status = OperationStatus::Ongoing(0); +    let mut last_progress = 0u8; +    while status != OperationStatus::Idle { +        status = unwrap_ok!(device.get_operation_status()); +        if let OperationStatus::Ongoing(progress) = status { +            assert!(progress <= 100, "progress = {}", progress); +            assert!( +                progress >= last_progress, +                "progress = {}, last_progress = {}", +                progress, +                last_progress +            ); +            last_progress = progress; + +            thread::sleep(time::Duration::from_secs(10)); +        } +    } + +    let status = unwrap_ok!(device.get_storage_status()); +    assert!(status.filled_with_random); +} + +#[test_device]  fn export_firmware(device: Storage) {      let mut device = device;      assert_cmd_err!( | 
