8000 fix: flaky gdb test by jsturtevant · Pull Request #1247 · hyperlight-dev/hyperlight · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions src/hyperlight_host/examples/guest-debugging/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,13 @@ mod tests {
}
}

fn cleanup(out_file_path: &str, cmd_file_path: &str) -> Result<()> {
let res1 = std::fs::remove_file(out_file_path)
.map_err(|e| new_error!("Failed to remove gdb.output file: {}", e));
let res2 = std::fs::remove_file(cmd_file_path)
.map_err(|e| new_error!("Failed to remove gdb-commands.txt file: {}", e));

res1?;
res2?;

Ok(())
fn cleanup(out_file_path: &str, cmd_file_path: &str) {
// Ignore missing files — they may not exist if the test failed early.
for path in [out_file_path, cmd_file_path] {
if let Err(e) = std::fs::remove_file(path) {
println!("Warning: failed to remove {} during cleanup: {}", path, e);
}
}
}

#[test]
Expand Down Expand Up @@ -286,10 +283,7 @@ mod tests {

let result = run_guest_and_gdb(&cmd_file_path, &out_file_path, &cmd, checker);

// cleanup
let cleanup_result = cleanup(&out_file_path, &cmd_file_path);
assert!(cleanup_result.is_ok(), "{}", cleanup_result.unwrap_err());
// check if the test passed - done at the end to ensure cleanup is done
cleanup(&out_file_path, &cmd_file_path);
assert!(result.is_ok(), "{}", result.unwrap_err());
}

Expand Down Expand Up @@ -337,10 +331,7 @@ mod tests {
let checker = |contents: String| contents.contains("$2 = [1.20000005, 0, 0, 0]");
let result = run_guest_and_gdb(&cmd_file_path, &out_file_path, &cmd, checker);

// cleanup
let cleanup_result = cleanup(&out_file_path, &cmd_file_path);
assert!(cleanup_result.is_ok(), "{}", cleanup_result.unwrap_err());
// check if the test passed - done at the end to ensure cleanup is done
cleanup(&out_file_path, &cmd_file_path);
assert!(result.is_ok(), "{}", result.unwrap_err());
}
}
0