tests: Run in a chroot and unprivileged user namespaces.

* build-aux/test-env.in: Pass ‘--disable-chroot’ only when unprivileged
user namespace support is lacking and warn in that case.
* tests/store.scm ("build-things, check mode"): Use ‘gettimeofday’
rather than a shared file as a source of entropy.
("symlink is symlink")
("isolated environment", "inputs are read-only")
("inputs cannot be remounted read-write")
("build root cannot be made world-readable")
("/tmp, store, and /dev/{null,full} are writable")
("network is unreachable"): New tests.
* tests/processes.scm ("client + lock"): Skip when
‘unprivileged-user-namespace-supported?’ returns true.

Change-Id: I3b3c3ebdf6db5fd36ee70251d07b893c17ca1b84
This commit is contained in:
Ludovic Courtès 2025-01-22 23:48:14 +01:00
parent f854095b6f
commit 2f65438eba
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
3 changed files with 236 additions and 38 deletions

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018, 2025 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
;;;
;;; This file is part of GNU Guix.
@ -25,6 +25,8 @@
#:use-module (guix gexp)
#:use-module ((guix utils) #:select (call-with-temporary-directory))
#:use-module (gnu packages bootstrap)
#:use-module ((gnu build linux-container)
#:select (unprivileged-user-namespace-supported?))
#:use-module (guix tests)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-64)
@ -84,6 +86,11 @@
(and (kill (process-id daemon) 0)
(string-suffix? "guix-daemon" (first (process-command daemon)))))))
(when (unprivileged-user-namespace-supported?)
;; The test below assumes the build process can communicate with the outside
;; world via the TOKEN1 and TOKEN2 files, which is impossible when
;; guix-daemon is set up to build in separate namespaces.
(test-skip 1))
(test-assert* "client + lock"
(with-store store
(call-with-temporary-directory