aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2019-04-08 00:54:01 +0200
committerMarius Bakke <mbakke@fastmail.com>2019-04-08 00:54:01 +0200
commitba00235a9652bb129ff6867ffc3c7cfafe1cca09 (patch)
tree1ce56f512707e89362e1fed3d5b26d690462fbda /tests
parentf19ccdc62ca721b68745c35b046826b356f46c62 (diff)
parent0e2b0b05accdea7c3f016f8483d0ec04021114d3 (diff)
downloadpatches-ba00235a9652bb129ff6867ffc3c7cfafe1cca09.tar
patches-ba00235a9652bb129ff6867ffc3c7cfafe1cca09.tar.gz
Merge branch 'master' into staging
Diffstat (limited to 'tests')
-rw-r--r--tests/containers.scm11
-rw-r--r--tests/guix-environment-container.sh15
2 files changed, 25 insertions, 1 deletions
diff --git a/tests/containers.scm b/tests/containers.scm
index 5323e5037d..37408f380d 100644
--- a/tests/containers.scm
+++ b/tests/containers.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 David Thompson <davet@gnu.org>
+;;; Copyright © 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -52,6 +53,16 @@
#:namespaces '(user))))
(skip-if-unsupported)
+(test-assert "call-with-container, user namespace, guest UID/GID"
+ (zero?
+ (call-with-container '()
+ (lambda ()
+ (assert-exit (and (= 42 (getuid)) (= 77 (getgid)))))
+ #:guest-uid 42
+ #:guest-gid 77
+ #:namespaces '(user))))
+
+(skip-if-unsupported)
(test-assert "call-with-container, uts namespace"
(zero?
(call-with-container '()
diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh
index f2221af95b..78507f76c0 100644
--- a/tests/guix-environment-container.sh
+++ b/tests/guix-environment-container.sh
@@ -44,6 +44,19 @@ else
test $? = 42
fi
+# By default, the UID inside the container should be the same as outside.
+uid="`id -u`"
+inner_uid="`guix environment -C --ad-hoc --bootstrap guile-bootstrap \
+ -- guile -c '(display (getuid))'`"
+test $inner_uid = $uid
+
+# When '--user' is passed, the UID should be 1000. (Note: Use a separate HOME
+# so that we don't run into problems when the test directory is under /home.)
+export tmpdir
+inner_uid="`HOME=$tmpdir guix environment -C --ad-hoc --bootstrap guile-bootstrap \
+ --user=gnu-guix -- guile -c '(display (getuid))'`"
+test $inner_uid = 1000
+
if test "x$USER" = "x"; then USER="`id -un`"; fi
# Check whether /etc/passwd and /etc/group are valid.
@@ -123,7 +136,7 @@ rm $tmpdir/mounts
# Test that user can be mocked.
usertest='(exit (and (string=? (getenv "HOME") "/home/foognu")
- (string=? (passwd:name (getpwuid 0)) "foognu")
+ (string=? (passwd:name (getpwuid 1000)) "foognu")
(file-exists? "/home/foognu/umock")))'
touch "$tmpdir/umock"
HOME="$tmpdir" guix environment --bootstrap --container --user=foognu \