From f706e03c9dcc6c3df0d329ac6a70395a15fe1e76 Mon Sep 17 00:00:00 2001 From: hamistao Date: Thu, 5 Sep 2024 22:31:38 -0300 Subject: [PATCH] tests/vm: Add test for VM disconnection during `lxc exec` Signed-off-by: hamistao --- tests/vm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/vm b/tests/vm index 862d5d376..3194d9f99 100644 --- a/tests/vm +++ b/tests/vm @@ -18,5 +18,21 @@ lxc stop vm1 lxc start waitInstanceBooted vm1 +echo "==> Test lxc exec exit code upon VM disconnection due to a stop/reboot" +# Try disconnecting a VM stopping forcefully and gracefully to make sure they match. +(sleep 1 && lxc stop -f vm1) & +lxc exec vm1 -- sleep 10 || exitCode=$? +[ "${exitCode:-0}" -eq 129 ] + +wait $! +lxc start vm1 +waitInstanceBooted vm1 +(sleep 1 && lxc stop vm1) & +lxc exec vm1 -- sleep 10 || exitCode=$? +[ "${exitCode:-0}" -eq 129 ] + +wait $! +lxc delete -f vm1 + # shellcheck disable=SC2034 FAIL=0