Merge ~alfonsosanchezbeato/snappy-hwe-snaps/+git/pulseaudio:fix-tests into ~snappy-hwe-team/snappy-hwe-snaps/+git/pulseaudio:master

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: c6c785b2fc77ca90f2ea59fc9307c907b425cbc9
Merged at revision: cc080fd62696da35441f72194d97e84575888e19
Proposed branch: ~alfonsosanchezbeato/snappy-hwe-snaps/+git/pulseaudio:fix-tests
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/pulseaudio:master
Diff against target: 325 lines (+87/-111)
8 files modified
dev/null (+0/-8)
run-tests.sh (+51/-33)
snapcraft.yaml (+1/-0)
tests/lib/prepare-all.sh (+3/-42)
tests/lib/prepare.sh (+8/-9)
tests/lib/restore-each.sh (+4/-3)
tests/lib/utilities.sh (+17/-14)
tests/main/pactl-connects-to-server/task.yaml (+3/-2)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration Approve
Review via email: mp+387378@code.launchpad.net

Commit message

tests: fix ancillary scripts
run-tests.sh: update to latest template

Description of the change

tests: fix ancillary scripts
run-tests.sh: update to latest template

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 78254fff87a3aff9aff0efe5817b78b082bc73cf

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/1344/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 91f5885f1e9b428e24ad0202fe41fe4c1e429aaa

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/1345/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: c6c785b2fc77ca90f2ea59fc9307c907b425cbc9

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/1346/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/run-tests.sh b/run-tests.sh
index 0b0679d..7f827b6 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -1,4 +1,4 @@
1#!/bin/sh1#!/bin/bash
2#2#
3# Copyright (C) 2016 Canonical Ltd3# Copyright (C) 2016 Canonical Ltd
4#4#
@@ -16,64 +16,82 @@
1616
17set -e17set -e
1818
19TESTS_EXTRAS_URL="https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/tests-extras"19TESTS_EXTRAS_URL="https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/stack-snaps-tools"
20TESTS_EXTRAS_PATH=".tests-extras"20TESTS_EXTRAS_PATH="tests-extras"
2121
22# Display help.
23# This has to be in sync with the tests-extras/test-runner.sh script
24# functionalities as the parameters to this one are passed directly there
25# this function will quit the script because of the 'exec' keyword
26show_help() {22show_help() {
27 exec cat <<'EOF'23 exec cat <<'EOF'
28Usage: run-tests.sh [OPTIONS]24Usage: run-tests.sh [OPTIONS]
2925
30This is fetch & forget script and what it does is to fetch the26This is fetch & forget script and what it does is to fetch the
31tests-extras repository and execute the run-tests.sh script from27stack-snaps-tools repository and execute the run-tests.sh script from
32there passing arguments as-is.28there passing arguments as-is.
3329
34optional arguments:30When you see this message you don't have the tests-extras folder
35 --help Show this help message and exit31successfully populated in your workspace yet. Please rerun without
36 --channel Select another channel to build the base image from (default: stable)32specifying --help to proceed with the initial clone of the git repository.
37 --snap Extra snap to install
38 --debug Enable verbose debugging output
39 --test-from-channel Pull network-manager snap from the specified channel instead of building it from source
40 --force-new-image Force generating a new image used for testing
41EOF33EOF
42}34}
4335
44# Clone the tests-extras repository36# Clone the stack-snaps-tools repository
45clone_tests_extras() {37clone_tests_extras() {
46 echo "INFO: Fetching tests-extras scripts into $TESTS_EXTRAS_PATH ..."38 echo "INFO: Fetching stack-snaps-tools scripts into $TESTS_EXTRAS_PATH ..."
47 git clone -b master $TESTS_EXTRAS_URL $TESTS_EXTRAS_PATH >/dev/null 2>&139 if ! git clone -b master $TESTS_EXTRAS_URL $TESTS_EXTRAS_PATH >/dev/null 2>&1; then
48 if [ $? -ne 0 ]; then40 echo "ERROR: Failed to fetch the $TESTS_EXTRAS_URL repo, exiting.."
49 echo "ERROR: Failed to fetch the $TESTS_EXTRAS_URL repo, exiting.."41 exit 1
50 exit 142 fi
51 fi
52}43}
5344
54# Make sure the already cloned tests-extras repository is in a known and update45# Make sure the already cloned stack-snaps-tools repository is in a known and update
55# state before it is going to be used.46# state before it is going to be used.
56restore_and_update_tests_extras() {47restore_and_update_tests_extras() {
57 echo "INFO: Restoring and updating $TESTS_EXTRAS_PATH"48 echo "INFO: Restoring and updating $TESTS_EXTRAS_PATH"
58 cd $TESTS_EXTRAS_PATH && git reset --hard && git clean -dfx && git pull49 cd $TESTS_EXTRAS_PATH && git reset --hard && git clean -dfx && git pull
59 cd -50 cd -
60}51}
6152
62# ==============================================================================53# ==============================================================================
63# This is fetch & forget script and what it does is to fetch the tests-extras54# This is fetch & forget script and what it does is to fetch the stack-snaps-tools
64# repo and execute the run-tests.sh script from there passing arguments as-is.55# repo and execute the run-tests.sh script from there passing arguments as-is.
65#56#
66# The tests-extras repository ends up checked out in the snap tree but as a57# The stack-snaps-tools repository ends up checked out in the snap tree but as a
67# hidden directory which is re-used since then.58# hidden directory which is re-used since then.
6859
69# Display help w/o fetching anything and exit60# Find snap to use in the tests
70[ "$1" = "--help" ] && show_help61snaps=$(find . -maxdepth 1 -type f -name \
62 "*_*_$(dpkg-architecture -q DEB_HOST_ARCH).snap")
63while read -r snap_file; do
64 if [ -n "$snap" ]; then
65 printf "More than one snap revision in the folder\n"
66 exit 1
67 fi
68 snap=$PWD/${snap_file#*/}
69done < <(printf "%s\n" "$snaps")
70
71[ ! -d "$TESTS_EXTRAS_PATH" ] && [ "$1" = "--help" ] && show_help
7172
72if [ -d "$TESTS_EXTRAS_PATH" ]; then73if [ -d "$TESTS_EXTRAS_PATH" ]; then
73 restore_and_update_tests_extras74 restore_and_update_tests_extras
74else75else
75 clone_tests_extras76 clone_tests_extras
77fi
78
79# Any project-specific options for test-runner should be specified in
80# .tests_config under EXTRA_ARGS
81if [ -f ".tests_config" ]; then
82 # shellcheck disable=SC1091
83 . .tests_config
76fi84fi
7785
86# Get backends
87backends="--backends="
88separator=""
89while read -r be; do
90 backends=$backends$separator${be##*.}
91 separator=,
92done < <(yq r spread.yaml --printMode p 'backends.qemu.systems[*].*')
93
78echo "INFO: Executing tests runner"94echo "INFO: Executing tests runner"
79cd $TESTS_EXTRAS_PATH && ./tests-runner.sh "$@"95# shellcheck disable=SC2086
96cd $TESTS_EXTRAS_PATH &&
97 ./tests-runner.sh "$@" --snap="$snap" "$backends" $EXTRA_ARGS
diff --git a/snapcraft.yaml b/snapcraft.yaml
index b4bf686..5015ebb 100644
--- a/snapcraft.yaml
+++ b/snapcraft.yaml
@@ -129,6 +129,7 @@ parts:
129 - --disable-systemd-login129 - --disable-systemd-login
130 - --without-caps130 - --without-caps
131 - --disable-webrtc-aec131 - --disable-webrtc-aec
132 - --disable-dbus
132 - --disable-oss-output133 - --disable-oss-output
133 - --disable-oss-wrapper134 - --disable-oss-wrapper
134 - --disable-jack135 - --disable-jack
diff --git a/tests/lib/prepare-all.sh b/tests/lib/prepare-all.sh
index 00819cf..08ae20a 100644
--- a/tests/lib/prepare-all.sh
+++ b/tests/lib/prepare-all.sh
@@ -1,43 +1,4 @@
1#!/bin/bash1#!/bin/bash -x
22
3# We don't have to build a snap when we should use one from a3# Nothing to do here for the moment
4# channel4exit 0
5if [ -n "$SNAP_CHANNEL" ] ; then
6 exit 0
7fi
8
9# Setup classic snap and build the pulseaudio snap in there
10snap install --devmode --beta classic
11cat <<-EOF > /home/test/build-snap.sh
12#!/bin/sh
13set -ex
14
15export DEBIAN_FRONTEND=noninteractive
16
17# If there is a snap prebuilt for us, lets take that one to speed things up.
18if [ -e $PROJECT_PATH/${SNAP_NAME}_*_${SNAP_ARCH}.snap ] ; then
19 exit 0
20fi
21
22# FIXME: Enable propose for now until problems with conflicting systemd
23# packages between the Ubuntu Core image ppa and the archive are fixed.
24echo "deb http://archive.ubuntu.com/ubuntu/ xenial-proposed restricted main universe" > /etc/apt/sources.list.d/ubuntu-proposed.list
25echo "deb http://ppa.launchpad.net/snappy-dev/image/ubuntu xenial main" > /etc/apt/sources.list.d/ubuntu-image-ppa.list
26
27# Ensure we have the latest updates installed as the core snap
28# may be a bit out of date.
29apt update
30apt -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' full-upgrade -y --force-yes
31
32apt install -y --force-yes snapcraft
33cd /home/pulseaudio
34snapcraft clean
35snapcraft
36EOF
37
38chmod +x /home/test/build-snap.sh
39sudo classic /home/test/build-snap.sh
40snap remove classic
41
42# Make sure we have a snap build
43test -e /home/pulseaudio/${SNAP_NAME}*_${SNAP_ARCH}.snap
diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh
index e14a9b2..fc90454 100644
--- a/tests/lib/prepare.sh
+++ b/tests/lib/prepare.sh
@@ -1,6 +1,7 @@
1#!/bin/bash1#!/bin/bash -ex
22
3. $TESTSLIB/utilities.sh3# shellcheck source=tests/lib/utilities.sh
4. "$TESTSLIB"/utilities.sh
45
5echo "Wait for firstboot change to be ready"6echo "Wait for firstboot change to be ready"
6while ! snap changes | grep -q "Done"; do7while ! snap changes | grep -q "Done"; do
@@ -10,9 +11,10 @@ while ! snap changes | grep -q "Done"; do
10done11done
1112
12echo "Ensure fundamental snaps are still present"13echo "Ensure fundamental snaps are still present"
13. $TESTSLIB/snap-names.sh14# shellcheck source=tests/lib/snap-names.sh
14for name in $gadget_name $kernel_name $core_name; do15. "$TESTSLIB"/snap-names.sh
15 if ! snap list | grep -q $name ; then16for name in "$gadget_name" "$kernel_name" "$core_name"; do
17 if ! snap list | grep -q "$name" ; then
16 echo "Not all fundamental snaps are available, all-snap image not valid"18 echo "Not all fundamental snaps are available, all-snap image not valid"
17 echo "Currently installed snaps:"19 echo "Currently installed snaps:"
18 snap list20 snap list
@@ -20,9 +22,6 @@ for name in $gadget_name $kernel_name $core_name; do
20 fi22 fi
21done23done
2224
23echo "Kernel has a store revision"
24snap list | grep ^${kernel_name} | grep -E " [0-9]+\s+canonical"
25
26install_snap_under_test25install_snap_under_test
2726
28# Snapshot of the current snapd state for a later restore27# Snapshot of the current snapd state for a later restore
@@ -34,4 +33,4 @@ fi
3433
35# For debugging dump all snaps and connected slots/plugs34# For debugging dump all snaps and connected slots/plugs
36snap list35snap list
37snap interfaces36snap connections --all
diff --git a/tests/lib/restore-each.sh b/tests/lib/restore-each.sh
index 541ba8c..9427aa8 100644
--- a/tests/lib/restore-each.sh
+++ b/tests/lib/restore-each.sh
@@ -1,12 +1,13 @@
1#!/bin/bash1#!/bin/bash -ex
22
3. $TESTSLIB/snap-names.sh3# shellcheck source=tests/lib/snap-names.sh
4. "$TESTSLIB"/snap-names.sh
45
5# Remove all snaps not being the core, gadget, kernel or snap we're testing6# Remove all snaps not being the core, gadget, kernel or snap we're testing
6for snap in /snap/*; do7for snap in /snap/*; do
7 snap="${snap:6}"8 snap="${snap:6}"
8 case "$snap" in9 case "$snap" in
9 "bin" | "$gadget_name" | "$kernel_name" | "$core_name" | "$SNAP_NAME")10 README | bin | "$gadget_name" | "$kernel_name" | core* | snapd | "$SNAP_NAME")
10 ;;11 ;;
11 *)12 *)
12 snap remove "$snap"13 snap remove "$snap"
diff --git a/tests/lib/utilities.sh b/tests/lib/utilities.sh
index 08c0b8c..afc319d 100644
--- a/tests/lib/utilities.sh
+++ b/tests/lib/utilities.sh
@@ -12,23 +12,26 @@ install_snap_under_test() {
12 # without any network connectivity after reboot.12 # without any network connectivity after reboot.
13 if [ -n "$SNAP_CHANNEL" ] ; then13 if [ -n "$SNAP_CHANNEL" ] ; then
14 # Don't reinstall if we have it installed already14 # Don't reinstall if we have it installed already
15 if ! snap list | grep $SNAP_NAME ; then15 if ! snap list | grep "$SNAP_NAME"; then
16 snap install --$SNAP_CHANNEL $SNAP_NAME16 snap install --"$SNAP_CHANNEL" "$SNAP_NAME"
17 fi17 fi
18 else18 else
19 # Install first from store to avoid error when performing the connection19 # Install first from store to avoid error when performing the connection
20 snap install $SNAP_NAME20 sleep 3
21 snap install "$SNAP_NAME"
22 sleep 3
21 # Install prebuilt snap23 # Install prebuilt snap
22 snap install --dangerous ${PROJECT_PATH}/${SNAP_NAME}_*_${SNAP_ARCH}.snap24 snap install --dangerous "$PROJECT_PATH"/"$SNAP_NAME"_*_"$SNAP_ARCH".snap
23 fi25 sleep 3
24 if [ -n "$SNAP_AUTO_ALIASES" ]; then26 if [ -n "$SNAP_AUTO_ALIASES" ]; then
25 snapd_version=$(snap version | awk '/^snapd / {print $2; exit}')27 snapd_version=$(snap version | awk '/^snapd / {print $2; exit}')
26 for alias in $SNAP_AUTO_ALIASES ; do28 for alias in $SNAP_AUTO_ALIASES ; do
27 target=$SNAP_NAME.$alias29 target="$SNAP_NAME".$alias
28 if dpkg --compare-versions $snapd_version lt 2.25 ; then30 if dpkg --compare-versions "$snapd_version" lt 2.25 ; then
29 target=$SNAP_NAME31 target="$SNAP_NAME"
30 fi32 fi
31 snap alias $target $alias33 snap alias "$target" "$alias"
32 done34 done
35 fi
33 fi36 fi
34}37}
diff --git a/tests/main/module-loading-disabled/task.yaml b/tests/main/module-loading-disabled/task.yaml
35deleted file mode 10064438deleted file mode 100644
index 5ee9b43..0000000
--- a/tests/main/module-loading-disabled/task.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
1summary: Verify module loading is disabled
2
3description: |
4 As we're running pulseaudio in system mode (see https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/SystemWide/)
5 for more details we have module loading disabled to prevent any client from loading malicious code into the daemon.
6
7execute: |
8 ! /snap/bin/pactl load-module module-null-sink
diff --git a/tests/main/pactl-connects-to-server/task.yaml b/tests/main/pactl-connects-to-server/task.yaml
index 41dee48..f547f73 100644
--- a/tests/main/pactl-connects-to-server/task.yaml
+++ b/tests/main/pactl-connects-to-server/task.yaml
@@ -1,5 +1,6 @@
1summary: Test pactl is working1summary: Test pactl is working
22
3execute: |3execute: |
4 # Does it even work?4 sleep 3
5 /snap/bin/pactl info | grep -Pzq 'Server Name: pulseaudio'5 # Does it even work?
6 /snap/bin/pactl info | grep -Pzq 'Server Name: pulseaudio'

Subscribers

People subscribed via source and target branches