summaryrefslogtreecommitdiff
path: root/gnu/tests
diff options
context:
space:
mode:
authorLudovic Courtès <[email protected]>2022-06-08 14:46:24 +0200
committerLudovic Courtès <[email protected]>2022-06-08 14:46:24 +0200
commit8c3e9da13a3c92a7db308db8c0d81cb474ad7799 (patch)
tree88d06952aa5cc3a9c4991d9c43eb7950ff174fe1 /gnu/tests
parent5439c04ebdb7b6405f5ea2446b375f1d155a8d95 (diff)
parent0c5299200ffcd16370f047b7ccb187c60f30da34 (diff)
Merge branch 'master' into core-updates
Diffstat (limited to 'gnu/tests')
-rw-r--r--gnu/tests/install.scm114
-rw-r--r--gnu/tests/messaging.scm21
-rw-r--r--gnu/tests/ssh.scm46
-rw-r--r--gnu/tests/version-control.scm32
-rw-r--r--gnu/tests/virtualization.scm32
-rw-r--r--gnu/tests/web.scm6
6 files changed, 174 insertions, 77 deletions
diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm
index be8bb1b583..3754966140 100644
--- a/gnu/tests/install.scm
+++ b/gnu/tests/install.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <[email protected]>
+;;; Copyright © 2016-2022 Ludovic Courtès <[email protected]>
;;; Copyright © 2017, 2019, 2021 Tobias Geerinckx-Rice <[email protected]>
;;; Copyright © 2020 Mathieu Othacehe <[email protected]>
;;; Copyright © 2020 Danny Milosavljevic <[email protected]>
@@ -66,6 +66,7 @@
%test-separate-home-os
%test-raid-root-os
%test-encrypted-root-os
+ %test-encrypted-home-os
%test-encrypted-root-not-boot-os
%test-btrfs-root-os
%test-btrfs-root-on-subvolume-os
@@ -923,6 +924,117 @@ reboot\n")
;;;
+;;; LUKS-encrypted /home, unencrypted root.
+;;;
+
+(define-os-with-source (%encrypted-home-os %encrypted-home-os-source)
+ (use-modules (gnu) (gnu tests))
+
+ (operating-system
+ (host-name "cipherhome")
+ (timezone "Europe/Paris")
+ (locale "en_US.utf8")
+
+ (bootloader (bootloader-configuration
+ (bootloader grub-bootloader)
+ (targets (list "/dev/vdb"))))
+
+ ;; Note: Do not pass "console=ttyS0" so we can use our passphrase prompt
+ ;; detection logic in 'enter-luks-passphrase'.
+
+ (mapped-devices (list (mapped-device
+ (source (uuid "12345678-1234-1234-1234-123456789abc"))
+ (target "the-home-device")
+ (type luks-device-mapping))))
+ (file-systems (cons* (file-system
+ (device (file-system-label "root-fs"))
+ (mount-point "/")
+ (type "ext4"))
+ (file-system
+ (device (file-system-label "home-fs"))
+ (mount-point "/home")
+ (type "ext4")
+ (dependencies mapped-devices))
+ %base-file-systems))
+ (users %base-user-accounts)
+ (services (cons (service marionette-service-type
+ (marionette-configuration
+ (imported-modules '((gnu services herd)
+ (guix combinators)))))
+ %base-services))))
+
+(define %encrypted-home-installation-script
+ (string-append "\
+. /etc/profile
+set -e -x
+guix --version
+
+export GUIX_BUILD_OPTIONS=--no-grafts
+parted --script /dev/vdb mklabel gpt \\
+ mkpart primary ext2 1M 3M \\
+ mkpart primary ext2 3M 1.6G \\
+ mkpart primary 1.6G 2.0G \\
+ set 1 boot on \\
+ set 1 bios_grub on
+
+echo -n " %luks-passphrase " | \\
+ cryptsetup luksFormat --uuid=12345678-1234-1234-1234-123456789abc -q /dev/vdb3 -
+echo -n " %luks-passphrase " | \\
+ cryptsetup open --type luks --key-file - /dev/vdb3 the-home-device
+
+mkfs.ext4 -L root-fs /dev/vdb2
+mkfs.ext4 -L home-fs /dev/mapper/the-home-device
+mount /dev/vdb2 /mnt
+mkdir /mnt/home
+mount /dev/mapper/the-home-device /mnt/home
+df -h /mnt /mnt/home
+herd start cow-store /mnt
+mkdir /mnt/etc
+cp /etc/target-config.scm /mnt/etc/config.scm
+guix system init /mnt/etc/config.scm /mnt --no-substitutes
+sync
+reboot\n"))
+
+(define (enter-luks-passphrase-for-home marionette)
+ "Return a gexp to be inserted in the basic system test running on MARIONETTE
+to enter the LUKS passphrase. Note that 'cryptsetup open' in this case is
+launched as a shepherd service."
+ (let ((ocrad (file-append ocrad "/bin/ocrad")))
+ #~(begin
+ (define (passphrase-prompt? text)
+ (string-contains (pk 'screen-text text) "Enter pass"))
+
+ (test-assert "enter LUKS passphrase for the shepherd service"
+ (begin
+ ;; XXX: Here we use OCR as well but we could instead use QEMU
+ ;; '-serial stdio' and run it in an input pipe,
+ (wait-for-screen-text #$marionette passphrase-prompt?
+ #:ocrad #$ocrad
+ #:timeout 120)
+ (marionette-type #$(string-append %luks-passphrase "\n")
+ #$marionette)
+
+ ;; Take a screenshot for debugging purposes.
+ (marionette-control (string-append "screendump " #$output
+ "/shepherd-passphrase.ppm")
+ #$marionette))))))
+
+(define %test-encrypted-home-os
+ (system-test
+ (name "encrypted-home-os")
+ (description
+ "Test functionality of an OS installed with a LUKS /home partition")
+ (value
+ (mlet* %store-monad ((images (run-install %encrypted-home-os
+ %encrypted-home-os-source
+ #:script
+ %encrypted-home-installation-script))
+ (command (qemu-command* images)))
+ (run-basic-test %encrypted-home-os command "encrypted-home-os"
+ #:initialization enter-luks-passphrase-for-home)))))
+
+
+;;;
;;; LUKS-encrypted root file system and /boot in a non-encrypted partition.
;;;
diff --git a/gnu/tests/messaging.scm b/gnu/tests/messaging.scm
index 202a1c2f73..1e26c0ddea 100644
--- a/gnu/tests/messaging.scm
+++ b/gnu/tests/messaging.scm
@@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017, 2018 Clément Lassieur <[email protected]>
-;;; Copyright © 2017, 2018, 2021 Ludovic Courtès <[email protected]>
+;;; Copyright © 2017-2018, 2021-2022 Ludovic Courtès <[email protected]>
;;; Copyright © 2018 Efraim Flashner <[email protected]>
;;;
;;; This file is part of GNU Guix.
@@ -198,25 +198,6 @@
(start-service 'bitlbee))
marionette))
- (test-equal "valid PID"
- #$(file-append bitlbee "/sbin/bitlbee")
- (marionette-eval
- '(begin
- (use-modules (srfi srfi-1)
- (gnu services herd))
-
- (let ((bitlbee
- (find (lambda (service)
- (equal? '(bitlbee)
- (live-service-provision service)))
- (current-services))))
- (and (pk 'bitlbee-service bitlbee)
- (let ((pid (live-service-running bitlbee)))
- (readlink (string-append "/proc/"
- (number->string pid)
- "/exe"))))))
- marionette))
-
(test-assert "connect"
(let* ((address (make-socket-address AF_INET INADDR_LOOPBACK
6667))
diff --git a/gnu/tests/ssh.scm b/gnu/tests/ssh.scm
index 791ff7b73f..3f550db5ea 100644
--- a/gnu/tests/ssh.scm
+++ b/gnu/tests/ssh.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <[email protected]>
+;;; Copyright © 2016-2022 Ludovic Courtès <[email protected]>
;;; Copyright © 2017, 2018 Clément Lassieur <[email protected]>
;;; Copyright © 2017 Marius Bakke <[email protected]>
;;;
@@ -120,23 +120,35 @@ root with an empty password."
marionette))
;; Check sshd's PID file.
- (test-equal "sshd PID"
- (wait-for-file #$pid-file marionette)
- (marionette-eval
- '(begin
- (use-modules (gnu services herd)
- (srfi srfi-1))
-
- (live-service-running
- (find (lambda (live)
- (memq 'ssh-daemon
- (live-service-provision live)))
- (current-services))))
- marionette))
-
- (test-assert "wait for port 22"
+ (test-assert "sshd PID"
+ (let ((pid (marionette-eval
+ '(begin
+ (use-modules (gnu services herd)
+ (srfi srfi-1))
+
+ (live-service-running
+ (find (lambda (live)
+ (memq 'ssh-daemon
+ (live-service-provision live)))
+ (current-services))))
+ marionette)))
+ (if #$pid-file
+ (= pid (wait-for-file #$pid-file marionette))
+ pid)))
+
+ (test-assert "wait for port 22, IPv4"
(wait-for-tcp-port 22 marionette))
+ (test-assert "wait for port 22, IPv6"
+ ;; Make sure it's also available as IPv6.
+ ;; See <https://issues.guix.gnu.org/55335>.
+ (wait-for-tcp-port 22 marionette
+ #:address
+ `(make-socket-address
+ AF_INET6
+ (inet-pton AF_INET6 "::1")
+ 22)))
+
;; Connect to the guest over SSH. Make sure we can run a shell
;; command there.
(test-equal "shell command"
@@ -222,7 +234,7 @@ root with an empty password."
(openssh-configuration
(permit-root-login #t)
(allow-empty-passwords? #t)))
- "/var/run/sshd.pid"
+ #f ;inetd-style, no PID file
#:sftp? #t))))
(define %test-dropbear
diff --git a/gnu/tests/version-control.scm b/gnu/tests/version-control.scm
index fd3dba88ba..18c68a58f2 100644
--- a/gnu/tests/version-control.scm
+++ b/gnu/tests/version-control.scm
@@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017, 2018 Oleg Pykhalov <[email protected]>
-;;; Copyright © 2017, 2018, 2020, 2021 Ludovic Courtès <[email protected]>
+;;; Copyright © 2017-2018, 2020-2022 Ludovic Courtès <[email protected]>
;;; Copyright © 2017, 2018 Clément Lassieur <[email protected]>
;;; Copyright © 2018 Christopher Baines <[email protected]>
;;;
@@ -154,19 +154,11 @@ HTTP-PORT."
;; Wait for nginx to be up and running.
(test-assert "nginx running"
- (marionette-eval
- '(begin
- (use-modules (gnu services herd))
- (start-service 'nginx))
- marionette))
+ (wait-for-file "/var/run/nginx/pid" marionette))
;; Wait for fcgiwrap to be up and running.
(test-assert "fcgiwrap running"
- (marionette-eval
- '(begin
- (use-modules (gnu services herd))
- (start-service 'fcgiwrap))
- marionette))
+ (wait-for-tcp-port 9000 marionette))
;; Make sure the PID file is created.
(test-assert "PID file"
@@ -272,11 +264,7 @@ HTTP-PORT."
;; Wait for nginx to be up and running.
(test-assert "nginx running"
- (marionette-eval
- '(begin
- (use-modules (gnu services herd))
- (start-service 'nginx))
- marionette))
+ (wait-for-file "/var/run/nginx/pid" marionette))
;; Make sure Git test repository is created.
(test-assert "Git test repository"
@@ -486,17 +474,7 @@ HTTP-PORT."
;; Wait for nginx to be up and running.
(test-assert "nginx running"
- (marionette-eval
- '(begin
- (use-modules (gnu services herd))
- (start-service 'nginx))
- marionette))
-
- ;; Make sure the PID file is created.
- (test-assert "PID file"
- (marionette-eval
- '(file-exists? "/var/run/nginx/pid")
- marionette))
+ (wait-for-file "/var/run/nginx/pid" marionette))
;; Make sure Git test repository is created.
(test-assert "Git test repository"
diff --git a/gnu/tests/virtualization.scm b/gnu/tests/virtualization.scm
index 628cd0549b..299acc4945 100644
--- a/gnu/tests/virtualization.scm
+++ b/gnu/tests/virtualization.scm
@@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Christopher Baines <[email protected]>
-;;; Copyright © 2020, 2021 Ludovic Courtès <[email protected]>
+;;; Copyright © 2020-2022 Ludovic Courtès <[email protected]>
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <[email protected]>
;;; Copyright © 2021 Pierre Langlois <[email protected]>
;;;
@@ -31,8 +31,8 @@
#:use-module (gnu services dbus)
#:use-module (gnu services networking)
#:use-module (gnu services virtualization)
- #:use-module (gnu packages virtualization)
#:use-module (gnu packages ssh)
+ #:use-module (gnu packages virtualization)
#:use-module (guix gexp)
#:use-module (guix records)
#:use-module (guix store)
@@ -151,8 +151,8 @@
(operating-system os)
(memory-size (* 1024 3))))
- (define run-uname-over-ssh
- ;; Program that runs 'uname' over SSH and prints the result on standard
+ (define (run-command-over-ssh . command)
+ ;; Program that runs COMMAND over SSH and prints the result on standard
;; output.
(let ()
(define run
@@ -173,12 +173,12 @@
(userauth-password! session "")
(display
(get-string-all
- (open-remote-input-pipe* session "uname" "-on"))))
+ (open-remote-input-pipe* session #$@command))))
(status
(error "could not connect to childhurd over SSH"
session status)))))))
- (program-file "run-uname-over-ssh" run)))
+ (program-file "run-command-over-ssh" run)))
(define test
(with-imported-modules '((gnu build marionette))
@@ -242,9 +242,27 @@
(use-modules (ice-9 popen))
(get-string-all
- (open-input-pipe #$run-uname-over-ssh)))
+ (open-input-pipe #$(run-command-over-ssh "uname" "-on"))))
marionette))
+ (test-assert "guix-daemon up and running"
+ (let ((drv (marionette-eval
+ '(begin
+ (use-modules (ice-9 popen))
+
+ (get-string-all
+ (open-input-pipe
+ #$(run-command-over-ssh "guix" "build" "coreutils"
+ "--no-grafts" "-d"))))
+ marionette)))
+ ;; We cannot compare the .drv with (raw-derivation-file
+ ;; coreutils) on the host: they may differ due to fixed-output
+ ;; derivations and changes introduced compared to the 'guix'
+ ;; package snapshot.
+ (and (string-suffix? ".drv"
+ (pk 'drv (string-trim-right drv)))
+ drv)))
+
(test-end))))
(gexp->derivation "childhurd-test" test))
diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm
index 4e8eceaa2b..7a585e618d 100644
--- a/gnu/tests/web.scm
+++ b/gnu/tests/web.scm
@@ -481,11 +481,7 @@ HTTP-PORT."
(test-begin "tailon")
(test-assert "service running"
- (marionette-eval
- '(begin
- (use-modules (gnu services herd))
- (start-service 'tailon))
- marionette))
+ (wait-for-tcp-port 8080 marionette))
(test-equal "http-get"
200