summaryrefslogtreecommitdiff
diff options
authorSergio Cazzolato <sergio.cazzolato@canonical.com>2020-12-02 18:04:34 -0300
committerSergio Cazzolato <sergio.cazzolato@canonical.com>2020-12-02 18:04:34 -0300
commit7db34d5fa5ec63c3539c9a93b30f6117c0d83e41 (patch)
tree486e0e5d200a46824238b474301db9a316426c7d
parent5387521536765f7d1c992fc47eb6ccf114728ab0 (diff)
Use os.query tool instead of comparing the system var
-rw-r--r--tests/core/persistent-journal/task.yaml2
-rw-r--r--tests/cross/go-build/task.yaml2
-rwxr-xr-xtests/lib/pkgdb.sh6
-rwxr-xr-xtests/lib/prepare-restore.sh6
-rwxr-xr-xtests/lib/prepare.sh2
-rwxr-xr-xtests/lib/reset.sh2
-rwxr-xr-xtests/lib/tools/os.query6
-rw-r--r--tests/main/broken-seeding/task.yaml2
-rw-r--r--tests/main/classic-confinement-not-supported/task.yaml4
-rw-r--r--tests/main/classic-confinement/task.yaml2
-rw-r--r--tests/main/cloud-init/task.yaml6
-rw-r--r--tests/main/debs/task.yaml4
-rw-r--r--tests/main/install-fontconfig-cache-gen/task.yaml6
-rw-r--r--tests/main/interfaces-avahi-observe/task.yaml2
-rw-r--r--tests/main/interfaces-cups-control/task.yaml2
-rw-r--r--tests/main/interfaces-kvm/task.yaml4
-rw-r--r--tests/main/interfaces-locale-control/task.yaml6
-rw-r--r--tests/main/interfaces-opengl-nvidia/task.yaml12
-rw-r--r--tests/main/interfaces-system-dbus/task.yaml2
-rw-r--r--tests/main/interfaces-system-observe/task.yaml8
-rw-r--r--tests/main/interfaces-upower-observe/task.yaml2
-rw-r--r--tests/main/interfaces-x11-unix-socket/task.yaml2
-rw-r--r--tests/main/listing/task.yaml4
-rw-r--r--tests/main/network-retry/task.yaml4
-rw-r--r--tests/main/nfs-support/task.yaml2
-rw-r--r--tests/main/os.query/task.yaml8
-rw-r--r--tests/main/parallel-install-interfaces/task.yaml2
-rw-r--r--tests/main/postrm-purge/task.yaml2
-rw-r--r--tests/main/refresh/task.yaml2
-rw-r--r--tests/main/services-timer/task.yaml6
-rw-r--r--tests/main/services-watchdog/task.yaml2
-rw-r--r--tests/main/snap-cli-no-managers/task.yaml2
-rw-r--r--tests/main/snap-connect/task.yaml2
-rw-r--r--tests/main/snap-repair/task.yaml2
-rw-r--r--tests/main/snap-routine-file-access/task.yaml2
-rw-r--r--tests/main/snap-run/task.yaml6
-rw-r--r--tests/main/snap-service/task.yaml2
-rw-r--r--tests/main/snapd-notify/task.yaml2
-rw-r--r--tests/regression/lp-1618683/task.yaml4
-rw-r--r--tests/regression/lp-1644439/task.yaml17
-rw-r--r--tests/regression/lp-1862637/task.yaml2
-rw-r--r--tests/smoke/sandbox/task.yaml2
-rw-r--r--tests/unit/go/task.yaml2
-rw-r--r--tests/upgrade/basic/task.yaml4
44 files changed, 86 insertions, 85 deletions
diff --git a/tests/core/persistent-journal/task.yaml b/tests/core/persistent-journal/task.yaml
index e904b575c3..bd3863756c 100644
--- a/tests/core/persistent-journal/task.yaml
+++ b/tests/core/persistent-journal/task.yaml
@@ -30,7 +30,7 @@ execute: |
# on core16 journald is not reloaded, so changes are not visible until
# rebooted.
- if [[ ! "$SPREAD_SYSTEM" = ubuntu-core-16-* ]]; then
+ if os.query is-core16; then
# this check relies on *anything* getting logged; enabling persistent
# journal writes an entry about journal size, which should be sufficient.
MACHINE_ID=$(cat /etc/machine-id)
diff --git a/tests/cross/go-build/task.yaml b/tests/cross/go-build/task.yaml
index 05844f7345..3022e7f6a8 100644
--- a/tests/cross/go-build/task.yaml
+++ b/tests/cross/go-build/task.yaml
@@ -29,7 +29,7 @@ restore: |
apt --quiet -o Dpkg::Progress-Fancy=false update
prepare: |
- source /etc/os-release
+ . /etc/os-release
mkdir -p /tmp/cross-build/src/github.com/snapcore
cp -ar "$PROJECT_PATH" /tmp/cross-build/src/github.com/snapcore
chown -R test:12345 /tmp/cross-build
diff --git a/tests/lib/pkgdb.sh b/tests/lib/pkgdb.sh
index 04093b5fec..e177cfb5cb 100755
--- a/tests/lib/pkgdb.sh
+++ b/tests/lib/pkgdb.sh
@@ -202,7 +202,7 @@ distro_install_package() {
# arguments as package names.
APT_FLAGS=
DNF_FLAGS=
- if [[ "$SPREAD_SYSTEM" == fedora-* ]]; then
+ if os.query is-fedora; then
# Fedora images we use come with a number of preinstalled package, among
# them gtk3. Those packages are needed to run the tests. The
# xdg-desktop-portal-gtk package uses this in the spec:
@@ -449,7 +449,7 @@ distro_install_build_snapd(){
# On trusty we may pull in a new hwe-kernel that is needed to run the
# snapd tests. We need to reboot to actually run this kernel.
- if [[ "$SPREAD_SYSTEM" = ubuntu-14.04-* ]] && [ "$SPREAD_REBOOT" = 0 ]; then
+ if os.query is-trusty && [ "$SPREAD_REBOOT" = 0 ]; then
REBOOT
fi
elif [ -n "$PPA_VALIDATION_NAME" ]; then
@@ -509,7 +509,7 @@ distro_install_build_snapd(){
;;
esac
- if [[ "$SPREAD_SYSTEM" == arch-* ]]; then
+ if os.query is-arch; then
# Arch policy does not allow calling daemon-reloads in package
# install scripts
systemctl daemon-reload
diff --git a/tests/lib/prepare-restore.sh b/tests/lib/prepare-restore.sh
index b90cb8e351..20171724aa 100755
--- a/tests/lib/prepare-restore.sh
+++ b/tests/lib/prepare-restore.sh
@@ -216,7 +216,7 @@ install_dependencies_from_published(){
###
prepare_project() {
- if [[ "$SPREAD_SYSTEM" == ubuntu-* ]] && [[ "$SPREAD_SYSTEM" != ubuntu-core-* ]]; then
+ if os.query is-ubuntu && os.query is-classic; then
apt-get remove --purge -y lxd lxcfs || true
apt-get autoremove --purge -y
"$TESTSTOOLS"/lxd-state undo-mount-changes
@@ -279,7 +279,7 @@ prepare_project() {
distro_update_package_db
- if [[ "$SPREAD_SYSTEM" == arch-* ]]; then
+ if os.query is-arch; then
# perform system upgrade on Arch so that we run with most recent kernel
# and userspace
if [[ "$SPREAD_REBOOT" == 0 ]]; then
@@ -338,7 +338,7 @@ prepare_project() {
fi
# so is ubuntu-14.04
- if [[ "$SPREAD_SYSTEM" == ubuntu-14.04-* ]]; then
+ if os.query is-trusty; then
if [ ! -d packaging/ubuntu-14.04 ]; then
echo "no packaging/ubuntu-14.04/ directory "
echo "broken test setup"
diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh
index 8c01b068ca..f6e4419311 100755
--- a/tests/lib/prepare.sh
+++ b/tests/lib/prepare.sh
@@ -316,7 +316,7 @@ prepare_classic() {
disable_kernel_rate_limiting
- if [[ "$SPREAD_SYSTEM" == arch-* ]]; then
+ if os.query is-arch; then
# Arch packages do not ship empty directories by default, hence there is
# no /etc/dbus-1/system.d what prevents dbus from properly establishing
# inotify watch on that path
diff --git a/tests/lib/reset.sh b/tests/lib/reset.sh
index 40d36820cf..440afd7800 100755
--- a/tests/lib/reset.sh
+++ b/tests/lib/reset.sh
@@ -63,7 +63,7 @@ reset_classic() {
systemctl reset-failed "$unit" || true
done
- if [[ "$SPREAD_SYSTEM" == ubuntu-14.04-* ]]; then
+ if os.query is-trusty; then
systemctl start snap.mount.service
fi
diff --git a/tests/lib/tools/os.query b/tests/lib/tools/os.query
index d4be883113..be60faeb5f 100755
--- a/tests/lib/tools/os.query
+++ b/tests/lib/tools/os.query
@@ -4,7 +4,7 @@ show_help() {
echo "usage: is-core, is-classic"
echo " is-core16, is-core18, is-core20"
echo " is-trusty, is-xenial, is-bionic, is-focal"
- echo " is-debian, is-fedora, is-amazon-linux, is-arch, is-centos, is-opensuse"
+ echo " is-ubuntu, is-debian, is-fedora, is-amazon-linux, is-arch, is-centos, is-opensuse"
echo ""
echo "Get general information about the current system"
}
@@ -45,6 +45,10 @@ is_focal() {
grep -qFx 'UBUNTU_CODENAME=focal' /etc/os-release
}
+is_ubuntu() {
+ grep -qFx 'ID=ubuntu' /etc/os-release
+}
+
is_debian() {
grep -qFx 'ID=debian' /etc/os-release
}
diff --git a/tests/main/broken-seeding/task.yaml b/tests/main/broken-seeding/task.yaml
index 18f3441e02..2c8058810b 100644
--- a/tests/main/broken-seeding/task.yaml
+++ b/tests/main/broken-seeding/task.yaml
@@ -61,7 +61,7 @@ execute: |
retry -n 30 sh -c 'snap warnings | MATCH "seeding failed "'
# the ubuntu postinst will fix broken seeds, see LP: 1868706
- if [[ "$SPREAD_SYSTEM" == ubuntu-* ]]; then
+ if os.query is-ubuntu; then
# XXX: why is this needed?
mkdir -p /var/lib/snapd/void
# during a pkg upgrade snapd is stopped
diff --git a/tests/main/classic-confinement-not-supported/task.yaml b/tests/main/classic-confinement-not-supported/task.yaml
index a5e20867c3..3887bc7f89 100644
--- a/tests/main/classic-confinement-not-supported/task.yaml
+++ b/tests/main/classic-confinement-not-supported/task.yaml
@@ -25,13 +25,13 @@ execute: |
echo "Check that the classic snap is not installable even with --classic"
EXPECTED_TEXT="snap \"$CLASSIC_SNAP\" requires classic confinement which is only available on classic systems"
- if [[ "$SPREAD_SYSTEM" = fedora-* ]]; then
+ if os.query is-fedora; then
EXPECTED_TEXT="classic confinement requires snaps under /snap or symlink from /snap to /var/lib/snapd/snap"
fi
"$TESTSTOOLS"/to-one-line "$( snap install --dangerous --classic "${CLASSIC_SNAP}_1.0_all.snap" 2>&1 )" | MATCH "$EXPECTED_TEXT"
echo "Not from the store either"
- if [[ "$SPREAD_SYSTEM" = fedora-* ]]; then
+ if os.query is-fedora; then
EXPECTED_TEXT="cannot install \"$CLASSIC_SNAP\": classic confinement requires snaps under /snap or symlink from /snap to /var/lib/snapd/snap"
fi
"$TESTSTOOLS"/to-one-line "$( snap install --classic "$CLASSIC_SNAP" 2>&1 )" | MATCH "$EXPECTED_TEXT"
diff --git a/tests/main/classic-confinement/task.yaml b/tests/main/classic-confinement/task.yaml
index 176052a4e3..6d44014c69 100644
--- a/tests/main/classic-confinement/task.yaml
+++ b/tests/main/classic-confinement/task.yaml
@@ -59,7 +59,7 @@ execute: |
snap info "$CLASSIC_SNAP"|MATCH "installed:.* 2.0 .*classic"
"$CLASSIC_SNAP" | MATCH lala
- if [[ "$SPREAD_SYSTEM" == ubuntu-* ]]; then
+ if os.query is-ubuntu; then
echo "Verify we get 'change_profile unsafe' for classic confinement"
MATCH "change_profile unsafe" < /var/lib/snapd/apparmor/profiles/snap.test-snapd-classic-confinement.test-snapd-classic-confinement
fi
diff --git a/tests/main/cloud-init/task.yaml b/tests/main/cloud-init/task.yaml
index e8486464d0..48aa16d8c0 100644
--- a/tests/main/cloud-init/task.yaml
+++ b/tests/main/cloud-init/task.yaml
@@ -17,9 +17,7 @@ execute: |
if [[ ! -e /run/cloud-init/instance-data.json ]]; then
echo "cloud-init instance data is required to execute the test"
- if [[ "$SPREAD_SYSTEM" == ubuntu-* &&
- "$SPREAD_SYSTEM" != ubuntu-14.04-* &&
- "$SPREAD_SYSTEM" != ubuntu-core-20-* ]]; then
+ if os.query is-ubuntu && not os.query is-trusty && not os.query is-core20; then
# we expect the test to run on all Ubuntu images,
# excluding 14.04/core20
echo "the test expected to run on $SPREAD_SYSTEM"
@@ -76,7 +74,7 @@ execute: |
snap_cloud_region=$(snap get core cloud.region)
test "$cloud_region" = "$snap_cloud_region"
- if [[ "$SPREAD_SYSTEM" == ubuntu-core-* ]]; then
+ if os.query is-core; then
# TODO: is there a race here with snapd restricting cloud-init and us
# checking that it was restricted?
echo "Test that cloud-init restrict file was written"
diff --git a/tests/main/debs/task.yaml b/tests/main/debs/task.yaml
index 8614707a8a..6f43af7ad1 100644
--- a/tests/main/debs/task.yaml
+++ b/tests/main/debs/task.yaml
@@ -5,7 +5,7 @@ systems: [-ubuntu-core-*, -fedora-*, -opensuse-*, -arch-*, -amazon-*, -centos-*]
execute: |
echo "Ensure that our debs have the 'built-using' header"
out=$(dpkg -I "$GOHOME"/snapd_*.deb)
- if [[ "$SPREAD_SYSTEM" = ubuntu-* ]]; then
+ if os.query is-ubuntu; then
# Apparmor & seccomp is only compiled in on Ubuntu for now.
echo "$out" | MATCH 'Built-Using:.*apparmor \(='
echo "$out" | MATCH 'Built-Using:.*libseccomp \(='
@@ -13,7 +13,7 @@ execute: |
echo "$out" | MATCH 'Built-Using:.*libcap2 \(='
# not running on 14.04 because we don't have user sessions there
- if [[ "$SPREAD_SYSTEM" != ubuntu-14.04-* ]]; then
+ if not os.query is-trusty; then
echo "Ensure that the snapd.session-agent.socket symlinks is part of the deb and that it has the right (relative) target"
dpkg -c "$GOHOME"/snapd_*.deb |MATCH -- '-> \.\./snapd.session-agent.socket'
fi
diff --git a/tests/main/install-fontconfig-cache-gen/task.yaml b/tests/main/install-fontconfig-cache-gen/task.yaml
index f836f4f374..d675bed997 100644
--- a/tests/main/install-fontconfig-cache-gen/task.yaml
+++ b/tests/main/install-fontconfig-cache-gen/task.yaml
@@ -10,7 +10,7 @@ debug: |
ls -lah /var/cache/fontconfig/
prepare: |
- if [ "$SPREAD_SYSTEM" = ubuntu-16.04-64 ]; then
+ if os.query is-xenial; then
PKG=fonts-kiloji
NAME=kiloji
else
@@ -26,7 +26,7 @@ prepare: |
fc-cat /var/cache/fontconfig/* 2>/dev/null | MATCH "$NAME"
restore: |
- if [ "$SPREAD_SYSTEM" = ubuntu-16.04-64 ]; then
+ if if os.query is-xenial; then
PKG=fonts-kiloji
else
PKG=fonts-noto-color-emoji
@@ -35,7 +35,7 @@ restore: |
apt autoremove -y "$PKG" || true
execute: |
- if [ "$SPREAD_SYSTEM" = ubuntu-16.04-64 ]; then
+ if if os.query is-xenial; then
NAME=kiloji
else
NAME=NotoColorE
diff --git a/tests/main/interfaces-avahi-observe/task.yaml b/tests/main/interfaces-avahi-observe/task.yaml
index 7fea3c723a..258107c306 100644
--- a/tests/main/interfaces-avahi-observe/task.yaml
+++ b/tests/main/interfaces-avahi-observe/task.yaml
@@ -10,7 +10,7 @@ prepare: |
echo "And avahi-daemon is configured"
sed -i 's/^#enable-dbus=yes/enable-dbus=yes/' /etc/avahi/avahi-daemon.conf
- if [[ "$SPREAD_SYSTEM" = ubuntu-14.04-* ]]; then
+ if if os.query is-trusty; then
initctl reload-configuration
restart avahi-daemon
else
diff --git a/tests/main/interfaces-cups-control/task.yaml b/tests/main/interfaces-cups-control/task.yaml
index f42898215d..986fa55a42 100644
--- a/tests/main/interfaces-cups-control/task.yaml
+++ b/tests/main/interfaces-cups-control/task.yaml
@@ -24,7 +24,7 @@ prepare: |
echo "Given a snap declaring a cups plug is installed"
snap install test-snapd-cups-control-consumer
- if [[ "$SPREAD_SYSTEM" != ubuntu-14.04-* ]]; then
+ if not os.query is-trusty; then
# Not all distributions are starting the cups service directly after
# the package was installed.
echo "Enabling cups service in case it is not enabled"
diff --git a/tests/main/interfaces-kvm/task.yaml b/tests/main/interfaces-kvm/task.yaml
index f1367be832..891681e326 100644
--- a/tests/main/interfaces-kvm/task.yaml
+++ b/tests/main/interfaces-kvm/task.yaml
@@ -11,7 +11,7 @@ prepare: |
fi
touch /dev/kvm
- if [[ "$SPREAD_SYSTEM" == fedora-* ]]; then
+ if os.query is-fedora; then
ausearch --checkpoint stamp -m AVC || true
fi
@@ -50,7 +50,7 @@ execute: |
fi
MATCH "Permission denied" < call.error
- if [[ "$SPREAD_SYSTEM" == fedora-* ]]; then
+ if os.query is-fedora; then
# make sure there are no selinux denials on fedora
ausearch -i --checkpoint stamp --start checkpoint -m AVC 2>&1 | MATCH 'no matches'
fi
diff --git a/tests/main/interfaces-locale-control/task.yaml b/tests/main/interfaces-locale-control/task.yaml
index b804c3b885..f7bd324df8 100644
--- a/tests/main/interfaces-locale-control/task.yaml
+++ b/tests/main/interfaces-locale-control/task.yaml
@@ -13,7 +13,7 @@ summary: |
file both for reading and writing. This path doesn't exist on the excluded distributions.
prepare: |
- if [[ "$SPREAD_SYSTEM" = ubuntu-core-* ]]; then
+ if os.query is-core; then
if snap interfaces | MATCH locale-control; then
echo "locale-control should be only available on core"
exit 1
@@ -32,7 +32,7 @@ prepare: |
EOF
restore: |
- if [[ "$SPREAD_SYSTEM" = ubuntu-core-* ]]; then
+ if os.query is-core; then
if snap interfaces | MATCH locale-control; then
echo "locale-control should be only available on core"
exit 1
@@ -44,7 +44,7 @@ restore: |
mv locale.back /etc/default/locale
execute: |
- if [[ "$SPREAD_SYSTEM" = ubuntu-core-* ]]; then
+ if os.query is-core; then
if snap interfaces | MATCH locale-control; then
echo "locale-control should be only available on core"
exit 1
diff --git a/tests/main/interfaces-opengl-nvidia/task.yaml b/tests/main/interfaces-opengl-nvidia/task.yaml
index 1462a6addf..87ad6677ec 100644
--- a/tests/main/interfaces-opengl-nvidia/task.yaml
+++ b/tests/main/interfaces-opengl-nvidia/task.yaml
@@ -18,7 +18,7 @@ prepare: |
mkdir -p /usr/share/vulkan/icd.d
echo "canary-vulkan" > /usr/share/vulkan/icd.d/nvidia_icd.json
- if [[ "$SPREAD_SYSTEM" == ubuntu-18.04-* ]]; then
+ if os.query is-bionic; then
# mock GLVND EGL vendor file
echo "Test GLVND EGL vendor files access"
mkdir -p /usr/share/glvnd/egl_vendor.d
@@ -26,7 +26,7 @@ prepare: |
fi
# mock nvidia libraries
- if [[ "$SPREAD_SYSTEM" == ubuntu-18.04-* ]]; then
+ if os.query is-bionic; then
mkdir -p /usr/lib/"$(dpkg-architecture -qDEB_HOST_MULTIARCH)"/tls
mkdir -p /usr/lib/"$(dpkg-architecture -qDEB_HOST_MULTIARCH)"/vdpau
echo "canary-triplet" >> /usr/lib/"$(dpkg-architecture -qDEB_HOST_MULTIARCH)"/libGLX.so.0.0.1
@@ -72,7 +72,7 @@ restore: |
rm -rf /usr/share/glvnd/egl_vendor.d/10_nvidia.json
fi
- if [[ "$SPREAD_SYSTEM" == ubuntu-18.04-* ]]; then
+ if os.query is-bionic; then
rm -rf /usr/lib/"$(dpkg-architecture -qDEB_HOST_MULTIARCH)"/tls
rm -rf /usr/lib/"$(dpkg-architecture -qDEB_HOST_MULTIARCH)"/vdpau
rm -f /usr/lib/"$(dpkg-architecture -qDEB_HOST_MULTIARCH)"/libGLX.so.0.0.1
@@ -102,7 +102,7 @@ execute: |
echo "App can access nvidia library files"
expected="canary-legacy"
- if [[ "$SPREAD_SYSTEM" == ubuntu-18.04-* ]]; then
+ if os.query is-bionic; then
expected="canary-triplet"
fi
files="libGLX.so.0.0.1 libGLX_nvidia.so.0.0.1 libnvidia-glcore.so.$NV_VERSION tls/libnvidia-tls.so.$NV_VERSION libnvidia-tls.so.$NV_VERSION vdpau/libvdpau_nvidia.so.$NV_VERSION"
@@ -112,7 +112,7 @@ execute: |
if [[ "$(uname -m)" == x86_64 ]]; then
expected32="canary-32-legacy"
- if [[ "$SPREAD_SYSTEM" == ubuntu-18.04-* ]]; then
+ if os.query is-bionic; then
expected32="canary-32-triplet"
fi
for f in $files; do
@@ -123,7 +123,7 @@ execute: |
echo "And vulkan ICD file"
snap run test-snapd-policy-app-consumer.opengl -c "cat /var/lib/snapd/lib/vulkan/icd.d/nvidia_icd.json" | MATCH canary-vulkan
- if [[ "$SPREAD_SYSTEM" == ubuntu-18.04-* ]]; then
+ if os.query is-bionic; then
echo "And GLVND EGL vendor file"
snap run test-snapd-policy-app-consumer.opengl -c "cat /var/lib/snapd/lib/glvnd/egl_vendor.d/10_nvidia.json" | MATCH canary-egl
fi
diff --git a/tests/main/interfaces-system-dbus/task.yaml b/tests/main/interfaces-system-dbus/task.yaml
index 38d146a23a..c5160814fd 100644
--- a/tests/main/interfaces-system-dbus/task.yaml
+++ b/tests/main/interfaces-system-dbus/task.yaml
@@ -7,7 +7,7 @@ prepare: |
# we can only talk from an unconfied dbus-send to the service on classic,
# on ubuntu-core devices *all* dbus calls are mediated.
echo "Ensure the dbus service is up"
- if ! grep -q ID=ubuntu-core /etc/os-release; then
+ if os.query is-classic; then
dbus-send --system --print-reply --dest=com.dbustest.HelloWorld /com/dbustest/HelloWorld com.dbustest.HelloWorld.SayHello | MATCH "hello world"
fi
diff --git a/tests/main/interfaces-system-observe/task.yaml b/tests/main/interfaces-system-observe/task.yaml
index 892adb37ab..c9dab8cb8e 100644
--- a/tests/main/interfaces-system-observe/task.yaml
+++ b/tests/main/interfaces-system-observe/task.yaml
@@ -15,13 +15,13 @@ prepare: |
echo "Given a snap declaring a plug on the system-observe interface is installed"
snap install --edge test-snapd-system-observe-consumer
- if [[ "$SPREAD_SYSTEM" != ubuntu-14.04-* ]]; then
+ if not os.query is-trusty; then
echo "And hostnamed is started"
systemctl start systemd-hostnamed
fi
restore: |
- if [[ "$SPREAD_SYSTEM" != ubuntu-14.04-* ]]; then
+ if not os.query is-trusty; then
systemctl stop systemd-hostnamed
fi
@@ -36,7 +36,7 @@ execute: |
expected="/dev/tty.*?serial"
su -l -c "test-snapd-system-observe-consumer.consumer" test | MATCH "$expected"
- if [[ "$SPREAD_SYSTEM" != ubuntu-14.04-* ]]; then
+ if not os.query is-trusty; then
echo "And the snap is able to introspect hostname1"
expected="<property name=\"Hostname\" type=\"s\" access=\"read\">"
su -l -c "test-snapd-system-observe-consumer.dbus-introspect" test | MATCH "$expected"
@@ -59,7 +59,7 @@ execute: |
fi
MATCH "Permission denied" < consumer.error
- if [[ "$SPREAD_SYSTEM" != ubuntu-14.04-* ]]; then
+ if not os.query is-trusty; then
echo "And the snap is not able to introspect hostname1"
if su -l -c "test-snapd-system-observe-consumer.dbus-introspect" test 2> introspect.error; then
echo "Expected error with plug disconnected"
diff --git a/tests/main/interfaces-upower-observe/task.yaml b/tests/main/interfaces-upower-observe/task.yaml
index 20d9d3e560..b710f88467 100644
--- a/tests/main/interfaces-upower-observe/task.yaml
+++ b/tests/main/interfaces-upower-observe/task.yaml
@@ -31,7 +31,7 @@ prepare: |
execute: |
SLOT_PROVIDER=
SLOT_NAME=upower-observe
- if [[ "$SPREAD_SYSTEM" = ubuntu-core-* ]]; then
+ if os.query is-core; then
SLOT_PROVIDER=upower
SLOT_NAME=service
fi
diff --git a/tests/main/interfaces-x11-unix-socket/task.yaml b/tests/main/interfaces-x11-unix-socket/task.yaml
index 6233524297..01395540d0 100644
--- a/tests/main/interfaces-x11-unix-socket/task.yaml
+++ b/tests/main/interfaces-x11-unix-socket/task.yaml
@@ -32,7 +32,7 @@ execute: |
not x11-client.rm -f /tmp/.X11-unix/X0
# Ubuntu Core does not have a system:x11 implicit slot
- if [[ "$SPREAD_SYSTEM" = ubuntu-core-* ]]; then
+ if os.query is-core; then
exit 0
fi
diff --git a/tests/main/listing/task.yaml b/tests/main/listing/task.yaml
index aa720ad079..c58c29cf0b 100644
--- a/tests/main/listing/task.yaml
+++ b/tests/main/listing/task.yaml
@@ -50,11 +50,11 @@ execute: |
VERSION=$FINAL_VERSION
TRACKING="(latest/)?stable"
- elif [ "$SPREAD_BACKEND" = "external" ] && [[ "$SPREAD_SYSTEM" == ubuntu-core-16-* ]]; then
+ elif [ "$SPREAD_BACKEND" = "external" ] && os.query is-core16; then
echo "On the external device the core snap tested could be in any track"
TRACKING="(latest/)?(edge|beta|candidate|stable)"
- elif [ "$SPREAD_BACKEND" = "external" ] && { [[ "$SPREAD_SYSTEM" == ubuntu-core-18-* ]] || [[ "$SPREAD_SYSTEM" == ubuntu-core-20-* ]]; }; then
+ elif [ "$SPREAD_BACKEND" = "external" ] && { os.query is-core18 || os.query is-core20; }; then
echo "On the external device the snapd snap tested could be in any track"
NAME=snapd
VERSION=$SNAPD_GIT_VERSION
diff --git a/tests/main/network-retry/task.yaml b/tests/main/network-retry/task.yaml
index fea4822cfe..f641f02917 100644
--- a/tests/main/network-retry/task.yaml
+++ b/tests/main/network-retry/task.yaml
@@ -2,7 +2,7 @@ summary: Ensure network retry works correctly
prepare: |
echo "Break DNS"
- if [[ "$SPREAD_SYSTEM" = ubuntu-core-* ]]; then
+ if os.query is-core; then
resolvConf=$(realpath /etc/resolv.conf)
mv "${resolvConf}" "${resolvConf}.save"
echo "${resolvConf}" > resolvConf.txt
@@ -17,7 +17,7 @@ prepare: |
restore: |
echo "Unbreak DNS"
- if [[ "$SPREAD_SYSTEM" = ubuntu-core-* ]]; then
+ if os.query is-core; then
resolvConf=$(cat resolvConf.txt)
mv "${resolvConf}.save" "${resolvConf}"
else
diff --git a/tests/main/nfs-support/task.yaml b/tests/main/nfs-support/task.yaml
index 0a24b9a0e6..0046851d66 100644
--- a/tests/main/nfs-support/task.yaml
+++ b/tests/main/nfs-support/task.yaml
@@ -185,7 +185,7 @@ execute: |
# not supported. Error displayed:
# - arch: mount.nfs: requested NFS version or transport protocol is not supported
# - debian-sid, ubuntu-20.10: mount.nfs: an incorrect mount option was specified
- if [[ "$SPREAD_SYSTEM" != arch-* && "$SPREAD_SYSTEM" != debian-sid-* && "$SPREAD_SYSTEM" != ubuntu-20.10-* ]]; then
+ if not os.query is-arch && "$SPREAD_SYSTEM" != debian-sid-* && "$SPREAD_SYSTEM" != ubuntu-20.10-* ]]; then
# Mount NFS-exported /home over real /home using NFSv3 and UDP transport
mount -t nfs localhost:/home /home -o nfsvers=3,proto=udp
diff --git a/tests/main/os.query/task.yaml b/tests/main/os.query/task.yaml
index 5bc51a9e7f..87fcb1fc7e 100644
--- a/tests/main/os.query/task.yaml
+++ b/tests/main/os.query/task.yaml
@@ -13,47 +13,55 @@ execute: |
os.query is-core16
not os.query is-core18
not os.query is-classic
+ os.query is-ubuntu
;;
ubuntu-core-18-*)
os.query is-core
os.query is-core18
not os.query is-core20
not os.query is-classic
+ os.query is-ubuntu
;;
ubuntu-core-20-*)
os.query is-core
os.query is-core20
not os.query is-core18
not os.query is-classic
+ os.query is-ubuntu
;;
ubuntu-14-*)
os.query is-classic
os.query is-trusty
not os.query is-bionic
not os.query is-core
+ os.query is-ubuntu
;;
ubuntu-16-*)
os.query is-classic
os.query is-xenial
not os.query is-bionic
not os.query is-core
+ os.query is-ubuntu
;;
ubuntu-18-*)
os.query is-classic
os.query is-bionic
not os.query is-focal
not os.query is-core
+ os.query is-ubuntu
;;
ubuntu-20.04-*)
os.query is-classic
os.query is-focal
not os.query is-xenial
not os.query is-core
+ os.query is-ubuntu
;;
*)
os.query is-classic
not os.query is-focal
not os.query is-core
+ not os.query is-ubuntu
;;
esac
diff --git a/tests/main/parallel-install-interfaces/task.yaml b/tests/main/parallel-install-interfaces/task.yaml
index a9e3277082..b17740069a 100644
--- a/tests/main/parallel-install-interfaces/task.yaml
+++ b/tests/main/parallel-install-interfaces/task.yaml
@@ -11,7 +11,7 @@ prepare: |
"$TESTSTOOLS"/snaps-state install-local-as home-consumer home-consumer_foo
# the home interface is not autoconnected on all-snap systems
- if [[ ! "$SPREAD_SYSTEM" == ubuntu-core-* ]]; then
+ if os.query is-classic; then
snap disconnect home-consumer:home
snap disconnect home-consumer_foo:home
fi
diff --git a/tests/main/postrm-purge/task.yaml b/tests/main/postrm-purge/task.yaml
index 98c48763e4..1105c99d05 100644
--- a/tests/main/postrm-purge/task.yaml
+++ b/tests/main/postrm-purge/task.yaml
@@ -75,7 +75,7 @@ execute: |
fi
done
- if [[ "$SPREAD_SYSTEM" != ubuntu-14.04-* ]]; then
+ if not os.query is-trusty; then
# ubuntu-14.04: systemctl does not list not-found & failed units properly
# test-snapd-service-refuses-to-stop gets forcefully killed by systemd,
diff --git a/tests/main/refresh/task.yaml b/tests/main/refresh/task.yaml
index 870b04d160..6d6c8ed4cb 100644
--- a/tests/main/refresh/task.yaml
+++ b/tests/main/refresh/task.yaml
@@ -115,7 +115,7 @@ execute: |
tests.cleanup defer snap unset system experimental.refresh-app-awareness
#shellcheck source=tests/lib/pkgdb.sh
- if os.query is-classic && ! os.query is-trusty && [ "$(. /etc/os-release && echo "$ID")" != amzn ]; then
+ if os.query is-classic && not os.query is-trusty && not os.query is-amazon-linux; then
. "$TESTSLIB/pkgdb.sh"
distro_install_package inotify-tools
# XXX: probably a bug in defer, this fails without ' ' quotes around the rest.
diff --git a/tests/main/services-timer/task.yaml b/tests/main/services-timer/task.yaml
index 64e3dbfdc8..416de7d066 100644
--- a/tests/main/services-timer/task.yaml
+++ b/tests/main/services-timer/task.yaml
@@ -18,7 +18,7 @@ execute: |
# Fri 2018-02-23 11:01:00 CET 4min 25s left Fri 2018-02-23 10:51:36 CET 4min 58s ago snap.timer-service-snap.random-timer.timer snap.timer-service-snap.random-timer.service
echo "When disabled, times are not listed by systemd"
snap disable test-snapd-timer-service
- if [[ "$SPREAD_SYSTEM" == ubuntu-14.04-* ]]; then
+ if os.query is-trusty; then
for service in regular-timer random-timer range-timer trivial-timer; do
systemctl show -p UnitFileState snap.test-snapd-timer-service.$service.timer | MATCH "UnitFileState="
done
@@ -28,7 +28,7 @@ execute: |
echo "When reenabled, the timers are present again"
snap enable test-snapd-timer-service
- if [[ "$SPREAD_SYSTEM" == ubuntu-14.04-* ]]; then
+ if os.query is-trusty; then
for service in regular-timer random-timer range-timer trivial-timer; do
systemctl show -p UnitFileState snap.test-snapd-timer-service.$service.timer | MATCH "UnitFileState=enabled"
done
@@ -38,7 +38,7 @@ execute: |
echo "When removed, times are not listed by systemd"
snap remove --purge test-snapd-timer-service
- if [[ "$SPREAD_SYSTEM" == ubuntu-14.04-* ]]; then
+ if os.query is-trusty; then
for service in regular-timer random-timer range-timer trivial-timer; do
systemctl show -p UnitFileState snap.test-snapd-timer-service.$service.timer | MATCH "UnitFileState="
done
diff --git a/tests/main/services-watchdog/task.yaml b/tests/main/services-watchdog/task.yaml
index c4287c8930..9d06571e80 100644
--- a/tests/main/services-watchdog/task.yaml
+++ b/tests/main/services-watchdog/task.yaml
@@ -37,7 +37,7 @@ execute: |
done
systemctl show -p SubState snap.test-snapd-service-watchdog.direct-watchdog-ok | MATCH 'SubState=running'
- if [[ "$SPREAD_SYSTEM" == ubuntu-14.04-* ]]; then
+ if os.query is-trusty; then
# service watchdog does not appear to work in Ubuntu 14.04 at all
exit 0
fi
diff --git a/tests/main/snap-cli-no-managers/task.yaml b/tests/main/snap-cli-no-managers/task.yaml
index 8282f39078..3b842bb662 100644
--- a/tests/main/snap-cli-no-managers/task.yaml
+++ b/tests/main/snap-cli-no-managers/task.yaml
@@ -17,6 +17,6 @@ execute: |
check_imports /usr/bin/snap
# snap-bootstrap is shipped only on ubuntu (except for 14.04)
- if [[ "$SPREAD_SYSTEM" = ubuntu-2* ]] || [[ "$SPREAD_SYSTEM" = ubuntu-18.04-* ]] || [[ "$SPREAD_SYSTEM" = ubuntu-16.04-* ]]; then
+ if [[ "$SPREAD_SYSTEM" = ubuntu-2* ]] || os.query is-bionic || os.query is-xenial; then
check_imports /usr/lib/snapd/snap-bootstrap
fi
diff --git a/tests/main/snap-connect/task.yaml b/tests/main/snap-connect/task.yaml
index cfe7ee8cb9..0b331288c1 100644
--- a/tests/main/snap-connect/task.yaml
+++ b/tests/main/snap-connect/task.yaml
@@ -4,7 +4,7 @@ prepare: |
echo "Install a test snap"
"$TESTSTOOLS"/snaps-state install-local home-consumer
# the home interface is not autoconnected on all-snap systems
- if [[ ! "$SPREAD_SYSTEM" == ubuntu-core-16-* ]]; then
+ if not os.query is-core16; then
snap disconnect home-consumer:home
fi
diff --git a/tests/main/snap-repair/task.yaml b/tests/main/snap-repair/task.yaml
index 7e41435145..543a819389 100644
--- a/tests/main/snap-repair/task.yaml
+++ b/tests/main/snap-repair/task.yaml
@@ -4,7 +4,7 @@ summary: Ensure that snap-repair is available
systems: [-fedora-*, -opensuse-*, -arch-*, -amazon-*, -centos-*, -debian-sid-*]
execute: |
- if ! grep -q "ID=ubuntu-core" /etc/os-release; then
+ if os.query is-classic; then
echo "Ensure snap-repair is disabled on classic"
snapd.tool exec snap-repair 2>&1 | MATCH "cannot use snap-repair on a classic system"
exit 0
diff --git a/tests/main/snap-routine-file-access/task.yaml b/tests/main/snap-routine-file-access/task.yaml
index d59ade8c96..5a7800b667 100644
--- a/tests/main/snap-routine-file-access/task.yaml
+++ b/tests/main/snap-routine-file-access/task.yaml
@@ -95,7 +95,7 @@ execute: |
# Classic confinement snaps run in the host system's mount
# namespace, so there are no restrictions on it's file access.
- if [[ "$SPREAD_SYSTEM" = ubuntu-core-* ]]; then
+ if os.query is-core; then
exit 0
fi
"$TESTSTOOLS"/snaps-state install-local test-snapd-classic-confinement --classic
diff --git a/tests/main/snap-run/task.yaml b/tests/main/snap-run/task.yaml
index 236142c75a..87c055c23c 100644
--- a/tests/main/snap-run/task.yaml
+++ b/tests/main/snap-run/task.yaml
@@ -29,11 +29,11 @@ execute: |
fi
# the strace on 14.04 is too old
- if grep -q 'VERSION_ID="14.04"' /etc/os-release; then
+ if os.query is-trusty; then
snap install strace-static
fi
# the strace on opensuse is too old
- if grep -q 'ID=opensuse' /etc/os-release; then
+ if os.query is-opensuse; then
snap install strace-static
fi
# install the snap if no system strace is found
@@ -48,7 +48,7 @@ execute: |
fi
MATCH "Can't stat 'invalid': No such file or directory" < stderr
- if [[ "$SPREAD_SYSTEM" == arch-* || "$SPREAD_SYSTEM" == opensuse-tumbleweed-* ]] ; then
+ if os.query is-arch || [[ "$SPREAD_SYSTEM" == opensuse-tumbleweed-* ]] ; then
# Arch linux and Opensuse tumbleweed run the mainline kernel, strace
# (with event filter or not) *may* randomly get stuck on the kernel
# side, see:
diff --git a/tests/main/snap-service/task.yaml b/tests/main/snap-service/task.yaml
index af9e876d4c..62b95d3514 100644
--- a/tests/main/snap-service/task.yaml
+++ b/tests/main/snap-service/task.yaml
@@ -20,7 +20,7 @@ execute: |
echo "A snap that refuses to stop is killed eventually"
snap stop test-snapd-service.test-snapd-service-refuses-to-stop
# systemd in 14.04 does not provide the "Result: timeout" information
- if [[ "$SPREAD_SYSTEM" == ubuntu-14.04-* ]]; then
+ if os.query is-trusty; then
systemctl status snap.test-snapd-service.test-snapd-service-refuses-to-stop|MATCH "code=killed"
else
systemctl status snap.test-snapd-service.test-snapd-service-refuses-to-stop|MATCH "Result: timeout"
diff --git a/tests/main/snapd-notify/task.yaml b/tests/main/snapd-notify/task.yaml
index ec528f8eb5..e4723bcbb4 100644
--- a/tests/main/snapd-notify/task.yaml
+++ b/tests/main/snapd-notify/task.yaml
@@ -19,7 +19,7 @@ execute: |
watchdog="$(systemctl show -p WatchdogTimestampMonotonic snapd.service | cut -f2 -d=)"
# service became active after it was started
test "$activeenter" -gt "$mainstart"
- if [[ "$SPREAD_SYSTEM" != ubuntu-14.04-* ]]; then
+ if not os.query is-trusty; then
# service pinged systemd after start
test "$watchdog" -gt "$mainstart"
# and became active after having pinged the daemon
diff --git a/tests/regression/lp-1618683/task.yaml b/tests/regression/lp-1618683/task.yaml
index 5b05eec108..68471fbf23 100644
--- a/tests/regression/lp-1618683/task.yaml
+++ b/tests/regression/lp-1618683/task.yaml
@@ -10,7 +10,7 @@ prepare: |
echo "Having installed a test snap in devmode"
"$TESTSTOOLS"/snaps-state install-local test-snapd-tools --devmode
- if [[ "$SPREAD_SYSTEM" == centos-* ]]; then
+ if os.query is-centos; then
# RHEL/Centos 7.4+ set this to 0 by default
# see: https://access.redhat.com/solutions/3188102
cat /proc/sys/user/max_user_namespaces > old_max_user_ns
@@ -18,7 +18,7 @@ prepare: |
fi
restore: |
- if [[ "$SPREAD_SYSTEM" == centos-* ]]; then
+ if os.query is-centos; then
# RHEL/Centos 7.4+ set this to 0 by default
cat old_max_user_ns > /proc/sys/user/max_user_namespaces
fi
diff --git a/tests/regression/lp-1644439/task.yaml b/tests/regression/lp-1644439/task.yaml
index c31b9fe1c0..49ab0b525d 100644
--- a/tests/regression/lp-1644439/task.yaml
+++ b/tests/regression/lp-1644439/task.yaml
@@ -5,7 +5,9 @@ summary: Regression test for https://bugs.launchpad.net/snap-confine/+bug/164443
# general. We discussed this in the past and we'd have to change how we do our
# CI so that we can always build each branch against ubuntu 16.04 container and
# only then repackage and test on a given distribution.
-systems: [ubuntu-14.04-32, ubuntu-14.04-64, ubuntu-16.04-32, ubuntu-16.04-64]
+
+systems: [ubuntu-14.04-64, ubuntu-16.04-32, ubuntu-16.04-64]
+
details: |
snap-confine uses privately-shared /run/snapd/ns to store bind-mounted
mount namespaces of each snap. In the case that snap-confine is invoked
@@ -26,13 +28,6 @@ debug: |
uname -a
execute: |
- # This test is meaningful only on Ubuntu for now as this is where we have
- # the complete apparmor patch-set.
- . /etc/os-release
- if [ "$ID" != "ubuntu" ] && [ "$ID" != "ubuntu-core" ]; then
- echo "This test is only supported on Ubuntu"
- exit 0
- fi
# Don't test on other architectures as (especially on arm) kernel versions
# are not synchronized with x86 and this test is not architecture specific
# to warrant the extra work to figure out which kernel revision got the fix
@@ -41,11 +36,7 @@ execute: |
echo "This test is only supported on x86_64 and i386"
exit 0
fi
- # Check if the kernel is at least 4.4.0-67
- if ! uname -r | perl -ne '/^(\d+)\.(\d+)\.(\d+)-(\d+)/ or exit 1; exit 1 if $1<4; exit 1 if $2<4; exit 1 if $3==0 && $4<67'; then
- echo "This test is not supported on kernels older than 4.4.0-67"
- exit 0
- fi
+
#shellcheck source=tests/lib/dirs.sh
. "$TESTSLIB/dirs.sh"
echo "We can now run a snap command from the namespace of a snap command and see it work"
diff --git a/tests/regression/lp-1862637/task.yaml b/tests/regression/lp-1862637/task.yaml
index 187941d8bc..cf4bc9fe9a 100644
--- a/tests/regression/lp-1862637/task.yaml
+++ b/tests/regression/lp-1862637/task.yaml
@@ -9,7 +9,7 @@ restore: |
execute: |
# The snap always sees /var/lib/dhcp.
test-snapd-app.sh -c 'test -d /var/lib/dhcp'
- if [[ "$SPREAD_SYSTEM" != ubuntu-core-16-* ]]; then
+ if not os.query is-core16; then
if [ -d /var/lib/dhcp ]; then
# Variant 1) The host is not a core16 system and has /var/lib/dhcp
# Directory is bind mounted and writable when the interface is
diff --git a/tests/smoke/sandbox/task.yaml b/tests/smoke/sandbox/task.yaml
index a569d26ddd..0d0e0183a9 100644
--- a/tests/smoke/sandbox/task.yaml
+++ b/tests/smoke/sandbox/task.yaml
@@ -19,7 +19,7 @@ execute: |
"$TESTSTOOLS"/snaps-state install-local test-snapd-sandbox
# home is not auto-connected on core
- if grep -q ID=ubuntu-core /etc/os-release; then
+ if os.query is-core; then
snap connect test-snapd-sandbox:home
fi
diff --git a/tests/unit/go/task.yaml b/tests/unit/go/task.yaml
index bd12ad7fc1..ffd43cabe9 100644
--- a/tests/unit/go/task.yaml
+++ b/tests/unit/go/task.yaml
@@ -17,7 +17,7 @@ execute: |
# The format of code produced by "gofmt" drifts over time. Perform checks
# only on a fixed version to avoid hair-pulling annoyance every six months.
- if [[ "$SPREAD_SYSTEM" != ubuntu-16.04-* ]]; then
+ if not os.query is-xenial; then
skip='SKIP_GOFMT=1'
fi
diff --git a/tests/upgrade/basic/task.yaml b/tests/upgrade/basic/task.yaml
index 00c5394d6c..3bd63300a0 100644
--- a/tests/upgrade/basic/task.yaml
+++ b/tests/upgrade/basic/task.yaml
@@ -64,7 +64,7 @@ execute: |
prevsnapdver="$(snap --version|grep "snapd ")"
echo "$prevsnapdver" > prevsnapdver.out
- if [[ "$SPREAD_SYSTEM" = debian-* ]] ; then
+ if os.query is-debian; then
# For debian we install the latest core snap independently until
# the bug fix is on stable once 2.27 landed
snap install core
@@ -101,7 +101,7 @@ execute: |
# allow-downgrades prevents errors when new versions hit the archive, for instance,
# trying to install 2.11ubuntu1 over 2.11+0.16.04
pkg_extension="$(distro_get_package_extension)"
- if [[ "$SPREAD_SYSTEM" == arch-* ]]; then
+ if os.query is-arch; then
# Arch's pacman is a bit funky here, the command that's run is:
# pacman -U --noconfirm --force /home/gopath/snapd-*.pkg.tar.xz
# The official repo package contains snapd and snap-confine. The local test package