Merge branch 'master' into staging
[jackhill/guix/guix.git] / gnu / tests / audio.scm
CommitLineData
06465d2b
PM
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@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
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 packages mpd)
26 #:use-module (guix gexp)
27 #:export (%test-mpd))
28
29(define %mpd-os
30 (simple-operating-system
9909eddb 31 (service mpd-service-type)))
06465d2b
PM
32
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
40 (define vm
41 (virtual-machine os))
42
43 (define test
44 (with-imported-modules '((gnu build marionette))
45 #~(begin
46 (use-modules (srfi srfi-64)
47 (gnu build marionette))
48 (define marionette
49 (make-marionette (list #$vm)))
50
51 (mkdir #$output)
52 (chdir #$output)
53
54 (test-begin "mpd")
55
56 (test-assert "service is running"
57 (marionette-eval
58 '(begin
59 (use-modules (gnu services herd))
60 (start-service 'mpd))
61 marionette))
62
9909eddb
LC
63 (test-assert "mpd listening"
64 ;; Wait until mpd is actually listening before spawning 'mpc'.
65 (wait-for-tcp-port 6600 marionette))
66
67 (test-equal "mpc connect"
68 0
06465d2b 69 (marionette-eval
9909eddb 70 '(system* #$(file-append mpd-mpc "/bin/mpc"))
06465d2b
PM
71 marionette))
72
73 (test-end)
74 (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
75 (gexp->derivation "mpd-test" test))
76
77(define %test-mpd
78 (system-test
79 (name "mpd")
80 (description "Test that the mpd can run and be connected to.")
81 (value (run-mpd-test))))