File: task.yaml

package info (click to toggle)
snapd 2.72-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,412 kB
  • sloc: sh: 16,506; ansic: 16,211; python: 11,213; makefile: 1,919; exp: 190; awk: 58; xml: 22
file content (72 lines) | stat: -rw-r--r-- 2,448 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
summary: Check that installing and running a snap works

details: |
    Snapd installs packages by mounting them in a structure under /snap or
    /var/lib/snapd/snap directories, depending on distribution policy. Ensure
    that a trivial test snap can be installed, shows up in the list of installed
    packages, can be started as both root and non-root user and that a snapd
    state recorded that installation in the change system. The test snap is
    installed, and partially tested (only as root) for each of the major base
    snaps: core, core18, core20 and core22.

restore: |
    tests.exec is-skipped && exit 0

    rm -f /home/test/stderr.log
    rm -f /home/test/stdout.log
    # required! in autopkgtest no suite restore is run at all
    snap remove --purge test-snapd-sh
    for base in core18 core20 core22 core24; do
        snap remove --purge test-snapd-sh-${base} || true
    done

debug: |
    tests.exec is-skipped && exit 0

    if test -e stderr.log; then
        echo "content of stderr.log"
        cat stderr.log
    fi

execute: |
    tests.exec is-skipped && exit 0

    #shellcheck source=tests/lib/systems.sh
    . "$TESTSLIB"/systems.sh

    echo "Ensure install from the store works"
    snap install test-snapd-sh

    echo "Ensure that the snap can be run as root"
    test-snapd-sh.sh -c 'echo hello' > stdout.log 2> stderr.log
    MATCH "^hello$" < stdout.log
    if grep -v DEBUG stderr.log ; then
        echo "stderr.log must be empty but it is not: (run as root)"
        cat stderr.log
        exit 1
    fi

    echo "Ensure that the snap can be run as the user"
    su -l -c "test-snapd-sh.sh -c 'echo hello' > stdout.log 2> stderr.log" test
    MATCH "^hello$" < stdout.log
    if grep -v DEBUG stderr.log ; then
        echo "stderr.log must be empty but it is not: (run as user)"
        cat stderr.log
        exit 1
    fi

    echo "Ensure the snap is listed"
    snap list | grep ^test-snapd-sh

    echo "Ensure a change was generated for the install"
    snap changes | MATCH 'Install "test-snapd-sh" snap'

    echo "Ensure different bases work"
    for base in core18 core20 core22 core24; do
        snap install test-snapd-sh-${base}
        
        test-snapd-sh-${base}.sh -c "echo hello $base" | MATCH "hello $base"
        # shellcheck disable=SC2016
        test-snapd-sh-${base}.sh -c 'touch $SNAP_COMMON/test'
        test -f /var/snap/test-snapd-sh-${base}/common/test
    done