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 (105 lines) | stat: -rw-r--r-- 5,113 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
summary: verify that user environment settings are added

details: |
    User environment variables are added via /etc/profile.d/snapd.sh (bash/sh
    specific) or via /lib/environment.d/ helpers. Make sure that at least one of
    the mechanisms works and XDG_DATA_DIRS and PATH are updated accordingly
    inside the user session, no matter the shell they use.

systems:
   - -ubuntu-core-*  # cannot install zsh or fish
   - -ubuntu-14.04-* # cannot use systemd
   - -amazon-linux-2-* # no fish package for AMZN2
   - -amazon-linux-2023-* # no fish package for AL2023
   - -centos-9-* # no fish package

environment:
    TEST_ZSH_USER: test-zsh
    TEST_FISH_USER: test-fish

prepare: |

    echo "Create a user with a different shell"
    useradd --create-home --user-group -s /usr/bin/zsh "$TEST_ZSH_USER"
    useradd --create-home --user-group -s /usr/bin/fish "$TEST_FISH_USER"
    # tests.session assumes that the shell is sh compatible, which isn't true
    # for fish
    for user in test "$TEST_ZSH_USER" ; do
        tests.session prepare -u "$user"
    done

restore: |
    for user in test "$TEST_ZSH_USER"  ; do
        tests.session restore -u "$user"
    done
    userdel -f -r "$TEST_ZSH_USER"
    userdel -f -r "$TEST_FISH_USER"

execute: |
    for user in test "$TEST_ZSH_USER" ; do
        # Dump the environment set up by the user session manager
        if tests.session has-session-systemd-and-dbus; then
            tests.session -u "$user" exec systemctl --user show-environment > "${user}-session-env"
        fi
        tests.session -u "$user" exec env > "${user}-profile-env"
        # dump the variables exported to a subprocess
        tests.session -u "$user" exec sh -c 'exec env' > "${user}-child-env"
    done
    # tests.session as the helper assumes a sh compatible shell, so we cannot
    # use it with fish
    su -c 'env' -l "$TEST_FISH_USER"  > "${TEST_FISH_USER}-profile-env"
    # fish allows environment variables to be selectively exported to
    # subprocesses, dump them now and verify that the right ones are there later
    su -c 'sh -c "exec env"' -l "$TEST_FISH_USER" > "${TEST_FISH_USER}-child-env"

    SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"
    LOCAL_PATH=
    if tests.info is-snapd-from-archive; then
        MOUNT_DIR="$(os.paths snap-mount-dir)"
        LOCAL_PATH="$MOUNT_DIR/snapd/current"
    fi
    for user in test "$TEST_ZSH_USER" "$TEST_FISH_USER" ; do
        echo "checking $user"
        if [ -e "${user}-session-env" ]; then
            # Even though there's user session support, systemd may be too old and
            # not support user-environment-generators (specifically systemd versions
            # earlier than 233).
            if [ -d "$LOCAL_PATH"/usr/lib/systemd/user-environment-generators ]; then
                MATCH 'XDG_DATA_DIRS=.*[:]?/var/lib/snapd/desktop[:]?.*' < "${user}-session-env"
                MATCH "PATH=.*[:]?${SNAP_MOUNT_DIR}/bin[:]?.*" < "${user}-session-env"
            fi
        fi
        # Profile should also be correctly set up
        case "$user:$SPREAD_SYSTEM" in
            test-zsh:ubuntu-*|test-zsh:debian-*)
                # Due to https://bugs.launchpad.net/ubuntu/+source/zsh/+bug/1640514
                NOMATCH 'XDG_DATA_DIRS=.*[:]?/var/lib/snapd/desktop[:]?.*' < "${user}-profile-env"
                NOMATCH "PATH=.*[:]?${SNAP_MOUNT_DIR}/bin[:]?.*" < "${user}-profile-env"
                ;;
            test-fish:ubuntu-16.04*)
                # fish on 16.04 is just too old to support vendor_conf.d so
                # XDG_DATA_DIRS is not appended to, but also does not clobber
                # PATH
                NOMATCH 'XDG_DATA_DIRS=.*[:]?/var/lib/snapd/desktop[:]?.*' < "${user}-profile-env"
                MATCH "PATH=.*[:]?${SNAP_MOUNT_DIR}/bin[:]?.*" < "${user}-profile-env"
                NOMATCH 'XDG_DATA_DIRS=.*[:]?/var/lib/snapd/desktop[:]?.*' < "${user}-child-env"
                MATCH "PATH=.*[:]?${SNAP_MOUNT_DIR}/bin[:]?.*" < "${user}-child-env"
                ;;
            *)
                MATCH 'XDG_DATA_DIRS=.*[:]?/var/lib/snapd/desktop[:]?.*' < "${user}-profile-env"
                MATCH "PATH=.*[:]?${SNAP_MOUNT_DIR}/bin[:]?.*" < "${user}-profile-env"
                # similarly the right paths are set for subprocesses
                MATCH 'XDG_DATA_DIRS=.*[:]?/var/lib/snapd/desktop[:]?.*' < "${user}-child-env"
                MATCH "PATH=.*[:]?${SNAP_MOUNT_DIR}/bin[:]?.*" < "${user}-child-env"
                # make sure that XDG_DATA_DIRS contains the default locations as well
                MATCH 'XDG_DATA_DIRS=.*[:]?/usr/share[:]?.*' < "${user}-profile-env"
                if ! os.query is-opensuse tumbleweed; then
                    # it was observed that on Tumbleweed XDG_DATA_DIRS seems to
                    # have a default value which does not include
                    # /usr/local/share, so apply the check only on remaining
                    # systems
                    MATCH 'XDG_DATA_DIRS=.*[:]?/usr/local/share[:]?.*' < "${user}-profile-env"
                fi
                ;;
        esac
    done