Skip to content

Commit

Permalink
tests/container: Test container disconnect during exec
Browse files Browse the repository at this point in the history
Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Sep 12, 2024
1 parent 1b0d761 commit 883a1a6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/container
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,24 @@ lxc exec u1 -- mkdir /root/sys
lxc exec u1 -- mount -t sysfs sysfs /root/sys
lxc delete -f u1


echo "==> Try cleanly stopping a container"
lxc launch "${IMAGE}" c1
waitInstanceBooted c1
lxc restart c1

echo "==> Test exit codes when container disconnects during lxc exec"

# Try disconnecting a container stopping forcefully and gracefully to make sure they differ appropriately.
(sleep 1 && lxc restart -f c1) &
lxc exec c1 -- sleep 10 || exitCode=$?
[ "${exitCode:-0}" -eq 137 ]

(sleep 1 && lxc stop c1) &
lxc exec c1 -- sleep 10 || exitCode=$?
# Both 129 and 143 have been seen and both make sense here.
[ "${exitCode:-0}" -eq 129 ] || [ "${exitCode:-0}" -eq 143 ]

lxc delete -f c1

# shellcheck disable=SC2034
FAIL=0

0 comments on commit 883a1a6

Please sign in to comment.