lightdm.scm 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>.
  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 lightdm)
  19. #:use-module (gnu bootloader)
  20. #:use-module (gnu bootloader grub)
  21. #:use-module (gnu packages)
  22. #:use-module (gnu packages ocr)
  23. #:use-module (gnu packages ratpoison)
  24. #:use-module (gnu packages vnc)
  25. #:use-module (gnu packages xorg)
  26. #:use-module (gnu services)
  27. #:use-module (gnu services base)
  28. #:use-module (gnu services dbus)
  29. #:use-module (gnu services desktop)
  30. #:use-module (gnu services networking)
  31. #:use-module (gnu services lightdm)
  32. #:use-module (gnu services ssh)
  33. #:use-module (gnu services xorg)
  34. #:use-module (gnu system)
  35. #:use-module (gnu system file-systems)
  36. #:use-module (gnu system keyboard)
  37. #:use-module (gnu system shadow)
  38. #:use-module (gnu system vm)
  39. #:use-module (gnu tests)
  40. #:use-module (guix gexp)
  41. #:use-module (guix modules)
  42. #:use-module (srfi srfi-1)
  43. #:export (%test-lightdm))
  44. (define minimal-desktop-services
  45. (list polkit-wheel-service
  46. (service upower-service-type)
  47. (service accountsservice-service-type)
  48. (service polkit-service-type)
  49. (service elogind-service-type)
  50. (service dbus-root-service-type)
  51. (service x11-socket-directory-service-type)))
  52. (define %lightdm-os
  53. (operating-system
  54. (inherit %simple-os)
  55. (packages (cons* ocrad ratpoison xterm %base-packages))
  56. (services
  57. (cons* (set-xorg-configuration (xorg-configuration
  58. (keyboard-layout (keyboard-layout "us")))
  59. lightdm-service-type)
  60. (service lightdm-service-type
  61. (lightdm-configuration
  62. (allow-empty-passwords? #t)
  63. (debug? #t)
  64. (xdmcp? #t)
  65. (vnc-server? #t)
  66. (vnc-server-command
  67. (file-append tigervnc-server "/bin/Xvnc"
  68. " -SecurityTypes None"))
  69. (greeters (list (lightdm-gtk-greeter-configuration
  70. (allow-debugging? #t))))
  71. (seats (list (lightdm-seat-configuration
  72. (name "*")
  73. (user-session "ratpoison"))))))
  74. ;; For debugging.
  75. (service dhcp-client-service-type)
  76. (service openssh-service-type
  77. (openssh-configuration
  78. (permit-root-login #t)
  79. (allow-empty-passwords? #t)))
  80. (append minimal-desktop-services
  81. (remove (lambda (service)
  82. (eq? (service-kind service) guix-service-type))
  83. %base-services))))))
  84. (define (run-lightdm-test)
  85. "Run tests in %LIGHTDM-OS."
  86. (define os (marionette-operating-system
  87. %lightdm-os
  88. #:imported-modules (source-module-closure
  89. '((gnu services herd)))))
  90. (define vm (virtual-machine os))
  91. (define test
  92. (with-imported-modules (source-module-closure
  93. '((gnu build marionette)))
  94. #~(begin
  95. (use-modules (gnu build marionette)
  96. (srfi srfi-26)
  97. (srfi srfi-64))
  98. (let ((marionette (make-marionette (list #$vm))))
  99. (test-runner-current (system-test-runner #$output))
  100. (test-begin "lightdm")
  101. (test-assert "service is running"
  102. (marionette-eval
  103. '(begin
  104. (use-modules (gnu services herd))
  105. (start-service 'lightdm))
  106. marionette))
  107. (test-assert "service can be stopped"
  108. (marionette-eval
  109. '(begin
  110. (use-modules (gnu services herd))
  111. (stop-service 'lightdm))
  112. marionette))
  113. (test-assert "service can be restarted"
  114. (marionette-eval
  115. '(begin
  116. (use-modules (gnu services herd))
  117. (restart-service 'lightdm))
  118. marionette))
  119. (test-assert "login screen is displayed"
  120. ;; GNU Ocrad fails to recognize the "Log In" button text, so use
  121. ;; Tesseract.
  122. (wait-for-screen-text marionette
  123. (cut string-contains <> "Log In")
  124. #:ocr #$(file-append tesseract-ocr
  125. "/bin/tesseract")))
  126. (test-assert "can connect to TCP port 5900 on IPv4"
  127. (wait-for-tcp-port 5900 marionette))
  128. ;; The VNC server fails to listen to IPv6 due to "Error binding to
  129. ;; address [::]:5900: Address already in use" (see:
  130. ;; https://github.com/canonical/lightdm/issues/266).
  131. (test-expect-fail 1)
  132. (test-assert "can connect to TCP port 5900 on IPv6"
  133. (wait-for-tcp-port 5900 marionette
  134. #:address
  135. `(make-socket-address
  136. AF_INET6
  137. (inet-pton AF_INET6 "::1")
  138. 5900)))
  139. (test-end)))))
  140. (gexp->derivation "lightdm-test" test))
  141. (define %test-lightdm
  142. (system-test
  143. (name "lightdm")
  144. (description "Basic tests for the LightDM service.")
  145. (value (run-lightdm-test))))