mirror of
https://github.com/token2/snapd.git
synced 2026-03-13 11:15:47 -07:00
Cleaning (killing) the spawned process was deferred to restore but spread waits for execute script to finish completely which causes the test to hang for the whole time of the process (sleep 5m). If the test is successful we could speed up the process by popping the clean command. Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>
54 lines
1.8 KiB
YAML
54 lines
1.8 KiB
YAML
summary: Ensure that the process-control interface works.
|
|
|
|
details: |
|
|
The process-control interface allows a snap to control other processes via signals
|
|
and nice.
|
|
|
|
A snap which defines the process-control plug must be shown in the interfaces list.
|
|
The plug must not be auto-connected on install and, as usual, must be able to be
|
|
reconnected.
|
|
|
|
A snap declaring a plug on this interface must be able to kill other processes. Currently
|
|
this test does not check the priority change capability of the interface, will be
|
|
extended later.
|
|
|
|
prepare: |
|
|
echo "Given a snap declaring a plug on the process-control interface is installed"
|
|
"$TESTSTOOLS"/snaps-state install-local process-control-consumer
|
|
|
|
execute: |
|
|
echo "The interface is disconnected by default"
|
|
snap interfaces -i process-control | MATCH -- '- +process-control-consumer:process-control'
|
|
|
|
echo "When the plug is connected"
|
|
snap connect process-control-consumer:process-control
|
|
|
|
echo "Then the snap is able to kill an existing process"
|
|
sleep 5m &
|
|
pid=$!
|
|
kill -s 0 "$pid"
|
|
process-control-consumer.signal SIGTERM "$pid"
|
|
retry -n 10 not kill -s 0 "$pid"
|
|
|
|
if [ "$(snap debug confinement)" = partial ] ; then
|
|
exit
|
|
fi
|
|
|
|
echo "When the plug is disconnected"
|
|
snap disconnect process-control-consumer:process-control
|
|
|
|
echo "Then the snap is not able to kill an existing process"
|
|
sleep 5m &
|
|
pid=$!
|
|
tests.cleanup defer "kill $pid 2>/dev/null || true"
|
|
|
|
if process-control-consumer.signal SIGTERM "$pid" 2> process-kill.error; then
|
|
echo "Expected permission error accessing killing a process with disconnected plug"
|
|
exit 1
|
|
fi
|
|
MATCH "Permission denied" < process-kill.error
|
|
kill -s 0 "$pid"
|
|
|
|
# Test passed, clean (kill) process now
|
|
tests.cleanup pop
|