-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command to read the VPD lock state
The lock information is returned as an array of trailing data.
- Loading branch information
Showing
9 changed files
with
176 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ mod v07; | |
mod v08; | ||
mod v09; | ||
mod v10; | ||
mod v11; | ||
|
||
pub fn assert_serialized( | ||
out: &mut [u8], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
//! The tests in this module check that the serialized form of messages from MGS | ||
//! protocol version 11 have not changed. | ||
//! | ||
//! If a test in this module fails, _do not change the test_! This means you | ||
//! have changed, deleted, or reordered an existing message type or enum | ||
//! variant, and you should revert that change. This will remain true until we | ||
//! bump the `version::MIN` to a value higher than 11, at which point these | ||
//! tests can be removed as we will stop supporting v11. | ||
|
||
use super::assert_serialized; | ||
use gateway_messages::MgsRequest; | ||
use gateway_messages::SerializedSize; | ||
use gateway_messages::SpError; | ||
use gateway_messages::SpResponse; | ||
use gateway_messages::VpdError; | ||
|
||
#[test] | ||
fn sp_response() { | ||
let mut out = [0; SpResponse::MAX_SIZE]; | ||
let response = SpResponse::VpdLockState; | ||
let expected = [41]; | ||
assert_serialized(&mut out, &expected, &response); | ||
} | ||
|
||
#[test] | ||
fn host_request() { | ||
let mut out = [0; MgsRequest::MAX_SIZE]; | ||
let request = MgsRequest::VpdLockState; | ||
let expected = [41]; | ||
assert_serialized(&mut out, &expected, &request); | ||
} | ||
|
||
#[test] | ||
fn vpd_protocol_errors() { | ||
let mut out = [0; MgsRequest::MAX_SIZE]; | ||
|
||
for (error, serialized) in [ | ||
(VpdError::InvalidDevice, &[0]), | ||
(VpdError::NotPresent, &[1]), | ||
(VpdError::DeviceError, &[2]), | ||
(VpdError::Unavailable, &[3]), | ||
(VpdError::DeviceTimeout, &[4]), | ||
(VpdError::DeviceOff, &[5]), | ||
(VpdError::BadAddress, &[6]), | ||
(VpdError::BadBuffer, &[7]), | ||
(VpdError::BadRead, &[8]), | ||
(VpdError::BadWrite, &[9]), | ||
(VpdError::BadLock, &[10]), | ||
(VpdError::NotImplemented, &[11]), | ||
(VpdError::IsLocked, &[12]), | ||
(VpdError::PartiallyLocked, &[13]), | ||
(VpdError::AlreadyLocked, &[14]), | ||
(VpdError::TaskRestarted, &[15]), | ||
] { | ||
// Test VpdError variants encoded in an SpResponse | ||
let response = SpResponse::Error(SpError::Vpd(error)); | ||
let mut expected = vec![17, 34]; | ||
expected.extend_from_slice(serialized); | ||
assert_serialized(&mut out, &expected, &response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters