aboutsummaryrefslogtreecommitdiff
path: root/tests/guix-pack-relocatable.sh
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-05-09 17:13:00 +0200
committerLudovic Courtès <ludo@gnu.org>2019-05-09 17:42:31 +0200
commit8deb65c37850bfca36429f3fe5239bd9236f969c (patch)
tree700a253b1398623c6c8ec976f4056b95d22273f3 /tests/guix-pack-relocatable.sh
parent18160c3408a6481f70e7f15afe5009edd2a731ae (diff)
downloadguix-8deb65c37850bfca36429f3fe5239bd9236f969c.tar
guix-8deb65c37850bfca36429f3fe5239bd9236f969c.tar.gz
tests: Ensure 'unshare' works before relying on it.
Fixes <https://bugs.gnu.org/35642>. Reported by Josh Holland <josh@inv.alid.pw>. * tests/guix-pack-relocatable.sh: Before invoking 'unshare' at the bottom, add "if unshare -r true" condition. * tests/guix-pack.sh: Likewise.
Diffstat (limited to 'tests/guix-pack-relocatable.sh')
-rw-r--r--tests/guix-pack-relocatable.sh15
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/guix-pack-relocatable.sh b/tests/guix-pack-relocatable.sh
index 38dcf1e485..c45a679bb1 100644
--- a/tests/guix-pack-relocatable.sh
+++ b/tests/guix-pack-relocatable.sh
@@ -65,8 +65,15 @@ export relocatable_option
tarball="`guix pack $relocatable_option -S /Bin=bin sed`"
(cd "$test_directory"; tar xvf "$tarball")
-# Run that relocatable 'sed' in a user namespace where we "erase" the store by
-# mounting an empty file system on top of it. That way, we exercise the
-# wrapper code that creates the user namespace and bind-mounts the store.
-unshare -mrf sh -c 'mount -t tmpfs none "$STORE_PARENT"; echo "$STORE_PARENT"/*; "$test_directory/Bin/sed" --version > "$test_directory/output"'
+if unshare -r true # Are user namespaces supported?
+then
+ # Run that relocatable 'sed' in a user namespace where we "erase" the store by
+ # mounting an empty file system on top of it. That way, we exercise the
+ # wrapper code that creates the user namespace and bind-mounts the store.
+ unshare -mrf sh -c 'mount -t tmpfs none "$STORE_PARENT"; echo "$STORE_PARENT"/*; "$test_directory/Bin/sed" --version > "$test_directory/output"'
+else
+ # Run the relocatable 'sed' in the current namespaces. This is a weak
+ # test because we're going to access store items from the host store.
+ "$test_directory/Bin/sed" --version > "$test_directory/output"
+fi
grep 'GNU sed' "$test_directory/output"