From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH 2/2] tests: Add 'prosody-service-type' test. Date: Wed, 08 Feb 2017 15:47:07 +0100 Message-ID: <87d1espwno.fsf@gnu.org> References: <20170205185854.4345-1-clement@lassieur.org> <20170205185854.4345-3-clement@lassieur.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbTWd-0006lc-02 for guix-devel@gnu.org; Wed, 08 Feb 2017 09:47:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbTWY-0003Ib-W4 for guix-devel@gnu.org; Wed, 08 Feb 2017 09:47:15 -0500 In-Reply-To: <20170205185854.4345-3-clement@lassieur.org> (=?utf-8?Q?=22Cl?= =?utf-8?Q?=C3=A9ment?= Lassieur"'s message of "Sun, 5 Feb 2017 19:58:54 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: =?utf-8?Q?Cl=C3=A9ment?= Lassieur Cc: guix-devel@gnu.org Hello! Cl=C3=A9ment Lassieur skribis: > * gnu/tests/messaging.scm: New file. > * gnu/services/messaging.scm: New exported procedure. > ()[provision]: Add 'xmpp-daemon'. Awesome! Please also add the new file to gnu/local.mk. > +(define %base-os > + (operating-system > + (host-name "komputilo") > + (timezone "Europe/Berlin") > + (locale "en_US.UTF-8") > + > + (bootloader (grub-configuration (device "/dev/sdX"))) > + (file-systems %base-file-systems) > + (firmware '()) > + (users %base-user-accounts) > + (services (cons (dhcp-client-service) > + %base-services)))) > + > +(define (os-with-service service) > + "Return a test operating system that runs SERVICE." > + (operating-system > + (inherit %base-os) > + (services (cons service > + (operating-system-user-services %base-os))))) > + > +(define (run-xmpp-test name xmpp-service pid-file create-account) > + "Run a test of an OS running XMPP-SERVICE, which writes its PID to PID= -FILE." > + (mlet* %store-monad ((os -> (marionette-operating-system > + (os-with-service xmpp-service) > + #:imported-modules '((gnu services herd))= )) I think you can remove =E2=80=98os-with-service=E2=80=99 and simply add the= Prosody service explicitly in =E2=80=98%base-os=E2=80=99 (which could be rename =E2= =80=98%prosody-os=E2=80=99 maybe). > + (define script.ft > + (scheme-file > + "script.ft" > + #~(begin > + (define (handle-received-message time from nickname message) > + (if (equal? message #$message) > + (ft-quit 0) > + (ft-quit 1))) > + (add-hook! ft-message-receive-hook handle-received-message) > + > + (ft-set-jid! #$jid) > + (ft-set-password! #$password) > + (ft-set-server! #$server) > + (ft-set-port! #$port) > + (ft-set-sslconn! #f) > + (ft-connect-blocking) > + (ft-send-message #$jid #$message) > + (ft-main-loop)))) Very neat that this can be done in Scheme too. :-) If it=E2=80=99s possible, I agree that adding a timeout (say 1 minute) woul= d be nice. > + ;; Check XMPP service's PID. > + (test-assert "service process id" > + (let ((pid (number->string (wait-for-file #$pid-file)))) > + (marionette-eval `(zero? (system* "ps" "-p" ,pid)) > + marionette))) I think (file-exists? (string-append "/proc/" pid)) would be enough. > +(define %create-prosody-account > + (program-file > + "create-account" > + #~(let* ((jid (cadr (command-line))) > + (password (caddr (command-line))) Better use =E2=80=98match=E2=80=99 here. :-) (match (command-line) ((command jid password) =E2=80=A6)) Could you send an updated patch? Thank you! Ludo=E2=80=99.