1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
3 ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
5 ;;; This file is part of GNU Guix.
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.
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.
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/>.
20 (define-module (gnu tests rsync)
21 #:use-module (gnu packages rsync)
22 #:use-module (gnu tests)
23 #:use-module (gnu system)
24 #:use-module (gnu system file-systems)
25 #:use-module (gnu system shadow)
26 #:use-module (gnu system vm)
27 #:use-module (gnu services)
28 #:use-module (gnu services rsync)
29 #:use-module (gnu services networking)
30 #:use-module (guix gexp)
31 #:use-module (guix store)
32 #:export (%test-rsync))
34 (define* (run-rsync-test rsync-os #:optional (rsync-port 873))
35 "Run tests in %RSYNC-OS, which has rsync running and listening on
38 (marionette-operating-system
40 #:imported-modules '((gnu services herd)
46 (port-forwardings '())))
49 (with-imported-modules '((gnu build marionette))
51 (use-modules (srfi srfi-11) (srfi srfi-64)
52 (gnu build marionette))
55 (make-marionette (list #$vm)))
62 ;; Wait for rsync to be up and running.
63 (test-assert "service running"
66 (use-modules (gnu services herd))
67 (start-service 'rsync))
70 ;; Make sure the PID file is created.
71 (test-assert "PID file"
73 '(file-exists? "/var/run/rsyncd/rsyncd.pid")
76 (test-assert "Test file copied to share"
79 (call-with-output-file "/tmp/input"
81 (display "test-file-contents\n" port)))
83 (system* "rsync" "/tmp/input"
84 (string-append "rsync://localhost:"
85 (number->string #$rsync-port)
89 (test-equal "Test file correctly received from share"
93 (use-modules (ice-9 rdelim))
96 (string-append "rsync://localhost:"
97 (number->string #$rsync-port)
100 (call-with-input-file "/tmp/output"
106 (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
108 (gexp->derivation "rsync-test" test))
111 ;; Return operating system under test.
113 (simple-operating-system
114 (service dhcp-client-service-type)
115 (service rsync-service-type))))
118 (packages (cons* rsync
119 (operating-system-packages base-os))))))
124 (description "Connect to a running RSYNC server.")
125 (value (run-rsync-test %rsync-os))))