services: databases: Don't specify a default postgresql version.
[jackhill/guix/guix.git] / gnu / tests / desktop.scm
CommitLineData
cd1ad27e
LC
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
3;;;
4;;; This file is part of GNU Guix.
5;;;
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.
10;;;
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.
15;;;
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/>.
18
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))
28
29\f
30;;;
31;;; Elogind.
32;;;
33
34(define (run-elogind-test vm)
35 (define test
36 (with-imported-modules '((gnu build marionette)
37 (guix build syscalls))
38 #~(begin
39 (use-modules (gnu build marionette)
40 (guix build syscalls)
41 (srfi srfi-64))
42
43 (define marionette
44 (make-marionette '(#$vm)))
45
46 (mkdir #$output)
47 (chdir #$output)
48
49 (test-begin "elogind")
50
51 ;; Log in as root on tty1, and check what 'loginctl' returns.
52 (test-equal "login on tty1"
d553ee80 53 '(("c1" "0" "root" "seat0" "tty1") ;session
cd1ad27e
LC
54 ("seat0") ;seat
55 ("0" "root")) ;user
56
57 (begin
58 ;; Wait for tty1.
59 (marionette-eval
60 '(begin
61 (use-modules (gnu services herd))
62 (start-service 'term-tty1))
63 marionette)
64 (marionette-control "sendkey ctrl-alt-f1" marionette)
65
66 ;; Now we can type.
67 (marionette-type "root\n" marionette)
68 (marionette-type "loginctl list-users --no-legend > users\n"
69 marionette)
70 (marionette-type "loginctl list-seats --no-legend > seats\n"
71 marionette)
72 (marionette-type "loginctl list-sessions --no-legend > sessions\n"
73 marionette)
74
75
76 ;; Read the three files.
77 (marionette-eval '(use-modules (rnrs io ports)) marionette)
78 (let ((guest-file (lambda (file)
79 (string-tokenize
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")))))
85
86 (test-end)
87 (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
88
89 (gexp->derivation "elogind" test))
90
91(define %test-elogind
92 (system-test
93 (name "elogind")
94 (description
95 "Test whether we can log in when elogind is enabled, and whether
96'loginctl' reports accurate user, session, and seat information.")
97 (value
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))))))