1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2020 Oleg Pykhalov <go.wigust@gmail.com>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (gnu tests package-management)
20 #:use-module (gnu packages base)
21 #:use-module (gnu packages package-management)
22 #:use-module (gnu services)
23 #:use-module (gnu services networking)
24 #:use-module (gnu services nix)
25 #:use-module (gnu system)
26 #:use-module (gnu system vm)
27 #:use-module (gnu tests)
28 #:use-module (guix gexp)
29 #:use-module (guix packages)
34 ;;; This module provides a test definition for the nix-daemon
38 (define* (run-nix-test name test-os)
39 "Run tests in TEST-OS, which has nix-daemon running."
41 (marionette-operating-system
43 #:imported-modules '((gnu services herd))))
48 (port-forwardings '((8080 . 80)))
52 (with-imported-modules '((gnu build marionette))
54 (use-modules (srfi srfi-11)
56 (gnu build marionette)
61 (make-marionette (list #$vm)))
68 ;; XXX: Shepherd reads the config file *before* binding its control
69 ;; socket, so /var/run/shepherd/socket might not exist yet when the
70 ;; 'marionette' service is started.
71 (test-assert "shepherd socket ready"
74 (use-modules (gnu services herd))
76 (cond ((file-exists? (%shepherd-socket-file))
85 (test-assert "Nix daemon running"
88 ;; Wait for nix-daemon to be up and running.
89 (start-service 'nix-daemon)
90 (with-output-to-file "guix-test.nix"
93 with import <nix/config.nix>;
96 system = builtins.currentSystem;
99 args = [\"-c\" \"mkdir $out\\necho FOO > $out/foo\"];
103 (zero? (system* (string-append #$nix "/bin/nix-build")
104 "--substituters" "" "--debug" "--no-out-link"
110 (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
112 (gexp->derivation (string-append name "-test") test))
115 ;; Return operating system under test.
117 (simple-operating-system
118 (service nix-service-type)
119 (service dhcp-client-service-type))))
122 (packages (cons nix (operating-system-packages base-os))))))
127 (description "Connect to a running nix-daemon")
128 (value (run-nix-test name %nix-os))))
130 ;;; package-management.scm ends here