[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/02: tests: Ensure 'unshare' works before relying on it.
From: |
guix-commits |
Subject: |
01/02: tests: Ensure 'unshare' works before relying on it. |
Date: |
Thu, 9 May 2019 11:42:38 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 8deb65c37850bfca36429f3fe5239bd9236f969c
Author: Ludovic Courtès <address@hidden>
Date: Thu May 9 17:13:00 2019 +0200
tests: Ensure 'unshare' works before relying on it.
Fixes <https://bugs.gnu.org/35642>.
Reported by Josh Holland <address@hidden>.
* tests/guix-pack-relocatable.sh: Before invoking 'unshare' at the
bottom, add "if unshare -r true" condition.
* tests/guix-pack.sh: Likewise.
---
tests/guix-pack-relocatable.sh | 15 +++++++++++----
tests/guix-pack.sh | 4 ++--
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/tests/guix-pack-relocatable.sh b/tests/guix-pack-relocatable.sh
index 38dcf1e..c45a679 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"
diff --git a/tests/guix-pack.sh b/tests/guix-pack.sh
index a43f4d1..3cd0404 100644
--- a/tests/guix-pack.sh
+++ b/tests/guix-pack.sh
@@ -1,6 +1,6 @@
# GNU Guix --- Functional package management for GNU
# Copyright © 2018 Chris Marusich <address@hidden>
-# Copyright © 2018 Ludovic Courtès <address@hidden>
+# Copyright © 2018, 2019 Ludovic Courtès <address@hidden>
#
# This file is part of GNU Guix.
#
@@ -59,7 +59,7 @@ is_available () {
type "$1" > /dev/null
}
-if is_available chroot && is_available unshare; then
+if is_available chroot && is_available unshare && unshare -r true; then
# Verify we can use what we built.
unshare -r chroot . /opt/gnu/bin/guile --version
cd -