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 (63 lines) | stat: -rw-r--r-- 2,753 bytes parent folder | download | duplicates (4)
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
summary: mimic test for the hole-poking code in snap-update-ns

details: |
    When snap-confine cannot create a mount point because of read-only
    filesystem it will use a "writable mimic" constructed out of tmpfs and a
    farm of bind mounts.  This test contains a mimic snap that has various
    kinds of elements that must be correctly handled by the mimic code.

environment:
    PLUG: test-snapd-content-mimic-plug:content
    SLOT: test-snapd-content-mimic-slot:content

prepare: |
    "$TESTSTOOLS"/snaps-state install-local test-snapd-content-mimic-plug
    "$TESTSTOOLS"/snaps-state install-local test-snapd-content-mimic-slot

execute: |
    # Before the content interface is connected we expect to see certain files
    # in the $SNAP directory. Those files represent various kinds of filesystem
    # entries that should be correctly replicated inside the mimic.
    
    check_existing_files() {
        #shellcheck disable=SC2016
        test-snapd-content-mimic-plug.sh -c 'test -f $SNAP/file'
        #shellcheck disable=SC2016
        test-snapd-content-mimic-plug.sh -c 'test -d $SNAP/dir'
        #shellcheck disable=SC2016
        test-snapd-content-mimic-plug.sh -c 'test -h $SNAP/symlink'
        #shellcheck disable=SC2016
        test-snapd-content-mimic-plug.sh -c 'cat $SNAP/file' | MATCH 'content-of-file'
        #shellcheck disable=SC2016
        test-snapd-content-mimic-plug.sh -c 'ls $SNAP/dir' | MATCH 'stuff-in-dir'
        #shellcheck disable=SC2016
        test-snapd-content-mimic-plug.sh -c 'readlink $SNAP/symlink' | MATCH 'symlink-target'
    }

    echo "Check the real thing, before a mimic is established."
    check_existing_files

    # Connect the content interface which will make $SNAP/content show up (TIP:
    # it's not in the snap! It's added dynamically at runtime). Not only we get
    # access to the new things (we'll check those shortly) but we also retain
    # access to the same old stuff that was there before.
    #shellcheck disable=SC2016
    test-snapd-content-mimic-plug.sh -c 'test ! -e $SNAP/content'

    echo "When we connect the interface"
    snap connect "$PLUG" "$SLOT"

    echo "Check we see shared content inside the newly created directory"
    check_existing_files
    #shellcheck disable=SC2016
    test-snapd-content-mimic-plug.sh -c 'test -d $SNAP/content'
    #shellcheck disable=SC2016
    test-snapd-content-mimic-plug.sh -c 'test -e $SNAP/content/canary'

    echo "When we disconnect the interface"
    snap disconnect "$PLUG" "$SLOT"

    echo "The content interface is fully undoable so all the shared content goes away without a trace."
    check_existing_files
    #shellcheck disable=SC2016
    test-snapd-content-mimic-plug.sh -c 'test ! -e $SNAP/content'