aboutsummaryrefslogtreecommitdiff
path: root/gnu/tests
diff options
context:
space:
mode:
authorChris Marusich <cmmarusich@gmail.com>2018-07-30 22:53:47 -0700
committerChris Marusich <cmmarusich@gmail.com>2018-08-28 00:19:58 -0700
commitb0f951e4f04766892933e3b60d1b24ab3a8589c2 (patch)
tree95aaaf2f786388987d3f0c45c61e60e98046d5c1 /gnu/tests
parentcb29343940dfffe8863c0a6b1e2b3494c7836b53 (diff)
downloadgnu-guix-b0f951e4f04766892933e3b60d1b24ab3a8589c2.tar
gnu-guix-b0f951e4f04766892933e3b60d1b24ab3a8589c2.tar.gz
tests: tor: Add more test cases.
* 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.
Diffstat (limited to 'gnu/tests')
-rw-r--r--gnu/tests/networking.scm59
1 files changed, 53 insertions, 6 deletions
diff --git a/gnu/tests/networking.scm b/gnu/tests/networking.scm
index 5e54edc462..7ca71f0c2c 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)))))