#[test] fn os_user_runtime_panic_positive() { let (mut runtime, shell, child) = setup(); let baseline = runtime.fixture_backend().primary_inventory(); assert_eq!(baseline, [2, 2, 6, 6]); activate(&mut runtime, child); let buffer = runtime.allocate(32, 16).unwrap(); runtime.push(&buffer, 0x7f).unwrap(); runtime.panic().unwrap(); assert_eq!(runtime.fixture_backend().record(child).exit_code, Some(127)); assert_eq!(runtime.fixture_backend().runtime_hooks.borrow().terminals, 1); assert_eq!(runtime.fixture_backend().heap_inventory(), Inventory { pages: 0, pins: 0 }); assert_eq!(runtime.fixture_backend().reap(child), Outcome::Clean(127)); activate(&mut runtime, shell); assert_eq!(runtime.fixture_backend().record(shell).resources.state, threads::State::Running); assert_eq!(runtime.fixture_backend().primary_inventory(), [1, 1, 3, 3]); } #[test] fn os_user_runtime_panic_negative() { let (mut runtime, shell, child) = setup(); activate(&mut runtime, child); runtime.panic().unwrap(); let inventory = runtime.fixture_backend().primary_inventory(); let terminals = runtime.fixture_backend().runtime_hooks.borrow().terminals; // A second terminal call models a returning Exit SVC and its retry loop. for _ in 0..2 { assert_eq!(runtime.panic(), Err(Error::Context)); assert_eq!(runtime.exit(127), Err(Error::Context)); } assert_eq!(runtime.fixture_backend().runtime_hooks.borrow().terminals, terminals); assert_eq!(runtime.fixture_backend().primary_inventory(), inventory); assert_eq!(runtime.fixture_backend().record(child).exit_code, Some(127)); activate(&mut runtime, shell); assert_eq!(runtime.fixture_backend().record(shell).resources.state, threads::State::Running); assert_eq!(runtime.fixture_backend().reap(child), Outcome::Clean(127)); }