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 (66 lines) | stat: -rw-r--r-- 2,400 bytes parent folder | download | duplicates (3)
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
summary: Ensure classic dimension works correctly

details: |
    Validates classic snap can be installed in uc16. Check that classic can 
    run commands inside classic and sudo works without a password inside
    classic.

# classic snap is not maintained for UC18+, for these releases the lxd snaps is
# recommended instead of the classic snap
systems: [ubuntu-core-16-*]

environment:
    # We need to set the SUDO_USER here to simulate the real
    # behavior. I.e. when entering classic it happens via
    # `sudo classic` and the user gets a user shell inside
    # the classic environment that has sudo support.
    SUDO_USER: test

prepare: |
    echo "test ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/create-test

restore: |
    rm -f /etc/sudoers.d/create-test
    # Undo the change done by the classic snap.
    # FIXME: https://github.com/snapcore/classic-snap/issues/32
    if [ "$(mountinfo.query /dev/pts .sb_opts)" = "rw,mode=666,ptmxmode=666" ]; then
        mount devpts -t devpts /dev/pts -o remount,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
    fi

execute: |
    echo "Ensure classic can be installed"
    snap install --devmode --beta classic
    snap list|MATCH classic

    echo "Check that classic can run commands inside classic"
    classic test -f /var/lib/dpkg/status

    echo "Ensure that after classic exits no processes are left behind"
    classic "sleep 133713371337&"
    # use "[f]oo" to search for "foo" in ps output without having to filter yourself out
    if pgrep -f 133713371337; then
        echo "The sleep process was not killed when classic exited"
        echo "Something is wrong with the cleanup"
        exit 1
    fi

    echo "Ensure sudo works without a password inside classic"
    # classic uses "script" to work around the issue that
    # tty reports "no tty" inside snaps (LP: #1611493)
    #
    # "script" adds extra \r into the output that we need to filter here
    if [ "$(classic sudo id -u|tr -d '\r')" != "0" ]; then
        echo "sudo inside classic did not work as expected"
        exit 1
    fi

    for d in /proc /run /sys /dev /snappy; do
        if ! classic test -d $d; then
            echo "Expected dir $d is missing inside classic"
            exit 1
        fi
        if ! classic mount | MATCH "$d"; then
            echo "Expected bind mount for $d in classic missing"
            exit 1
        fi
    done