desktop.scm 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017, 2021 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. (define-module (gnu tests desktop)
  19. #:use-module (gnu tests)
  20. #:use-module (gnu services)
  21. #:use-module (gnu services dbus)
  22. #:use-module (gnu services desktop)
  23. #:use-module (gnu system vm)
  24. #:use-module (guix gexp)
  25. #:use-module (srfi srfi-1)
  26. #:export (%test-elogind))
  27. ;;;
  28. ;;; Elogind.
  29. ;;;
  30. (define (run-elogind-test vm)
  31. (define test
  32. (with-imported-modules '((gnu build marionette)
  33. (guix build syscalls))
  34. #~(begin
  35. (use-modules (gnu build marionette)
  36. (guix build syscalls)
  37. (srfi srfi-64))
  38. (define marionette
  39. (make-marionette '(#$vm)))
  40. (test-runner-current (system-test-runner #$output))
  41. (test-begin "elogind")
  42. ;; Log in as root on tty1, and check what 'loginctl' returns.
  43. (test-equal "login on tty1"
  44. '(("c1" "0" "root" "seat0" "tty1") ;session
  45. ("seat0") ;seat
  46. ("0" "root")) ;user
  47. (begin
  48. ;; Wait for tty1.
  49. (marionette-eval
  50. '(begin
  51. (use-modules (gnu services herd))
  52. (start-service 'term-tty1))
  53. marionette)
  54. (marionette-control "sendkey ctrl-alt-f1" marionette)
  55. ;; Now we can type.
  56. (marionette-type "root\n" marionette)
  57. (marionette-type "loginctl list-users --no-legend > users\n"
  58. marionette)
  59. (marionette-type "loginctl list-seats --no-legend > seats\n"
  60. marionette)
  61. (marionette-type "loginctl list-sessions --no-legend > sessions\n"
  62. marionette)
  63. ;; Read the three files.
  64. (marionette-eval '(use-modules (rnrs io ports)) marionette)
  65. (let ((guest-file (lambda (file)
  66. (string-tokenize
  67. (wait-for-file file marionette
  68. #:read 'get-string-all)))))
  69. (list (guest-file "/root/sessions")
  70. (guest-file "/root/seats")
  71. (guest-file "/root/users")))))
  72. (test-end))))
  73. (gexp->derivation "elogind" test))
  74. (define %test-elogind
  75. (system-test
  76. (name "elogind")
  77. (description
  78. "Test whether we can log in when elogind is enabled, and whether
  79. 'loginctl' reports accurate user, session, and seat information.")
  80. (value
  81. (let ((os (marionette-operating-system
  82. (simple-operating-system
  83. (service elogind-service-type)
  84. (service polkit-service-type)
  85. (service dbus-root-service-type))
  86. #:imported-modules '((gnu services herd)
  87. (guix combinators)))))
  88. (run-elogind-test (virtual-machine os))))))