File: task.yaml

package info (click to toggle)
snapd 2.71-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 79,536 kB
  • sloc: ansic: 16,114; sh: 16,105; python: 9,941; makefile: 1,890; exp: 190; awk: 40; xml: 22
file content (53 lines) | stat: -rw-r--r-- 1,853 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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