1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>.
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (gnu tests lightdm)
20 #:use-module (gnu bootloader)
21 #:use-module (gnu bootloader grub)
22 #:use-module (gnu packages)
23 #:use-module (gnu packages ocr)
24 #:use-module (gnu packages ratpoison)
25 #:use-module (gnu packages vnc)
26 #:use-module (gnu packages xorg)
27 #:use-module (gnu services)
28 #:use-module (gnu services base)
29 #:use-module (gnu services dbus)
30 #:use-module (gnu services desktop)
31 #:use-module (gnu services networking)
32 #:use-module (gnu services lightdm)
33 #:use-module (gnu services ssh)
34 #:use-module (gnu services xorg)
35 #:use-module (gnu system)
36 #:use-module (gnu system file-systems)
37 #:use-module (gnu system shadow)
38 #:use-module (gnu system vm)
39 #:use-module (gnu tests)
40 #:use-module (guix gexp)
41 #:use-module (guix modules)
42 #:use-module (srfi srfi-1)
43 #:export (%test-lightdm))
45 (define minimal-desktop-services
46 (list polkit-wheel-service
47 (service upower-service-type)
48 (accountsservice-service)
49 (service polkit-service-type)
52 x11-socket-directory-service))
57 (packages (cons* ocrad ratpoison xterm %base-packages))
59 (cons* (service lightdm-service-type
60 (lightdm-configuration
61 (allow-empty-passwords? #t)
66 (file-append tigervnc-server "/bin/Xvnc"
67 " -SecurityTypes None"))
68 (greeters (list (lightdm-gtk-greeter-configuration
69 (allow-debugging? #t))))
70 (seats (list (lightdm-seat-configuration
72 (user-session "ratpoison"))))))
75 (service dhcp-client-service-type)
76 (service openssh-service-type
77 (openssh-configuration
78 (permit-root-login #t)
79 (allow-empty-passwords? #t)))
80 (append minimal-desktop-services
81 (remove (lambda (service)
82 (eq? (service-kind service) guix-service-type))
85 (define (run-lightdm-test)
86 "Run tests in %LIGHTDM-OS."
88 (define os (marionette-operating-system
90 #:imported-modules (source-module-closure
91 '((gnu services herd)))))
93 (define vm (virtual-machine os))
96 (with-imported-modules (source-module-closure
97 '((gnu build marionette)))
99 (use-modules (gnu build marionette)
103 (let ((marionette (make-marionette (list #$vm))))
105 (test-runner-current (system-test-runner #$output))
106 (test-begin "lightdm")
108 (test-assert "service is running"
111 (use-modules (gnu services herd))
112 (start-service 'lightdm))
115 (test-assert "service can be stopped"
118 (use-modules (gnu services herd))
119 (stop-service 'lightdm))
122 (test-assert "service can be restarted"
125 (use-modules (gnu services herd))
126 (restart-service 'lightdm))
129 (test-assert "login screen is displayed"
130 ;; GNU Ocrad fails to recognize the "Log In" button text, so use
132 (wait-for-screen-text marionette
133 (cut string-contains <> "Log In")
134 #:ocr #$(file-append tesseract-ocr
137 (test-assert "can connect to TCP port 5900 on IPv4"
138 (wait-for-tcp-port 5900 marionette))
140 ;; The VNC server fails to listen to IPv6 due to "Error binding to
141 ;; address [::]:5900: Address already in use" (see:
142 ;; https://github.com/canonical/lightdm/issues/266).
144 (test-assert "can connect to TCP port 5900 on IPv6"
145 (wait-for-tcp-port 5900 marionette
147 `(make-socket-address
149 (inet-pton AF_INET6 "::1")
154 (gexp->derivation "lightdm-test" test))
156 (define %test-lightdm
159 (description "Basic tests for the LightDM service.")
160 (value (run-lightdm-test))))