audio.scm 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
  3. ;;; Copyright © 2022 Bruno Victal <mirai@makinata.eu>
  4. ;;;
  5. ;;; This file is part of GNU Guix.
  6. ;;;
  7. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  8. ;;; under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation; either version 3 of the License, or (at
  10. ;;; your option) any later version.
  11. ;;;
  12. ;;; GNU Guix is distributed in the hope that it will be useful, but
  13. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;;; GNU General Public License for more details.
  16. ;;;
  17. ;;; You should have received a copy of the GNU General Public License
  18. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  19. (define-module (gnu tests audio)
  20. #:use-module (gnu tests)
  21. #:use-module (gnu system)
  22. #:use-module (gnu system vm)
  23. #:use-module (gnu services)
  24. #:use-module (gnu services audio)
  25. #:use-module (gnu services networking)
  26. #:use-module (gnu packages mpd)
  27. #:use-module (guix gexp)
  28. #:export (%test-mpd
  29. %test-mympd))
  30. (define %mpd-os
  31. (simple-operating-system
  32. (service mpd-service-type)))
  33. (define (run-mpd-test)
  34. "Run tests in %mpd-os, which has mpd running."
  35. (define os
  36. (marionette-operating-system
  37. %mpd-os
  38. #:imported-modules '((gnu services herd))))
  39. (define vm
  40. (virtual-machine os))
  41. (define test
  42. (with-imported-modules '((gnu build marionette))
  43. #~(begin
  44. (use-modules (srfi srfi-64)
  45. (gnu build marionette))
  46. (define marionette
  47. (make-marionette (list #$vm)))
  48. (test-runner-current (system-test-runner #$output))
  49. (test-begin "mpd")
  50. (test-assert "service is running"
  51. (marionette-eval
  52. '(begin
  53. (use-modules (gnu services herd))
  54. (start-service 'mpd))
  55. marionette))
  56. (test-assert "mpd listening"
  57. ;; Wait until mpd is actually listening before spawning 'mpc'.
  58. (wait-for-tcp-port 6600 marionette))
  59. (test-equal "mpc connect"
  60. 0
  61. (marionette-eval
  62. '(system* #$(file-append mpd-mpc "/bin/mpc"))
  63. marionette))
  64. (test-end))))
  65. (gexp->derivation "mpd-test" test))
  66. (define %test-mpd
  67. (system-test
  68. (name "mpd")
  69. (description "Test that the mpd can run and be connected to.")
  70. (value (run-mpd-test))))
  71. (define (run-mympd-test)
  72. (define os (marionette-operating-system
  73. (simple-operating-system (service dhcp-client-service-type)
  74. (service mympd-service-type))
  75. #:imported-modules '((gnu services herd))))
  76. (define vm
  77. (virtual-machine
  78. (operating-system os)
  79. (port-forwardings '((8080 . 80)))))
  80. (define test
  81. (with-imported-modules '((gnu build marionette))
  82. #~(begin
  83. (use-modules (srfi srfi-64)
  84. (srfi srfi-8)
  85. (web client)
  86. (web response)
  87. (gnu build marionette))
  88. (define marionette
  89. (make-marionette (list #$vm)))
  90. (test-runner-current (system-test-runner #$output))
  91. (test-begin "mympd")
  92. (test-assert "service is running"
  93. (marionette-eval '(begin
  94. (use-modules (gnu services herd))
  95. (start-service 'mympd))
  96. marionette))
  97. (test-assert "HTTP port ready"
  98. (wait-for-tcp-port 80 marionette))
  99. (test-equal "http-head"
  100. 200
  101. (receive (x _) (http-head "http://localhost:8080") (response-code x)))
  102. (test-end))))
  103. (gexp->derivation "mympd-test" test))
  104. (define %test-mympd
  105. (system-test
  106. (name "mympd")
  107. (description "Connect to a running myMPD service.")
  108. (value (run-mympd-test))))