1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-05-25 18:41:54 +02:00

tests: Honor the return value of 'start-service'.

Since commit dc7b3e5633, 'start-service' returns
the Shepherd's representation of the service as a sexp, and '#f' if the
service fails to start.  Also, it doesn't throw an exception when the service
fails to start, so relying on an exception instead of relying on its return
value is a false positive.

* gnu/tests/base.scm (run-nss-mdns-test): Split tests so to check the return
value of 'start-service'.
(run-mcron-test, run-nss-mdns-test): Use 'test-assert' with the return value
of 'start-service'.
* gnu/tests/admin.scm (run-tailon-test): Idem.
* gnu/tests/dict.scm (run-dicod-test): Idem.
* gnu/tests/mail.scm (run-opensmtpd-test, run-exim-test, run-dovecot-test):
Idem.
* gnu/tests/messaging.scm (run-xmpp-test, run-bitlbee-test): Idem.
* gnu/tests/nfs.scm (run-nfs-test): Idem.
* gnu/tests/rsync.scm (run-rsync-test): Idem.
* gnu/tests/ssh.scm (run-ssh-test): Idem.
* gnu/tests/version-control.scm (run-cgit-test, run-git-http-test): Idem.
* gnu/tests/web.scm (run-php-fpm-test): Idem.
This commit is contained in:
Clément Lassieur
2018-06-11 21:07:24 +02:00
parent 14618a1ebb
commit c24b15472b
10 changed files with 69 additions and 80 deletions
+34 -24
View File
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -517,13 +518,11 @@ in a loop. See <http://bugs.gnu.org/26931>.")
(test-begin "mcron")
(test-eq "service running"
'running!
(test-assert "service running"
(marionette-eval
'(begin
(use-modules (gnu services herd))
(start-service 'mcron)
'running!)
(start-service 'mcron))
marionette))
;; Make sure root's mcron job runs, has its cwd set to "/root", and
@@ -619,32 +618,43 @@ in a loop. See <http://bugs.gnu.org/26931>.")
(test-begin "avahi")
(test-assert "wait for services"
(test-assert "nscd PID file is created"
(marionette-eval
'(begin
(use-modules (gnu services herd))
(start-service 'nscd))
marionette))
(start-service 'nscd)
(test-assert "nscd is listening on its socket"
(marionette-eval
;; XXX: Work around a race condition in nscd: nscd creates its
;; PID file before it is listening on its socket.
'(let ((sock (socket PF_UNIX SOCK_STREAM 0)))
(let try ()
(catch 'system-error
(lambda ()
(connect sock AF_UNIX "/var/run/nscd/socket")
(close-port sock)
(format #t "nscd is ready~%")
#t)
(lambda args
(format #t "waiting for nscd...~%")
(usleep 500000)
(try)))))
marionette))
;; XXX: Work around a race condition in nscd: nscd creates its
;; PID file before it is listening on its socket.
(let ((sock (socket PF_UNIX SOCK_STREAM 0)))
(let try ()
(catch 'system-error
(lambda ()
(connect sock AF_UNIX "/var/run/nscd/socket")
(close-port sock)
(format #t "nscd is ready~%"))
(lambda args
(format #t "waiting for nscd...~%")
(usleep 500000)
(try)))))
(test-assert "avahi is running"
(marionette-eval
'(begin
(use-modules (gnu services herd))
(start-service 'avahi-daemon))
marionette))
;; Wait for the other useful things.
(start-service 'avahi-daemon)
(start-service 'networking)
#t)
(test-assert "network is up"
(marionette-eval
'(begin
(use-modules (gnu services herd))
(start-service 'networking))
marionette))
(test-equal "avahi-resolve-host-name"