[pve-devel] [PATCH installer v2 6/6] tui: tests: catch EOF from proxmox-low-level-installer early

Christoph Heiss c.heiss at proxmox.com
Mon Nov 25 12:27:20 CET 2024


This can happen if e.g. not all required testdata is available, such as
.cd-info - in which case proxmox-low-level-installer will fail early
with

  could not open CD info file '/.cd-info' - No such file or directory at Proxmox/Install/ISOEnv.pm line 95.

Currently, next_msg() would just be recursively called until the stack
overflowed in such a case.

Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
Changes v1 -> v2:
  * new patch

 proxmox-tui-installer/src/views/install_progress.rs | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/proxmox-tui-installer/src/views/install_progress.rs b/proxmox-tui-installer/src/views/install_progress.rs
index 303da0e..d001451 100644
--- a/proxmox-tui-installer/src/views/install_progress.rs
+++ b/proxmox-tui-installer/src/views/install_progress.rs
@@ -258,7 +258,12 @@ mod tests {
 
     fn next_msg<R: BufRead>(reader: &mut R) -> Option<LowLevelMessage> {
         let mut line = String::new();
-        reader.read_line(&mut line).expect("a line");
+
+        match reader.read_line(&mut line) {
+            Ok(0) => return None, /* reached EOF */
+            Err(err) => panic!("failed to read message: {err}"),
+            _ => {}
+        }
 
         match serde_json::from_str::<LowLevelMessage>(&line) {
             Ok(msg) => Some(msg),
-- 
2.47.0





More information about the pve-devel mailing list