File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed
Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff 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/// ```
2123pub 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/// ```
3741pub 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
5259pub enum ExitCode {
Original file line number Diff line number Diff 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]
Original file line number Diff line number Diff 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]
You can’t perform that action at this time.
0 commit comments