summaryrefslogtreecommitdiff
path: root/tests/test-run.sh
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@microsoft.com>2020-05-27 14:23:03 +0100
committerAlexander Larsson <alexander.larsson@gmail.com>2020-07-24 10:28:30 +0200
commit7872935e129db8e2bab72dbadf24368d17ba1102 (patch)
tree7b9cf2e4cde1495bd04a1018255677b05287809e /tests/test-run.sh
parent1bf5f2ed9e95e060517db82b7b7b4153a8bb805c (diff)
downloadflatpak-7872935e129db8e2bab72dbadf24368d17ba1102.tar.gz
run: implement sandbox host os-release interface
If available, always read-only bind-mount /etc/os-release as /run/host/os-release (or /usr/lib/os-release as fallback) as suggested by the os-release specification: https://www.freedesktop.org/software/systemd/man/os-release.html
Diffstat (limited to 'tests/test-run.sh')
-rw-r--r--tests/test-run.sh24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/test-run.sh b/tests/test-run.sh
index fe6e9add..57740a3b 100644
--- a/tests/test-run.sh
+++ b/tests/test-run.sh
@@ -24,7 +24,7 @@ set -euo pipefail
skip_without_bwrap
skip_revokefs_without_fuse
-echo "1..16"
+echo "1..17"
# Use stable rather than master as the branch so we can test that the run
# command automatically finds the branch correctly
@@ -80,6 +80,28 @@ assert_file_has_content runtime-fpi "^runtime=runtime/org\.test\.Platform/$ARCH/
ok "run a runtime"
+if [ -f /etc/os-release ]; then
+ run_sh org.test.Platform cat /run/host/os-release >os-release
+ (cd /etc; md5sum os-release) | md5sum -c
+
+ ARGS="--filesystem=host-etc" run_sh org.test.Platform cat /run/host/os-release >os-release
+ (cd /etc; md5sum os-release) | md5sum -c
+
+ if run_sh org.test.Platform "echo test >> /run/host/os-release"; then exit 1; fi
+ if run_sh org.test.Platform "echo test >> /run/host/os-release"; then exit 1; fi
+elif [ -f /usr/lib/os-release ]; then
+ run_sh org.test.Platform cat /run/host/os-release >os-release
+ (cd /usr/lib; md5sum os-release) | md5sum -c
+
+ ARGS="--filesystem=host-os" run_sh org.test.Platform cat /run/host/os-release >os-release
+ (cd /usr/lib; md5sum os-release) | md5sum -c
+
+ if run_sh org.test.Platform "echo test >> /run/host/os-release"; then exit 1; fi
+ if run_sh org.test.Platform "echo test >> /run/host/os-release"; then exit 1; fi
+fi
+
+ok "host os-release"
+
if run org.test.Nonexistent 2> run-error-log; then
assert_not_reached "Unexpectedly able to run non-existent runtime"
fi