1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
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 desktop)
20 #:use-module (gnu tests)
21 #:use-module (gnu services)
22 #:use-module (gnu services dbus)
23 #:use-module (gnu services desktop)
24 #:use-module (gnu system vm)
25 #:use-module (guix gexp)
26 #:use-module (srfi srfi-1)
27 #:export (%test-elogind))
34 (define (run-elogind-test vm)
36 (with-imported-modules '((gnu build marionette)
37 (guix build syscalls))
39 (use-modules (gnu build marionette)
44 (make-marionette '(#$vm)))
49 (test-begin "elogind")
51 ;; Log in as root on tty1, and check what 'loginctl' returns.
52 (test-equal "login on tty1"
53 '(("c1" "0" "root" "seat0" "tty1") ;session
61 (use-modules (gnu services herd))
62 (start-service 'term-tty1))
64 (marionette-control "sendkey ctrl-alt-f1" marionette)
67 (marionette-type "root\n" marionette)
68 (marionette-type "loginctl list-users --no-legend > users\n"
70 (marionette-type "loginctl list-seats --no-legend > seats\n"
72 (marionette-type "loginctl list-sessions --no-legend > sessions\n"
76 ;; Read the three files.
77 (marionette-eval '(use-modules (rnrs io ports)) marionette)
78 (let ((guest-file (lambda (file)
80 (wait-for-file file marionette
81 #:read 'get-string-all)))))
82 (list (guest-file "/root/sessions")
83 (guest-file "/root/seats")
84 (guest-file "/root/users")))))
87 (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
89 (gexp->derivation "elogind" test))
95 "Test whether we can log in when elogind is enabled, and whether
96 'loginctl' reports accurate user, session, and seat information.")
98 (let ((os (marionette-operating-system
99 (simple-operating-system
100 (service elogind-service-type)
101 (service polkit-service-type)
102 (service dbus-root-service-type))
103 #:imported-modules '((gnu services herd)
104 (guix combinators)))))
105 (run-elogind-test (virtual-machine os))))))