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 (90 lines) | stat: -rw-r--r-- 2,910 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
summary: Test the auto-connect behavior of the cups-control interface.

details: |
    The cups-control interface is provided as an implicit slot on classic
    systems. It is also provided as a slot by the cups snap. Normally snapd will
    not auto-connect a plug if there are multiple candidate slots available.

    However the cups-control interface is set up to only make one slot a
    candidate: if a non-snap cupsd appears to be on the system then
    system:cups-control is favoured. And if there is no non-snap cupsd, the
    reverse is true.

systems:
    - -ubuntu-core-*
    - -ubuntu-14.04*

environment:
    BLOB_DIR: $(pwd)/fake-store-blobdir

prepare: |
    if [ "$TRUST_TEST_KEYS" = "false" ]; then
        echo "This test needs test keys to be trusted"
        exit
    fi

    snap debug can-manage-refreshes | MATCH false

    snap ack "$TESTSLIB/assertions/testrootorg-store.account-key"

    "$TESTSTOOLS"/store-state setup-fake-store "$BLOB_DIR"

    snap_path=$("$TESTSTOOLS"/snaps-state pack-local cups-consumer)
    "$TESTSTOOLS"/store-state make-snap-installable "$BLOB_DIR" "${snap_path}"
    cat > snap-decl.json <<'EOF'
    {
      "format": "1",
      "revision": "2",
      "snap-name": "cups-consumer",
      "snap-id": "cups-consumer-id",
      "plugs":
      {
        "cups-control": {
          "allow-installation": "true",
          "allow-auto-connection": "true"
        }
      }
    }
    EOF
    fakestore new-snap-declaration --dir "${BLOB_DIR}" --snap-decl-json snap-decl.json
    snap ack "${BLOB_DIR}"/asserts/*.snap-declaration

    echo "Hiding any existing cupsd configuration"
    mkdir -p /etc/cups
    if [ -f /etc/cups/cupsd.conf ]; then
        mv /etc/cups/cupsd.conf /etc/cups/cupsd.conf.orig
    fi

restore: |
    if [ "$TRUST_TEST_KEYS" = false ]; then
        echo "This test needs test keys to be trusted"
        exit
    fi
    "$TESTSTOOLS"/store-state teardown-fake-store "$BLOB_DIR"

    rm -f /etc/cups/cupsd.conf
    if [ -f /etc/cups/cupsd.conf.orig ]; then
        mv /etc/cups/cupsd.conf.orig /etc/cups/cupsd.conf
    fi

execute: |
    if [ "$TRUST_TEST_KEYS" = false ]; then
        echo "This test needs test keys to be trusted"
        exit
    fi

    echo "Install the cups-provider snap"
    "$TESTSTOOLS"/snaps-state install-local cups-provider

    echo "We auto-connect to the cups-provider snap when there is no system cupsd"
    test ! -f /etc/cups/cupsd.conf
    snap install cups-consumer
    snap connections cups-consumer | MATCH "cups-control +cups-consumer:cups-control +cups-provider:cups-control +-"

    echo "Remove the cups-consumer snap"
    snap remove cups-consumer

    echo "If there is a system cupsd, we auto-connect to the implicit slot"
    touch /etc/cups/cupsd.conf
    snap install cups-consumer
    snap connections cups-consumer | MATCH "cups-control +cups-consumer:cups-control +:cups-control +-"