Skip to content

Commit 7bfdeb6

Browse files
authored
Merge pull request #107 from rust-osdev/fix-macos-ci
Fix QEMU test flakiness on ARM64 macOS
2 parents 75a67a9 + ee24927 commit 7bfdeb6

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

example-kernels/runner-doctest/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ extern crate rlibc;
1616
/// extern "C" fn start() {
1717
/// assert_eq!(add(1, 2), 3);
1818
/// unsafe { exit_qemu(ExitCode::Success); }
19+
/// // Spin until QEMU shuts down to avoid overwriting the exit code (TCG race on ARM64).
20+
/// loop {}
1921
/// }
2022
/// ```
2123
pub fn add(a: u32, b: u32) -> u32 {
@@ -32,6 +34,8 @@ pub fn add(a: u32, b: u32) -> u32 {
3234
/// extern "C" fn start() {
3335
/// assert_eq!(mul(2, 3), 6);
3436
/// unsafe { exit_qemu(ExitCode::Success); }
37+
/// // Spin until QEMU shuts down to avoid overwriting the exit code (TCG race on ARM64).
38+
/// loop {}
3539
/// }
3640
/// ```
3741
pub fn mul(a: u32, b: u32) -> u32 {
@@ -47,6 +51,9 @@ fn test_runner(tests: &[&dyn Fn()]) {
4751
unsafe {
4852
exit_qemu(ExitCode::Success);
4953
}
54+
// Keep spinning so that the fallthrough `exit_qemu(Failed)` in `_start`
55+
// cannot overwrite the exit code before QEMU shuts down (TCG race on ARM64).
56+
loop {}
5057
}
5158

5259
pub enum ExitCode {

example-kernels/runner-fail-reboot/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ pub fn test_runner(tests: &[&dyn Fn()]) {
1414
unsafe {
1515
exit_qemu(ExitCode::Success);
1616
}
17+
// Keep spinning so that the fallthrough `exit_qemu(Failed)` in `_start`
18+
// cannot overwrite the exit code before QEMU shuts down (TCG race on ARM64).
19+
loop {}
1720
}
1821

1922
#[test_case]

example-kernels/runner-test/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ pub fn test_runner(tests: &[&dyn Fn()]) {
1313
}
1414

1515
unsafe { exit_qemu(ExitCode::Success); }
16+
// Keep spinning so that the fallthrough `exit_qemu(Failed)` in `_start`
17+
// cannot overwrite the exit code before QEMU shuts down (TCG race on ARM64).
18+
loop {}
1619
}
1720

1821
#[test_case]

0 commit comments

Comments
 (0)