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 (74 lines) | stat: -rw-r--r-- 2,934 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
67
68
69
70
71
72
73
74
summary: Ensure that the cups interface works.

details: |
    The cups-control interface allows a snap to access the locale configuration.

    A snap which defines the cups-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 talk to the cups
    daemon. The test snap used pulls the lpr functionality and installs a pdf
    printer. In order to actually connect to the socket it needs to declare a
    plug on the network interface. The test checks for the existence of a pdf
    file generated by the lpr command in the snap.

# Default cups/cups-pdf configuration on these distributions isn't working yet without further tweaks.
# TODO: enable on debian-sid once https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1006853 is fixed
systems: [-ubuntu-core-*, -opensuse-*, -fedora-*, -arch-*, -amazon-*, -centos-*, -debian-sid-*]

environment:
    TEST_FILE: /var/snap/test-snapd-cups-control-consumer/current/test_file.txt

prepare: |
    echo "Given a snap declaring a cups plug is installed"
    snap install test-snapd-cups-control-consumer

    if not os.query is-trusty; then
        # Not all distributions are starting the cups service directly after
        # the package was installed.
        echo "Enabling cups service in case it is not enabled"
        if ! systemctl is-enabled cups ; then
            # We can't use --now as this isn't supported by all distributions
            systemctl enable cups
        fi
        echo "Starting cups service in case it is not active"
        if ! systemctl is-active cups; then
            systemctl start cups
        fi
    fi

restore: |
    rm -rf "$HOME"/PDF "$TEST_FILE"

debug: |
    systemctl status cups || true
    "$TESTSTOOLS"/journal-state get-log -u cpus || true

execute: |
    echo "Then the plug is disconnected by default"
    snap interfaces -i cups-control | MATCH '^- +test-snapd-cups-control-consumer:cups-control'

    echo "When the plug is connected"
    snap connect test-snapd-cups-control-consumer:cups-control

    echo "Then the snap command is able to print files"
    echo "Hello World" > "$TEST_FILE"
    test-snapd-cups-control-consumer.lpr "$TEST_FILE"
    #shellcheck disable=SC2148
    #shellcheck disable=SC2016
    retry -n 60 --wait 1 sh -c 'test "$(find "$HOME"/PDF -name "*.pdf" | wc -l)" -ge 1'

    if [ "$(snap debug confinement)" = partial ] ; then
        exit 0
    fi

    echo "When the plug is disconnected"
    snap disconnect test-snapd-cups-control-consumer:cups-control

    echo "Then the snap command is not able to print files"
    if test-snapd-cups-control-consumer.lpr "$TEST_FILE" 2>print.error; then
        echo "Expected error with plug disconnected"
        exit 1
    fi
    MATCH "(scheduler not responding|No default destination)" < print.error