From: Chris Marusich <cmmarusich@gmail.com>
To: 32346@debbugs.gnu.org
Cc: Chris Marusich <cmmarusich@gmail.com>
Subject: [bug#32346] [PATCH 5/6] tests: tor: Add more test cases.
Date: Wed, 1 Aug 2018 23:51:58 -0700 [thread overview]
Message-ID: <20180802065159.20413-5-cmmarusich@gmail.com> (raw)
In-Reply-To: <20180802065159.20413-1-cmmarusich@gmail.com>
* gnu/tests/networking.scm (%tor-os/unix-socks-socket): New variable.
(run-tor-test) <os/unix-socks-socket, marionette/unix-socks-socket>
<socket-directory>: New variables.
<"tor is alive">: Move common code from this test case...
<tor-is-alive?>: ...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 <post@thomasdanckaert.be>
;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
+;;; Copyright © 2018 Chris Marusich <cmmarusich@gmail.com>
;;;
;;; 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
next prev parent reply other threads:[~2018-08-02 6:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-02 6:45 [bug#32346] [PATCH 0/6] TOR via Unix domain SOCKS socket Chris Marusich
2018-08-02 6:51 ` [bug#32346] [PATCH 1/6] services: tor: Add a system test Chris Marusich
2018-08-02 6:51 ` [bug#32346] [PATCH 2/6] services: tor: Rename activation procedure Chris Marusich
2018-08-20 20:03 ` Ludovic Courtès
2018-08-02 6:51 ` [bug#32346] [PATCH 3/6] marionette: Add support for QEMU's "quit" command Chris Marusich
2018-08-20 20:03 ` Ludovic Courtès
2018-08-02 6:51 ` [bug#32346] [PATCH 4/6] marionette: Add wait-for-unix-socket Chris Marusich
2018-08-20 20:05 ` Ludovic Courtès
2018-08-02 6:51 ` Chris Marusich [this message]
2018-08-20 20:06 ` [bug#32346] [PATCH 5/6] tests: tor: Add more test cases Ludovic Courtès
2018-08-02 6:51 ` [bug#32346] [PATCH 6/6] services: tor: Make it easier to use UNIX sockets Chris Marusich
2018-08-20 20:09 ` Ludovic Courtès
2018-08-20 20:02 ` [bug#32346] [PATCH 1/6] services: tor: Add a system test Ludovic Courtès
2018-08-28 7:46 ` bug#32346: " Chris Marusich
2018-08-02 9:27 ` [bug#32346] [PATCH 0/6] TOR via Unix domain SOCKS socket Nils Gillmann
2018-08-03 2:22 ` Chris Marusich
2018-08-03 11:43 ` Nils Gillmann
2018-08-04 4:34 ` Chris Marusich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180802065159.20413-5-cmmarusich@gmail.com \
--to=cmmarusich@gmail.com \
--cc=32346@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).