gnu: wine: Update to 4.0.
[jackhill/guix/guix.git] / tests / guix-daemon.sh
index 9186ffd..4c19a55 100644 (file)
@@ -1,5 +1,5 @@
 # GNU Guix --- Functional package management for GNU
-# Copyright © 2012, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2012, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
 #
 # This file is part of GNU Guix.
 #
@@ -81,6 +81,18 @@ guile -c "
 
 kill "$daemon_pid"
 
+# Pass several '--listen' options, and make sure they are all honored.
+guix-daemon --disable-chroot --listen="$socket" --listen="$socket-second" \
+           --listen="localhost" --listen="localhost:9876" &
+daemon_pid=$!
+
+for uri in "$socket" "$socket-second" \
+                    "guix://localhost" "guix://localhost:9876"
+do
+    GUIX_DAEMON_SOCKET="$uri" guix build guile-bootstrap
+done
+
+kill "$daemon_pid"
 
 # Check the failed build cache.
 
@@ -97,7 +109,7 @@ guile -c "
 
   (define (build-without-failing drv)
     (lambda (store)
-      (guard (c ((nix-protocol-error? c) (values #t store)))
+      (guard (c ((store-protocol-error? c) (values #t store)))
         (build-derivations store (list drv))
         (values #f store))))
 
@@ -165,9 +177,9 @@ client_code='
                                `("-e" ,build)
                                #:inputs `((,bash) (,build))
                                #:env-vars `(("x" . ,(random-text))))))
-      (exit (guard (c ((nix-protocol-error? c)
+      (exit (guard (c ((store-protocol-error? c)
                        (->bool
-                        (string-contains (pk (nix-protocol-error-message c))
+                        (string-contains (pk (store-protocol-error-message c))
                                          "failed"))))
               (build-derivations store (list drv))
               #f))))'
@@ -181,3 +193,53 @@ do
     GUIX_DAEMON_SOCKET="$socket" guile -c "$client_code"
     kill "$daemon_pid"
 done
+
+# Make sure garbage collection from a TCP connection does not work.
+
+tcp_socket="127.0.0.1:9999"
+guix-daemon --listen="$tcp_socket" &
+daemon_pid=$!
+
+GUIX_DAEMON_SOCKET="guix://$tcp_socket"
+export GUIX_DAEMON_SOCKET
+
+if guix gc; then false; else true; fi
+
+unset GUIX_DAEMON_SOCKET
+kill "$daemon_pid"
+
+# Log compression.
+
+guix-daemon --listen="$socket" --disable-chroot --debug --log-compression=gzip &
+daemon_pid=$!
+
+stamp="compressed-build-log-test-$$-`date +%H%M%S`"
+client_code="
+  (use-modules (guix) (gnu packages bootstrap))
+
+  (with-store store
+    (run-with-store store
+      (mlet %store-monad ((drv (lower-object
+                               (computed-file \"compressed-log-test\"
+                                              #~(begin
+                                                  (display \"$stamp\")
+                                                   (newline)
+                                                  (mkdir #\$output))
+                                              #:guile %bootstrap-guile))))
+       (display (derivation-file-name drv))
+       (newline)
+       (return #t))))
+"
+
+GUIX_DAEMON_SOCKET="$socket"
+export GUIX_DAEMON_SOCKET
+
+drv=`guile -c "$client_code"`
+guix build "$drv"
+
+log=`guix build "$drv" --log-file`
+test -f "$log"
+case "$log" in
+    *.gz) test "`gunzip -c < "$log"`" = "$stamp" ;;
+    *)    false ;;
+esac