gdm.scm 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2022⁠–⁠2023 Bruno Victal <mirai@makinata.eu>.
  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 gdm)
  19. #:use-module (gnu tests)
  20. #:use-module (gnu packages freedesktop)
  21. #:use-module (gnu packages ocr)
  22. #:use-module (gnu services)
  23. #:use-module (gnu services desktop)
  24. #:use-module (gnu services xorg)
  25. #:use-module (gnu system)
  26. #:use-module (gnu system vm)
  27. #:use-module (guix gexp)
  28. #:use-module (ice-9 format)
  29. #:export (%test-gdm-x11
  30. %test-gdm-wayland))
  31. (define* (make-os #:key wayland?)
  32. (operating-system
  33. (inherit %simple-os)
  34. (services
  35. (modify-services %desktop-services
  36. (gdm-service-type config => (gdm-configuration
  37. (inherit config)
  38. (wayland? wayland?)))))))
  39. (define* (run-gdm-test #:key wayland?)
  40. "Run tests in a vm which has gdm running."
  41. (define os
  42. (marionette-operating-system
  43. (make-os #:wayland? wayland?)
  44. #:imported-modules '((gnu services herd))))
  45. (define vm
  46. (virtual-machine
  47. (operating-system os)
  48. (memory-size 1024)))
  49. (define name (format #f "gdm-~:[x11~;wayland~]" wayland?))
  50. (define test
  51. (with-imported-modules '((gnu build marionette))
  52. #~(begin
  53. (use-modules (gnu build marionette)
  54. (ice-9 format)
  55. (srfi srfi-26)
  56. (srfi srfi-64))
  57. (let ((marionette (make-marionette (list #$vm)))
  58. (expected-session-type #$(if wayland? "wayland" "x11")))
  59. (test-runner-current (system-test-runner #$output))
  60. (test-begin #$name)
  61. ;; service for gdm is called xorg-server
  62. (test-assert "service is running"
  63. (marionette-eval
  64. '(begin
  65. (use-modules (gnu services herd))
  66. (start-service 'xorg-server))
  67. marionette))
  68. (test-group "gdm ready"
  69. (test-assert "PID file present"
  70. (wait-for-file "/var/run/gdm/gdm.pid" marionette))
  71. ;; Waiting for gdm.pid is not enough, tests may still sporadically
  72. ;; fail; ensure that the login screen is up.
  73. ;; XXX: GNU Ocrad works but with '--invert' only.
  74. (test-assert "login screen up"
  75. (wait-for-screen-text marionette
  76. (cut string-contains <> "Guix")
  77. #:ocr #$(file-append ocrad "/bin/ocrad")
  78. #:ocr-arguments '("--invert")
  79. #:timeout 120))) ;for slow systems
  80. (test-equal (string-append "session-type is " expected-session-type)
  81. expected-session-type
  82. (marionette-eval
  83. '(begin
  84. (use-modules (ice-9 popen)
  85. (ice-9 rdelim))
  86. (let* ((loginctl #$(file-append elogind "/bin/loginctl"))
  87. (get-session-cmd (string-join `(,loginctl "show-user" "gdm"
  88. "--property Display" "--value")))
  89. (session (call-with-port (open-input-pipe get-session-cmd) read-line))
  90. (get-type-cmd (string-join `(,loginctl "show-session" ,session
  91. "--property Type" "--value")))
  92. (type (call-with-port (open-input-pipe get-type-cmd) read-line)))
  93. type))
  94. marionette))
  95. (test-end)))))
  96. (gexp->derivation (string-append name "-test") test))
  97. (define %test-gdm-x11
  98. (system-test
  99. (name "gdm-x11")
  100. (description "Basic tests for the GDM service. (X11)")
  101. (value (run-gdm-test))))
  102. (define %test-gdm-wayland
  103. (system-test
  104. (name "gdm-wayland")
  105. (description "Basic tests for the GDM service. (Wayland)")
  106. (value (run-gdm-test #:wayland? #t))))