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 (45 lines) | stat: -rw-r--r-- 2,152 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
summary: check the symlinks following the right track

details: |
    Snapd contains logic to validate the contents of a snap to ensure that
    symbolic links follow certain restrictions. The test mounts a snap with
    crafted symbolic link names and targets, containing spaces and the character
    sequence ->, to check that snapd is not confused by that structure, and that
    after mounting, the symlinks retain their properties.

environment:
    SNAP: test-snapd-validate-container-happy

prepare: |

execute: |

    SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"

    # We shouldn't use relative symlinks in Github as they cannot be packed correctly.
    # So here let's test whether we can still pack such symlinks within a snap and use if needed.
    # First we "try" to unpack the snap structure and untar the symlinks
    # Then we pack the snap with these symlinks and then install
    # Finally we check to see if the symlinks actually support the intervined symlinks

    # Untar the symlinks 
    tar -xvf "$SNAP"/hell/hell.tar -C "$SNAP"/hell

    snap try "$SNAP"
    # Check to see if the symlinks point to the right paths
    readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/bar | MATCH "foo -> baz -> qux"
    readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/baz | MATCH "foo -> bar -> qux"
    readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/foo | MATCH "bar -> baz -> qux"
    readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/qux | MATCH "foo -> bar -> baz"
    snap remove "$SNAP"

    # Create a new snap structure that includes the unpacked symlinks
    snap pack "$SNAP"
    snap install --dangerous test-snapd-validate-container-happy_1.0_all.snap
    tests.cleanup defer snap remove --purge test-snapd-validate-container-happy

    # Check to see if the symlinks retain their existing paths
    readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/bar | MATCH "foo -> baz -> qux"
    readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/baz | MATCH "foo -> bar -> qux"
    readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/foo | MATCH "bar -> baz -> qux"
    readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/qux | MATCH "foo -> bar -> baz"