Skip to content

Commit 6e09be9

Browse files
committed
Enable gdb tests on Windows
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
1 parent 16df4fe commit 6e09be9

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

.github/workflows/dep_rust.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ jobs:
157157
RUST_LOG: debug
158158
run: just run-rust-examples-linux ${{ matrix.config }} ${{ matrix.hypervisor == 'mshv' && 'mshv2' || ''}}
159159

160-
- name: Run Rust Gdb tests - linux
161-
if: runner.os == 'Linux'
160+
- name: Run Rust Gdb tests
162161
env:
163162
CARGO_TERM_COLOR: always
164163
RUST_LOG: debug

Justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ like-ci config=default-target hypervisor="kvm":
126126
@# Run Rust examples - linux
127127
{{ if os() == "linux" { "just run-rust-examples-linux " + config + " " + if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}
128128

129-
@# Run Rust Gdb tests - linux
130-
{{ if os() == "linux" { "just test-rust-gdb-debugging " + config + " " + if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}
129+
@# Run Rust Gdb tests
130+
just test-rust-gdb-debugging {{ config }} {{ if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } }}
131131

132132
@# Run Rust Crashdump tests
133133
just test-rust-crashdump {{config}} {{ if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } }}

src/hyperlight_host/examples/guest-debugging/main.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ mod tests {
111111

112112
use super::*;
113113

114+
#[cfg(not(windows))]
115+
const GDB_COMMAND: &str = "rust-gdb";
116+
#[cfg(windows)]
117+
const GDB_COMMAND: &str = "gdb";
118+
114119
fn write_cmds_file(cmd_file_path: &str, cmd: &str) -> io::Result<()> {
115120
let file = File::create(cmd_file_path)?;
116121
let mut writer = BufWriter::new(file);
@@ -150,7 +155,7 @@ mod tests {
150155
// wait 3 seconds for the gdb to connect
151156
thread::sleep(Duration::from_secs(3));
152157

153-
let mut gdb = Command::new("rust-gdb")
158+
let mut gdb = Command::new(GDB_COMMAND)
154159
.arg("--nw")
155160
.arg("--batch")
156161
.arg("-x")
@@ -235,7 +240,9 @@ mod tests {
235240
#[serial]
236241
fn test_gdb_end_to_end() {
237242
let out_dir = std::env::var("OUT_DIR").expect("Failed to get out dir");
238-
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").expect("Failed to get manifest dir");
243+
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR")
244+
.expect("Failed to get manifest dir")
245+
.replace('\\', "/");
239246
let out_file_path = format!("{out_dir}/gdb.output");
240247
let cmd_file_path = format!("{out_dir}/gdb-commands.txt");
241248

@@ -262,6 +269,9 @@ mod tests {
262269
"
263270
);
264271

272+
#[cfg(windows)]
273+
let cmd = format!("set osabi none\n{}", cmd);
274+
265275
let checker = |contents: String| contents.contains("Stopped at hyperlight_main breakpoint");
266276

267277
let result = run_guest_and_gdb(&cmd_file_path, &out_file_path, &cmd, checker);
@@ -277,7 +287,10 @@ mod tests {
277287
#[serial]
278288
fn test_gdb_sse_check() {
279289
let out_dir = std::env::var("OUT_DIR").expect("Failed to get out dir");
280-
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").expect("Failed to get manifest dir");
290+
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR")
291+
.expect("Failed to get manifest dir")
292+
.replace('\\', "/");
293+
println!("manifest dir {manifest_dir}");
281294
let out_file_path = format!("{out_dir}/gdb-sse.output");
282295
let cmd_file_path = format!("{out_dir}/gdb-sse--commands.txt");
283296

@@ -308,6 +321,9 @@ mod tests {
308321
"
309322
);
310323

324+
#[cfg(windows)]
325+
let cmd = format!("set osabi none\n{}", cmd);
326+
311327
let checker = |contents: String| contents.contains("$2 = [1.20000005, 0, 0, 0]");
312328
let result = run_guest_and_gdb(&cmd_file_path, &out_file_path, &cmd, checker);
313329

0 commit comments

Comments
 (0)