1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2016 John Darrington <jmd@gnu.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 nfs)
21 #:use-module (gnu tests)
22 #:use-module (gnu system)
23 #:use-module (gnu system grub)
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 base)
29 #:use-module (gnu services nfs)
30 #:use-module (gnu services networking)
31 #:use-module (gnu packages onc-rpc)
32 #:use-module (guix gexp)
33 #:use-module (guix store)
34 #:use-module (guix monads)
39 (host-name "olitupmok")
40 (timezone "Europe/Berlin")
41 (locale "en_US.UTF-8")
43 (bootloader (grub-configuration (device "/dev/sdX")))
44 (file-systems %base-file-systems)
45 (users %base-user-accounts)
50 (service rpcbind-service-type
51 (rpcbind-configuration))
55 (define (run-nfs-test name socket)
56 "Run a test of an OS running RPC-SERVICE, which should create SOCKET."
57 (mlet* %store-monad ((os -> (marionette-operating-system
59 #:imported-modules '((gnu services herd)
61 (command (system-qemu-image/shared-store-script
64 (with-imported-modules '((gnu build marionette))
66 (use-modules (gnu build marionette)
70 (make-marionette (list #$command)))
72 (define (wait-for-socket file)
73 ;; Wait until SOCKET exists in the guest
76 (cond ((and (file-exists? ,file)
77 (eq? 'socket (stat:type (stat ,file))))
83 (error "Socket didn't show up: " ,file))))
89 (test-begin "rpc-daemon")
91 ;; Wait for the rpcbind daemon to be up and running.
92 (test-eq "RPC service running"
96 (use-modules (gnu services herd))
97 (start-service 'rpcbind-daemon)
101 ;; Check the socket file and that the service is still running.
102 (test-assert "RPC socket exists"
104 (wait-for-socket #$socket)
107 (use-modules (gnu services herd)
110 (live-service-running
112 (memq 'rpcbind-daemon
113 (live-service-provision live)))
114 (current-services))))
117 (test-assert "Probe RPC daemon"
119 '(zero? (system* "rpcinfo" "-p"))
123 (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
125 (gexp->derivation name test)))
130 (description "Test some things related to NFS.")
131 (value (run-nfs-test name "/var/run/rpcbind.sock"))))