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))
68 ;; Make sure the 'rsync' command is found.
69 (setenv "PATH" "/run/current-system/profile/bin")
71 (start-service 'rsync))
74 ;; Make sure the PID file is created.
75 (test-assert "PID file"
77 '(file-exists? "/var/run/rsyncd/rsyncd.pid")
80 (test-assert "Test file copied to share"
83 (call-with-output-file "/tmp/input"
85 (display "test-file-contents\n" port)))
87 (system* "rsync" "/tmp/input"
88 (string-append "rsync://localhost:"
89 (number->string #$rsync-port)
93 (test-equal "Test file correctly received from share"
97 (use-modules (ice-9 rdelim))
100 (string-append "rsync://localhost:"
101 (number->string #$rsync-port)
104 (call-with-input-file "/tmp/output"
110 (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
112 (gexp->derivation "rsync-test" test))
115 ;; Return operating system under test.
117 (simple-operating-system
118 (service dhcp-client-service-type)
119 (service rsync-service-type))))
122 (packages (cons* rsync
123 (operating-system-packages base-os))))))
128 (description "Connect to a running RSYNC server.")
129 (value (run-rsync-test %rsync-os))))