From 7bf96fea60f84386d24ded8810826a94a766035b Mon Sep 17 00:00:00 2001 From: Keiichi Watanabe Date: Tue, 26 Nov 2024 18:08:25 +0900 Subject: [PATCH] arch: serial: Use default values in SerialParameters for tests Use Default::default() to initialize SeralParameters structs in unit tests so it's clearer what fields are checked in each test. Also, it allow avoiding updating these tests when we add a new field in the struct in the future. BUG=none TEST=CQ Change-Id: Id550703676a7d2273956585358ac70a3e28ffeee Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/6048597 Commit-Queue: Daniel Verkamp Reviewed-by: Daniel Verkamp Auto-Submit: Keiichi Watanabe --- arch/src/serial.rs | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/arch/src/serial.rs b/arch/src/serial.rs index 09bbf38555..bfd897ba96 100644 --- a/arch/src/serial.rs +++ b/arch/src/serial.rs @@ -291,16 +291,10 @@ mod tests { SerialParameters { type_: SerialType::Stdout, hardware: SerialHardware::VirtioConsole, - name: None, - path: None, - input: None, num: 1, console: true, - earlycon: false, stdin: true, - out_timestamp: false, - debugcon_port: 0, - pci_address: None, + ..Default::default() }, ); @@ -337,16 +331,10 @@ mod tests { SerialParameters { type_: SerialType::Stdout, hardware: SerialHardware::VirtioConsole, - name: None, - path: None, - input: None, num: 1, console: true, - earlycon: false, stdin: true, - out_timestamp: false, - debugcon_port: 0, - pci_address: None, + ..Default::default() }, ); @@ -356,16 +344,9 @@ mod tests { SerialParameters { type_: SerialType::Stdout, hardware: SerialHardware::Serial, - name: None, - path: None, - input: None, num: 1, - console: false, earlycon: true, - stdin: false, - out_timestamp: false, - debugcon_port: 0, - pci_address: None, + ..Default::default() }, ); @@ -403,16 +384,10 @@ mod tests { SerialParameters { type_: SerialType::Stdout, hardware: SerialHardware::VirtioConsole, - name: None, - path: None, - input: None, num: 1, - console: false, earlycon: true, stdin: true, - out_timestamp: false, - debugcon_port: 0, - pci_address: None, + ..Default::default() }, );