From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fl7Ut-0000MU-Pw for guix-patches@gnu.org; Thu, 02 Aug 2018 02:54:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fl7Uq-0005fG-O9 for guix-patches@gnu.org; Thu, 02 Aug 2018 02:54:07 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:33171) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fl7Uq-0005f7-Ip for guix-patches@gnu.org; Thu, 02 Aug 2018 02:54:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fl7Uq-0005Bd-BS for guix-patches@gnu.org; Thu, 02 Aug 2018 02:54:04 -0400 Subject: [bug#32346] [PATCH 5/6] tests: tor: Add more test cases. Resent-Message-ID: From: Chris Marusich Date: Wed, 1 Aug 2018 23:51:58 -0700 Message-Id: <20180802065159.20413-5-cmmarusich@gmail.com> In-Reply-To: <20180802065159.20413-1-cmmarusich@gmail.com> References: <20180802064520.20273-1-cmmarusich@gmail.com> <20180802065159.20413-1-cmmarusich@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 32346@debbugs.gnu.org Cc: Chris Marusich * gnu/tests/networking.scm (%tor-os/unix-socks-socket): New variable. (run-tor-test) : New variables. <"tor is alive">: Move common code from this test case... : ...into this new procedure. <"tor is listening", "tor is alive, even when using a SOCKS socket"> <"tor is listening, even when using a SOCKS socket">: New test cases. --- gnu/tests/networking.scm | 59 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm index c9a4f5463..b332ec3cf 100644 --- a/gnu/tests/networking.scm +++ b/gnu/tests/networking.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Thomas Danckaert ;;; Copyright © 2017 Marius Bakke +;;; Copyright © 2018 Chris Marusich ;;; ;;; This file is part of GNU Guix. ;;; @@ -349,12 +350,29 @@ subnet 192.168.1.0 netmask 255.255.255.0 { (simple-operating-system (tor-service))) +(define %tor-os/unix-socks-socket + (simple-operating-system + (service tor-service-type + (tor-configuration + (config-file + (plain-file "test-torrc" + "\ +SocksPort unix:/var/run/tor/socks-sock +UnixSocksGroupWritable 1 +") + ))))) + (define (run-tor-test) (define os (marionette-operating-system %tor-os #:imported-modules '((gnu services herd)) #:requirements '(tor))) + (define os/unix-socks-socket + (marionette-operating-system %tor-os/unix-socks-socket + #:imported-modules '((gnu services herd)) + #:requirements '(tor))) + (define test (with-imported-modules '((gnu build marionette)) #~(begin @@ -366,12 +384,7 @@ subnet 192.168.1.0 netmask 255.255.255.0 { (define marionette (make-marionette (list #$(virtual-machine os)))) - (mkdir #$output) - (chdir #$output) - - (test-begin "tor") - - (test-assert "tor is alive" + (define (tor-is-alive? marionette) (marionette-eval '(begin (use-modules (gnu services herd) @@ -383,6 +396,40 @@ subnet 192.168.1.0 netmask 255.255.255.0 { (current-services)))) marionette)) + (mkdir #$output) + (chdir #$output) + + (test-begin "tor") + + ;; Test the usual TOR service. + + (test-assert "tor is alive" + (tor-is-alive? marionette)) + + (test-assert "tor is listening" + (let ((default-port 9050)) + (wait-for-tcp-port default-port marionette))) + + ;; Don't run two VMs at once. + (marionette-control "quit" marionette) + + ;; Test the TOR service using a SOCKS socket. + + (let* ((socket-directory "/tmp/more-sockets") + (_ (mkdir socket-directory)) + (marionette/unix-socks-socket + (make-marionette + (list #$(virtual-machine os/unix-socks-socket)) + ;; We can't use the same socket directory as the first + ;; marionette. + #:socket-directory socket-directory))) + (test-assert "tor is alive, even when using a SOCKS socket" + (tor-is-alive? marionette/unix-socks-socket)) + + (test-assert "tor is listening, even when using a SOCKS socket" + (wait-for-unix-socket "/var/run/tor/socks-sock" + marionette/unix-socks-socket))) + (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0))))) -- 2.18.0