123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- (define-module (gnu tests package-management)
- #:use-module (gnu packages base)
- #:use-module (gnu packages package-management)
- #:use-module (gnu services)
- #:use-module (gnu services networking)
- #:use-module (gnu services nix)
- #:use-module (gnu system)
- #:use-module (gnu system vm)
- #:use-module (gnu tests)
- #:use-module (guix gexp)
- #:use-module (guix packages)
- #:export (%test-nix))
- (define* (run-nix-test name test-os)
- "Run tests in TEST-OS, which has nix-daemon running."
- (define os
- (marionette-operating-system
- test-os
- #:imported-modules '((gnu services herd))))
- (define vm
- (virtual-machine
- (operating-system os)
- (port-forwardings '((8080 . 80)))
- (memory-size 1024)))
- (define test
- (with-imported-modules '((gnu build marionette))
- #~(begin
- (use-modules (srfi srfi-11)
- (srfi srfi-64)
- (gnu build marionette)
- (web client)
- (web response))
- (define marionette
- (make-marionette (list #$vm)))
- (mkdir #$output)
- (chdir #$output)
- (test-begin #$name)
-
-
-
- (test-assert "shepherd socket ready"
- (marionette-eval
- `(begin
- (use-modules (gnu services herd))
- (let loop ((i 10))
- (cond ((file-exists? (%shepherd-socket-file))
- #t)
- ((> i 0)
- (sleep 1)
- (loop (- i 1)))
- (else
- 'failure))))
- marionette))
- (test-assert "Nix daemon running"
- (marionette-eval
- '(begin
-
- (start-service 'nix-daemon)
- (with-output-to-file "guix-test.nix"
- (lambda ()
- (display "\
- with import <nix/config.nix>;
- derivation {
- system = builtins.currentSystem;
- name = \"guix-test\";
- builder = shell;
- args = [\"-c\" \"mkdir $out\\necho FOO > $out/foo\"];
- PATH = coreutils;
- }
- ")))
- (zero? (system* (string-append #$nix "/bin/nix-build")
- "--substituters" "" "--debug" "--no-out-link"
- "guix-test.nix")))
- marionette))
- (test-end)
- (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
- (gexp->derivation (string-append name "-test") test))
- (define %nix-os
-
- (let ((base-os
- (simple-operating-system
- (service nix-service-type)
- (service dhcp-client-service-type))))
- (operating-system
- (inherit base-os)
- (packages (cons nix (operating-system-packages base-os))))))
- (define %test-nix
- (system-test
- (name "nix")
- (description "Connect to a running nix-daemon")
- (value (run-nix-test name %nix-os))))
|