desktop.scm 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. (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. (mkdir #$output)
  41. (chdir #$output)
  42. (test-begin "elogind")
  43. ;; Log in as root on tty1, and check what 'loginctl' returns.
  44. (test-equal "login on tty1"
  45. '(("c1" "0" "root" "seat0" "/dev/tty1") ;session
  46. ("seat0") ;seat
  47. ("0" "root")) ;user
  48. (begin
  49. ;; Wait for tty1.
  50. (marionette-eval
  51. '(begin
  52. (use-modules (gnu services herd))
  53. (start-service 'term-tty1))
  54. marionette)
  55. (marionette-control "sendkey ctrl-alt-f1" marionette)
  56. ;; Now we can type.
  57. (marionette-type "root\n" marionette)
  58. (marionette-type "loginctl list-users --no-legend > users\n"
  59. marionette)
  60. (marionette-type "loginctl list-seats --no-legend > seats\n"
  61. marionette)
  62. (marionette-type "loginctl list-sessions --no-legend > sessions\n"
  63. marionette)
  64. ;; Read the three files.
  65. (marionette-eval '(use-modules (rnrs io ports)) marionette)
  66. (let ((guest-file (lambda (file)
  67. (string-tokenize
  68. (wait-for-file file marionette
  69. #:read 'get-string-all)))))
  70. (list (guest-file "/root/sessions")
  71. (guest-file "/root/seats")
  72. (guest-file "/root/users")))))
  73. (test-end)
  74. (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
  75. (gexp->derivation "elogind" test))
  76. (define %test-elogind
  77. (system-test
  78. (name "elogind")
  79. (description
  80. "Test whether we can log in when elogind is enabled, and whether
  81. 'loginctl' reports accurate user, session, and seat information.")
  82. (value
  83. (let ((os (marionette-operating-system
  84. (simple-operating-system
  85. (service elogind-service-type)
  86. (service polkit-service-type)
  87. (service dbus-root-service-type))
  88. #:imported-modules '((gnu services herd)
  89. (guix combinators)))))
  90. (run-elogind-test (virtual-machine os))))))