Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dirs,interfaces,overlord,snap,snapenv,test: export per-snap XDG_RUNTIME_DIR per user (LP: #1620442) #2281

Merged
merged 11 commits into from
Nov 17, 2016
Prev Previous commit
Next Next commit
tests: add test for XDG and SNAP variables
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
  • Loading branch information
zyga committed Nov 16, 2016
commit 443590efa16c42ce67e748953741c88f4cebd25b
31 changes: 31 additions & 0 deletions tests/main/snap-env/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
summary: inspect all the set environment variables prefixed with SNAP_ and XDG_
prepare: |
snapbuild $TESTSLIB/snaps/test-snapd-tools .
snap install --dangerous test-snapd-tools_1.0_all.snap
restore: |
rm -f *.snap
execute: |
echo "Collect SNAP and XDG environment variables"
test-snapd-tools.env | egrep '^SNAP_' | sort > snap-vars.txt
test-snapd-tools.env | egrep '^XDG_' | sort > xdg-vars.txt

echo "Ensure that SNAP environment variables are what we expect"
egrep -q '^SNAP_ARCH=(amd64|i386|arm64|armhf)$' snap-vars.txt
egrep -q '^SNAP_COMMON=/var/snap/test-snapd-tools/common$' snap-vars.txt
egrep -q '^SNAP_DATA=/var/snap/test-snapd-tools/x1$' snap-vars.txt
egrep -q '^SNAP_LIBRARY_PATH=/var/lib/snapd/lib/gl:$' snap-vars.txt
egrep -q '^SNAP_NAME=test-snapd-tools$' snap-vars.txt
# XXX: probably not something we ough to test
# egrep -q '^SNAP_REEXEC=0$' snap-vars.txt
egrep -q '^SNAP_REVISION=x1$' snap-vars.txt
egrep -q '^SNAP_USER_COMMON=/root/snap/test-snapd-tools/common$' snap-vars.txt
egrep -q '^SNAP_USER_DATA=/root/snap/test-snapd-tools/x1$' snap-vars.txt
egrep -q '^SNAP_VERSION=1.0$' snap-vars.txt
test $(wc -l < snap-vars.txt) -eq 10

echo "Enure that XDG environment variables are what we expect"
egrep -q '^XDG_RUNTIME_DIR=/run/user/0/snap.test-snapd-tools$' xdg-vars.txt
egrep -q '^XDG_SESSION_ID=1$' xdg-vars.txt
test $(wc -l < xdg-vars.txt) -eq 2
debug: |
cat *-vars.txt