Files
snapd/tests/core/writablepaths/task.yaml
Sergio Cazzolato 1f4ef54efc tests: add details for core tests suite (#13912)
* tests: add details for core tests suite

* Update tests/core/services/task.yaml

Co-authored-by: Oliver Calder <oliver@calder.dev>

* Update tests/core/snap-auto-import-asserts-spools/task.yaml

Co-authored-by: Oliver Calder <oliver@calder.dev>

* Update tests/core/snap-core-fixup/task.yaml

Co-authored-by: Oliver Calder <oliver@calder.dev>

* Update tests/core/snap-auto-import-asserts/task.yaml

Co-authored-by: Oliver Calder <oliver@calder.dev>

* Update tests/core/snapd-failover/task.yaml

Co-authored-by: Oliver Calder <oliver@calder.dev>

* Update tests/core/uc20-recovery/task.yaml

Co-authored-by: Oliver Calder <oliver@calder.dev>

* Update tests/core/snapd-failover/task.yaml

Co-authored-by: Oliver Calder <oliver@calder.dev>

* Update tests/core/snapd-refresh-vs-services/task.yaml

Co-authored-by: Oliver Calder <oliver@calder.dev>

---------

Co-authored-by: Oliver Calder <oliver@calder.dev>
2024-04-30 15:15:25 -03:00

58 lines
2.0 KiB
YAML

summary: Ensure that the writable paths on the image are correct
details: |
The file writable-paths allows specific paths in the root partition filesystem
to be made writable, whilst leaving the rest of the root filesystem read-only.
It does this by creating overlaying writable mounts on top of the read-only
root filesystem. These writable mounts are backed to the writable partition.
This test ensures everything in writable-paths is actually writable by checking
in the paths declared in /etc/system-image/writable-paths.
execute: |
echo "Ensure everything in writable-paths is actually writable"
#shellcheck disable=SC2002
cat /etc/system-image/writable-paths | while read -r line; do
line=$(echo "$line" | sed -e '/\s*#.*$/d')
if [ -z "$line" ]; then
continue;
fi
# a writable-path may be either a file or a directory
dir_or_file=$(echo "$line"|cut -f1 -d' ')
# fun! systemd is playing tricks with /etc/machine-id
# and mounts a RO tmpfs on top of the writable one which
# means we cannot touch this file
if [ "$dir_or_file" = "/etc/machine-id" ]; then
continue;
fi
if [ ! -e "$dir_or_file" ]; then
echo "$dir_or_file" >> missing
elif [ -f "$dir_or_file" ]; then
if ! touch "$dir_or_file"; then
echo "$dir_or_file" >> broken
fi
elif ! touch "$dir_or_file"/random-name-that-I-made-up; then
echo "$dir_or_file" >> broken
fi
rm -f "$dir_or_file"/random-name-that-I-made-up
done
if [ -s "broken" ]; then
echo "The following writable paths are not writable:"
cat broken
fi
if [ -s "missing" ]; then
echo "The following writable paths are missing:"
cat missing
fi
# FIMXE: make missing fatal as well
#if [ -s missing ] || [ -s broken ]; then
# exit 1
#fi
if [ -s broken ]; then
exit 1
fi