mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
rust/pv*: Unit test flag parsing
Add a unit test for flag parsing. In order to ease this test, add derive Eq to ControlFlags and Msb0Flags64. For the same test, add derive Default to CreateBootImageArgs and the structs used in it. The latter can be limited to only derive when testing to avoid confusion with any user-level default. Acked-by: Steffen Eiden <seiden@linux.ibm.com> Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Jakob Naucke <naucke@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
ec10654c35
commit
efdadfcdb9
@@ -213,3 +213,25 @@ pub fn create(opt: &CreateBootImageArgs) -> Result<OwnExitCode> {
|
||||
warn!("Successfully generated the Secure Execution image.");
|
||||
Ok(OwnExitCode::Success)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::cli::CreateBootImageLegacyFlags;
|
||||
|
||||
#[test]
|
||||
fn parse_flags() {
|
||||
let args = CreateBootImageArgs {
|
||||
legacy_flags: CreateBootImageLegacyFlags {
|
||||
enable_dump: Some(true),
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
let parsed_flags = super::parse_flags(&args).expect("Failed to parse flags {args:?}");
|
||||
let mut exp_flags = Vec::from(PlaintextControlFlagsV1::PCKMO);
|
||||
exp_flags.push(PcfV1::AllowDumping);
|
||||
let pcf = PlaintextControlFlagsV1::from_flags(PcfV1::all_enabled(exp_flags));
|
||||
assert_eq!(parsed_flags.0, pcf);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user