gnu: ardour: Update to 7.0
[jackhill/guix/guix.git] / gnu / tests / package-management.scm
CommitLineData
4656180d
OP
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2020 Oleg Pykhalov <go.wigust@gmail.com>
3;;;
4;;; This file is part of GNU Guix.
5;;;
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.
10;;;
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.
15;;;
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/>.
18
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)
30 #:export (%test-nix))
31
32;;; Commentary:
33;;;
34;;; This module provides a test definition for the nix-daemon
35;;;
36;;; Code:
37
38(define* (run-nix-test name test-os)
39 "Run tests in TEST-OS, which has nix-daemon running."
40 (define os
41 (marionette-operating-system
42 test-os
43 #:imported-modules '((gnu services herd))))
44
45 (define vm
46 (virtual-machine
47 (operating-system os)
48 (port-forwardings '((8080 . 80)))
49 (memory-size 1024)))
50
51 (define test
52 (with-imported-modules '((gnu build marionette))
53 #~(begin
54 (use-modules (srfi srfi-11)
55 (srfi srfi-64)
56 (gnu build marionette)
57 (web client)
58 (web response))
59
60 (define marionette
61 (make-marionette (list #$vm)))
62
89b05442 63 (test-runner-current (system-test-runner #$output))
4656180d
OP
64 (test-begin #$name)
65
66 ;; XXX: Shepherd reads the config file *before* binding its control
67 ;; socket, so /var/run/shepherd/socket might not exist yet when the
68 ;; 'marionette' service is started.
69 (test-assert "shepherd socket ready"
70 (marionette-eval
71 `(begin
72 (use-modules (gnu services herd))
73 (let loop ((i 10))
74 (cond ((file-exists? (%shepherd-socket-file))
75 #t)
76 ((> i 0)
77 (sleep 1)
78 (loop (- i 1)))
79 (else
80 'failure))))
81 marionette))
82
83 (test-assert "Nix daemon running"
84 (marionette-eval
85 '(begin
86 ;; Wait for nix-daemon to be up and running.
87 (start-service 'nix-daemon)
e9bed5e9
MO
88 (zero? (system* (string-append #$nix "/bin/nix")
89 "--experimental-features" "nix-command"
90 "store" "ping" "--store" "daemon")))
4656180d
OP
91 marionette))
92
7d72da6b 93 (test-end))))
4656180d
OP
94
95 (gexp->derivation (string-append name "-test") test))
96
97(define %nix-os
98 ;; Return operating system under test.
99 (let ((base-os
100 (simple-operating-system
101 (service nix-service-type)
7d72da6b 102 (service dhcp-client-service-type))))
4656180d
OP
103 (operating-system
104 (inherit base-os)
105 (packages (cons nix (operating-system-packages base-os))))))
106
107(define %test-nix
108 (system-test
109 (name "nix")
110 (description "Connect to a running nix-daemon")
111 (value (run-nix-test name %nix-os))))
112
113;;; package-management.scm ends here