Files
snapd/tests/core/tmp/task.yaml
Alfonso Sánchez-Beato 6a5d75d564 tests/core/tmp: use M suffix instead of m
Use M suffix instead of m as that is what is supported by ParseSize().
2021-12-10 13:52:30 +01:00

47 lines
1.5 KiB
YAML

summary: Check that the tmp.size settings work
environment:
MOUNTCFG_FILE: /etc/systemd/system/tmp.mount.d/override.conf
prepare: |
if [ -f "$MOUNTCFG_FILE" ]; then
echo "tmpfs configuration file already present, testbed not clean"
exit 1
fi
restore: |
rm -f "$MOUNTCFG_FILE"
execute: |
echo "Ensure tmp.size is not set initially"
test ! -f "$MOUNTCFG_FILE"
if snap get system tmp.size; then
echo "Error: tmp.size is unexpectedly set"
exit 1
fi
def_size=$(df --output=size /tmp | tail -1)
echo "Ensure setting tmp.size works"
for size in 100 200; do
snap set system tmp.size="$size"M
snap get system tmp.size | MATCH "$size"M
df -h --output=size /tmp | MATCH "$size"M
grep '^tmpfs /tmp' /proc/mounts | MATCH nosuid,nodev
MATCH "Options=mode=1777,strictatime,nosuid,nodev,size=${size}M" "$MOUNTCFG_FILE"
# Check that systemd is happy with the generated override.conf
systemctl daemon-reload
done
echo "Unsetting gets things back to defaults"
snap unset system tmp.size
if snap get system tmp.size; then
echo "Error: tmp.size is unexpectedly set"
exit 1
fi
test ! -f "$MOUNTCFG_FILE"
cur_size=$(df --output=size /tmp | tail -1)
# For some odd reason, resizing to the default can have a difference with the
# old one of one page (4k), at least in GCE, so we take that into account.
test "$cur_size" -le $((def_size + 4)) && test "$cur_size" -ge $((def_size - 4))
systemctl daemon-reload