1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
4 ;;; This file is part of GNU Guix.
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.
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.
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/>.
19 (define-module (gnu tests rsync)
20 #:use-module (gnu packages rsync)
21 #:use-module (gnu tests)
22 #:use-module (gnu system)
23 #:use-module (gnu system file-systems)
24 #:use-module (gnu system shadow)
25 #:use-module (gnu system vm)
26 #:use-module (gnu services)
27 #:use-module (gnu services rsync)
28 #:use-module (gnu services networking)
29 #:use-module (guix gexp)
30 #:use-module (guix store)
31 #:export (%test-rsync))
33 (define* (run-rsync-test rsync-os #:optional (rsync-port 873))
34 "Run tests in %RSYNC-OS, which has rsync running and listening on
37 (marionette-operating-system
39 #:imported-modules '((gnu services herd)
45 (port-forwardings '())))
48 (with-imported-modules '((gnu build marionette))
50 (use-modules (srfi srfi-11) (srfi srfi-64)
51 (gnu build marionette))
54 (make-marionette (list #$vm)))
61 ;; Wait for rsync to be up and running.
62 (test-eq "service running"
66 (use-modules (gnu services herd))
67 (start-service 'rsync)
71 ;; Make sure the PID file is created.
72 (test-assert "PID file"
74 '(file-exists? "/var/run/rsyncd/rsyncd.pid")
77 (test-assert "Test file copied to share"
80 (call-with-output-file "/tmp/input"
82 (display "test-file-contents\n" port)))
84 (system* "rsync" "/tmp/input"
85 (string-append "rsync://localhost:"
86 (number->string #$rsync-port)
90 (test-equal "Test file correctly received from share"
94 (use-modules (ice-9 rdelim))
97 (string-append "rsync://localhost:"
98 (number->string #$rsync-port)
101 (call-with-input-file "/tmp/output"
107 (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
109 (gexp->derivation "rsync-test" test))
112 ;; Return operating system under test.
114 (simple-operating-system
115 (dhcp-client-service)
116 (service rsync-service-type))))
119 (packages (cons* rsync
120 (operating-system-packages base-os))))))
125 (description "Connect to a running RSYNC server.")
126 (value (run-rsync-test %rsync-os))))