Merge branch 'master' into staging
[jackhill/guix/guix.git] / tests / store.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
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 (test-store)
20 #:use-module (guix tests)
21 #:use-module (guix config)
22 #:use-module (guix store)
23 #:use-module (guix utils)
24 #:use-module (guix monads)
25 #:use-module (gcrypt hash)
26 #:use-module (guix base32)
27 #:use-module (guix packages)
28 #:use-module (guix derivations)
29 #:use-module (guix serialization)
30 #:use-module (guix build utils)
31 #:use-module (guix gexp)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages bootstrap)
34 #:use-module (ice-9 match)
35 #:use-module (ice-9 regex)
36 #:use-module (rnrs bytevectors)
37 #:use-module (rnrs io ports)
38 #:use-module (web uri)
39 #:use-module (srfi srfi-1)
40 #:use-module (srfi srfi-11)
41 #:use-module (srfi srfi-26)
42 #:use-module (srfi srfi-34)
43 #:use-module (srfi srfi-64))
44
45 ;; Test the (guix store) module.
46
47 (define %store
48 (open-connection-for-tests))
49
50 (define %shell
51 (or (getenv "SHELL") (getenv "CONFIG_SHELL")))
52
53 \f
54 (test-begin "store")
55
56 (test-assert "open-connection with file:// URI"
57 (let ((store (open-connection (string-append "file://"
58 (%daemon-socket-uri)))))
59 (and (add-text-to-store store "foo" "bar")
60 (begin
61 (close-connection store)
62 #t))))
63
64 (test-equal "connection handshake error"
65 EPROTO
66 (let ((port (%make-void-port "rw")))
67 (guard (c ((store-connection-error? c)
68 (and (eq? port (store-connection-error-file c))
69 (store-connection-error-code c))))
70 (open-connection #f #:port port)
71 'broken)))
72
73 (test-equal "store-path-hash-part"
74 "283gqy39v3g9dxjy26rynl0zls82fmcg"
75 (store-path-hash-part
76 (string-append (%store-prefix)
77 "/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7")))
78
79 (test-equal "store-path-hash-part #f"
80 #f
81 (store-path-hash-part
82 (string-append (%store-prefix)
83 "/foo/bar/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7")))
84
85 (test-equal "store-path-package-name"
86 "guile-2.0.7"
87 (store-path-package-name
88 (string-append (%store-prefix)
89 "/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7")))
90
91 (test-equal "store-path-package-name #f"
92 #f
93 (store-path-package-name
94 "/foo/bar/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7"))
95
96 (test-assert "direct-store-path?"
97 (and (direct-store-path?
98 (string-append (%store-prefix)
99 "/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7"))
100 (not (direct-store-path?
101 (string-append
102 (%store-prefix)
103 "/283gqy39v3g9dxjy26rynl0zls82fmcg-guile-2.0.7/bin/guile")))
104 (not (direct-store-path? (%store-prefix)))))
105
106 (test-skip (if %store 0 15))
107
108 (test-equal "profiles/per-user exists and is not writable"
109 #o755
110 (stat:perms (stat (string-append %state-directory "/profiles/per-user"))))
111
112 (test-equal "profiles/per-user/$USER exists"
113 (list (getuid) #o755)
114 (let ((s (stat (string-append %state-directory "/profiles/per-user/"
115 (passwd:name (getpwuid (getuid)))))))
116 (list (stat:uid s) (stat:perms s))))
117
118 (test-equal "add-data-to-store"
119 #vu8(1 2 3 4 5)
120 (call-with-input-file (add-data-to-store %store "data" #vu8(1 2 3 4 5))
121 get-bytevector-all))
122
123 (test-assert "valid-path? live"
124 (let ((p (add-text-to-store %store "hello" "hello, world")))
125 (valid-path? %store p)))
126
127 (test-assert "valid-path? false"
128 (not (valid-path? %store
129 (string-append (%store-prefix) "/"
130 (make-string 32 #\e) "-foobar"))))
131
132 (test-assert "valid-path? error"
133 (with-store s
134 (guard (c ((store-protocol-error? c) #t))
135 (valid-path? s "foo")
136 #f)))
137
138 (test-assert "valid-path? recovery"
139 ;; Prior to Nix commit 51800e0 (18 Mar. 2014), the daemon would immediately
140 ;; close the connection after receiving a 'valid-path?' RPC with a non-store
141 ;; file name. See
142 ;; <http://article.gmane.org/gmane.linux.distributions.nixos/12411> for
143 ;; details.
144 (with-store s
145 (let-syntax ((true-if-error (syntax-rules ()
146 ((_ exp)
147 (guard (c ((store-protocol-error? c) #t))
148 exp #f)))))
149 (and (true-if-error (valid-path? s "foo"))
150 (true-if-error (valid-path? s "bar"))
151 (true-if-error (valid-path? s "baz"))
152 (true-if-error (valid-path? s "chbouib"))
153 (valid-path? s (add-text-to-store s "valid" "yeah"))))))
154
155 (test-assert "hash-part->path"
156 (let ((p (add-text-to-store %store "hello" "hello, world")))
157 (equal? (hash-part->path %store (store-path-hash-part p))
158 p)))
159
160 (test-assert "dead-paths"
161 (let ((p (add-text-to-store %store "random-text" (random-text))))
162 (->bool (member p (dead-paths %store)))))
163
164 ;; FIXME: Find a test for `live-paths'.
165 ;;
166 ;; (test-assert "temporary root is in live-paths"
167 ;; (let* ((p1 (add-text-to-store %store "random-text"
168 ;; (random-text) '()))
169 ;; (b (add-text-to-store %store "link-builder"
170 ;; (format #f "echo ~a > $out" p1)
171 ;; '()))
172 ;; (d1 (derivation %store "link"
173 ;; "/bin/sh" `("-e" ,b)
174 ;; #:inputs `((,b) (,p1))))
175 ;; (p2 (derivation->output-path d1)))
176 ;; (and (add-temp-root %store p2)
177 ;; (build-derivations %store (list d1))
178 ;; (valid-path? %store p1)
179 ;; (member (pk p2) (live-paths %store)))))
180
181 (test-assert "permanent root"
182 (let* ((p (with-store store
183 (let ((p (add-text-to-store store "random-text"
184 (random-text))))
185 (add-permanent-root p)
186 (add-permanent-root p) ; should not throw
187 p))))
188 (and (member p (live-paths %store))
189 (begin
190 (remove-permanent-root p)
191 (->bool (member p (dead-paths %store)))))))
192
193 (test-assert "dead path can be explicitly collected"
194 (let ((p (add-text-to-store %store "random-text"
195 (random-text) '())))
196 (let-values (((paths freed) (delete-paths %store (list p))))
197 (and (equal? paths (list p))
198 ;; XXX: On some file systems (notably Btrfs), freed
199 ;; may return 0. See <https://bugs.gnu.org/29363>.
200 ;;(> freed 0)
201 (not (file-exists? p))))))
202
203 (test-assert "add-text-to-store vs. delete-paths"
204 ;; Before, 'add-text-to-store' would return PATH2 without noticing that it
205 ;; is no longer valid.
206 (with-store store
207 (let* ((text (random-text))
208 (path (add-text-to-store store "delete-me" text))
209 (deleted (delete-paths store (list path)))
210 (path2 (add-text-to-store store "delete-me" text)))
211 (and (string=? path path2)
212 (equal? deleted (list path))
213 (valid-path? store path)
214 (file-exists? path)))))
215
216 (test-assert "add-to-store vs. delete-paths"
217 ;; Same as above.
218 (with-store store
219 (let* ((file (search-path %load-path "guix.scm"))
220 (path (add-to-store store "delete-me" #t "sha256" file))
221 (deleted (delete-paths store (list path)))
222 (path2 (add-to-store store "delete-me" #t "sha256" file)))
223 (and (string=? path path2)
224 (equal? deleted (list path))
225 (valid-path? store path)
226 (file-exists? path)))))
227
228 (test-equal "add-file-tree-to-store"
229 `(42
230 ("." directory #t)
231 ("./bar" directory #t)
232 ("./foo" directory #t)
233 ("./foo/a" regular "file a")
234 ("./foo/b" symlink "a")
235 ("./foo/c" directory #t)
236 ("./foo/c/p" regular "file p")
237 ("./foo/c/q" directory #t)
238 ("./foo/c/q/x" regular
239 ,(string-append "#!" %shell "\nexit 42"))
240 ("./foo/c/q/y" symlink "..")
241 ("./foo/c/q/z" directory #t))
242 (let* ((tree `("file-tree" directory
243 ("foo" directory
244 ("a" regular (data "file a"))
245 ("b" symlink "a")
246 ("c" directory
247 ("p" regular (data ,(string->utf8 "file p")))
248 ("q" directory
249 ("x" executable
250 (data ,(string-append "#!" %shell "\nexit 42")))
251 ("y" symlink "..")
252 ("z" directory))))
253 ("bar" directory)))
254 (result (add-file-tree-to-store %store tree)))
255 (cons (status:exit-val (system* (string-append result "/foo/c/q/x")))
256 (with-directory-excursion result
257 (map (lambda (file)
258 (let ((type (stat:type (lstat file))))
259 `(,file ,type
260 ,(match type
261 ((or 'regular 'executable)
262 (call-with-input-file file
263 get-string-all))
264 ('symlink (readlink file))
265 ('directory #t)))))
266 (find-files "." #:directories? #t))))))
267
268 (test-equal "add-file-tree-to-store, flat"
269 "Hello, world!"
270 (let* ((tree `("flat-file" regular (data "Hello, world!")))
271 (result (add-file-tree-to-store %store tree)))
272 (and (file-exists? result)
273 (call-with-input-file result get-string-all))))
274
275 (test-assert "references"
276 (let* ((t1 (add-text-to-store %store "random1"
277 (random-text)))
278 (t2 (add-text-to-store %store "random2"
279 (random-text) (list t1))))
280 (and (equal? (list t1) (references %store t2))
281 (equal? (list t2) (referrers %store t1))
282 (null? (references %store t1))
283 (null? (referrers %store t2)))))
284
285 (test-assert "references/substitutes missing reference info"
286 (with-store s
287 (set-build-options s #:use-substitutes? #f)
288 (guard (c ((store-protocol-error? c) #t))
289 (let* ((b (add-to-store s "bash" #t "sha256"
290 (search-bootstrap-binary "bash"
291 (%current-system))))
292 (d (derivation s "the-thing" b '("--help")
293 #:inputs `((,b)))))
294 (references/substitutes s (list (derivation->output-path d) b))
295 #f))))
296
297 (test-assert "references/substitutes with substitute info"
298 (with-store s
299 (set-build-options s #:use-substitutes? #t)
300 (let* ((t1 (add-text-to-store s "random1" (random-text)))
301 (t2 (add-text-to-store s "random2" (random-text)
302 (list t1)))
303 (t3 (add-text-to-store s "build" "echo -n $t2 > $out"))
304 (b (add-to-store s "bash" #t "sha256"
305 (search-bootstrap-binary "bash"
306 (%current-system))))
307 (d (derivation s "the-thing" b `("-e" ,t3)
308 #:inputs `((,b) (,t3) (,t2))
309 #:env-vars `(("t2" . ,t2))))
310 (o (derivation->output-path d)))
311 (with-derivation-narinfo d
312 (sha256 => (sha256 (string->utf8 t2)))
313 (references => (list t2))
314
315 (equal? (references/substitutes s (list o t3 t2 t1))
316 `((,t2) ;refs of O
317 () ;refs of T3
318 (,t1) ;refs of T2
319 ())))))) ;refs of T1
320
321 (test-equal "substitutable-path-info when substitutes are turned off"
322 '()
323 (with-store s
324 (set-build-options s #:use-substitutes? #f)
325 (let* ((b (add-to-store s "bash" #t "sha256"
326 (search-bootstrap-binary "bash"
327 (%current-system))))
328 (d (derivation s "the-thing" b '("--version")
329 #:inputs `((,b))))
330 (o (derivation->output-path d)))
331 (with-derivation-narinfo d
332 (substitutable-path-info s (list o))))))
333
334 (test-equal "substitutable-paths when substitutes are turned off"
335 '()
336 (with-store s
337 (set-build-options s #:use-substitutes? #f)
338 (let* ((b (add-to-store s "bash" #t "sha256"
339 (search-bootstrap-binary "bash"
340 (%current-system))))
341 (d (derivation s "the-thing" b '("--version")
342 #:inputs `((,b))))
343 (o (derivation->output-path d)))
344 (with-derivation-narinfo d
345 (substitutable-paths s (list o))))))
346
347 (test-assert "requisites"
348 (let* ((t1 (add-text-to-store %store "random1"
349 (random-text) '()))
350 (t2 (add-text-to-store %store "random2"
351 (random-text) (list t1)))
352 (t3 (add-text-to-store %store "random3"
353 (random-text) (list t2)))
354 (t4 (add-text-to-store %store "random4"
355 (random-text) (list t1 t3))))
356 (define (same? x y)
357 (and (= (length x) (length y))
358 (lset= equal? x y)))
359
360 (and (same? (requisites %store (list t1)) (list t1))
361 (same? (requisites %store (list t2)) (list t1 t2))
362 (same? (requisites %store (list t3)) (list t1 t2 t3))
363 (same? (requisites %store (list t4)) (list t1 t2 t3 t4))
364 (same? (requisites %store (list t1 t2 t3 t4))
365 (list t1 t2 t3 t4)))))
366
367 (test-assert "derivers"
368 (let* ((b (add-text-to-store %store "build" "echo $foo > $out" '()))
369 (s (add-to-store %store "bash" #t "sha256"
370 (search-bootstrap-binary "bash"
371 (%current-system))))
372 (d (derivation %store "the-thing"
373 s `("-e" ,b)
374 #:env-vars `(("foo" . ,(random-text)))
375 #:inputs `((,b) (,s))))
376 (o (derivation->output-path d)))
377 (and (build-derivations %store (list d))
378 (equal? (query-derivation-outputs %store (derivation-file-name d))
379 (list o))
380 (equal? (valid-derivers %store o)
381 (list (derivation-file-name d))))))
382
383 (test-equal "with-build-handler"
384 'success
385 (let* ((b (add-text-to-store %store "build" "echo $foo > $out" '()))
386 (s (add-to-store %store "bash" #t "sha256"
387 (search-bootstrap-binary "bash"
388 (%current-system))))
389 (d1 (derivation %store "the-thing"
390 s `("-e" ,b)
391 #:env-vars `(("foo" . ,(random-text)))
392 #:sources (list b s)))
393 (d2 (derivation %store "the-thing"
394 s `("-e" ,b)
395 #:env-vars `(("foo" . ,(random-text))
396 ("bar" . "baz"))
397 #:sources (list b s)))
398 (o1 (derivation->output-path d1))
399 (o2 (derivation->output-path d2)))
400 (with-build-handler
401 (let ((counter 0))
402 (lambda (continue store things mode)
403 (match things
404 ((drv)
405 (set! counter (+ 1 counter))
406 (if (string=? drv (derivation-file-name d1))
407 (continue #t)
408 (and (string=? drv (derivation-file-name d2))
409 (= counter 2)
410 'success))))))
411 (build-derivations %store (list d1))
412 (build-derivations %store (list d2))
413 'fail)))
414
415 (test-equal "with-build-handler + with-store"
416 'success
417 ;; Check that STORE remains valid when the build handler invokes CONTINUE,
418 ;; even though 'with-build-handler' is outside the dynamic extent of
419 ;; 'with-store'.
420 (with-build-handler (lambda (continue store things mode)
421 (match things
422 ((drv)
423 (and (string-suffix? "thingie.drv" drv)
424 (not (port-closed?
425 (store-connection-socket store)))
426 (continue #t)))))
427 (with-store store
428 (let* ((b (add-text-to-store store "build" "echo $foo > $out" '()))
429 (s (add-to-store store "bash" #t "sha256"
430 (search-bootstrap-binary "bash"
431 (%current-system))))
432 (d (derivation store "thingie"
433 s `("-e" ,b)
434 #:env-vars `(("foo" . ,(random-text)))
435 #:sources (list b s))))
436 (build-derivations store (list d))
437
438 ;; Here STORE's socket should still be open.
439 (and (valid-path? store (derivation->output-path d))
440 'success)))))
441
442 (test-assert "map/accumulate-builds"
443 (let* ((b (add-text-to-store %store "build" "echo $foo > $out" '()))
444 (s (add-to-store %store "bash" #t "sha256"
445 (search-bootstrap-binary "bash"
446 (%current-system))))
447 (d1 (derivation %store "the-thing"
448 s `("-e" ,b)
449 #:env-vars `(("foo" . ,(random-text)))
450 #:sources (list b s)))
451 (d2 (derivation %store "the-thing"
452 s `("-e" ,b)
453 #:env-vars `(("foo" . ,(random-text))
454 ("bar" . "baz"))
455 #:sources (list b s))))
456 (with-build-handler (lambda (continue store things mode)
457 (equal? (map derivation-file-name (list d1 d2))
458 things))
459 (map/accumulate-builds %store
460 (lambda (drv)
461 (build-derivations %store (list drv))
462 (add-to-store %store "content-addressed"
463 #t "sha256"
464 (derivation->output-path drv)))
465 (list d1 d2)))))
466
467 (test-assert "mapm/accumulate-builds"
468 (let* ((d1 (run-with-store %store
469 (gexp->derivation "foo" #~(mkdir #$output))))
470 (d2 (run-with-store %store
471 (gexp->derivation "bar" #~(mkdir #$output)))))
472 (with-build-handler (lambda (continue store things mode)
473 (equal? (map derivation-file-name (pk 'zz (list d1 d2)))
474 (pk 'XX things)))
475 (run-with-store %store
476 (mapm/accumulate-builds built-derivations `((,d1) (,d2)))))))
477
478 (test-equal "mapm/accumulate-builds, %current-target-system"
479 (make-list 2 '("i586-pc-gnu" "i586-pc-gnu"))
480 ;; Both the 'mapm' and 'mapm/accumulate-builds' procedures should see the
481 ;; right #:target.
482 (run-with-store %store
483 (mlet %store-monad ((lst1 (mapm %store-monad
484 (lambda _
485 (current-target-system))
486 '(a b)))
487 (lst2 (mapm/accumulate-builds
488 (lambda _
489 (current-target-system))
490 '(a b))))
491 (return (list lst1 lst2)))
492 #:system system
493 #:target "i586-pc-gnu"))
494
495 (test-assert "topologically-sorted, one item"
496 (let* ((a (add-text-to-store %store "a" "a"))
497 (b (add-text-to-store %store "b" "b" (list a)))
498 (c (add-text-to-store %store "c" "c" (list b)))
499 (d (add-text-to-store %store "d" "d" (list c)))
500 (s (topologically-sorted %store (list d))))
501 (equal? s (list a b c d))))
502
503 (test-assert "topologically-sorted, several items"
504 (let* ((a (add-text-to-store %store "a" "a"))
505 (b (add-text-to-store %store "b" "b" (list a)))
506 (c (add-text-to-store %store "c" "c" (list b)))
507 (d (add-text-to-store %store "d" "d" (list c)))
508 (s1 (topologically-sorted %store (list d a c b)))
509 (s2 (topologically-sorted %store (list b d c a b d))))
510 (equal? s1 s2 (list a b c d))))
511
512 (test-assert "topologically-sorted, more difficult"
513 (let* ((a (add-text-to-store %store "a" "a"))
514 (b (add-text-to-store %store "b" "b" (list a)))
515 (c (add-text-to-store %store "c" "c" (list b)))
516 (d (add-text-to-store %store "d" "d" (list c)))
517 (w (add-text-to-store %store "w" "w"))
518 (x (add-text-to-store %store "x" "x" (list w)))
519 (y (add-text-to-store %store "y" "y" (list x d)))
520 (s1 (topologically-sorted %store (list y)))
521 (s2 (topologically-sorted %store (list c y)))
522 (s3 (topologically-sorted %store (cons y (references %store y)))))
523 ;; The order in which 'references' returns the references of Y is
524 ;; unspecified, so accommodate.
525 (let* ((x-then-d? (equal? (references %store y) (list x d))))
526 (and (equal? s1
527 (if x-then-d?
528 (list w x a b c d y)
529 (list a b c d w x y)))
530 (equal? s2
531 (if x-then-d?
532 (list a b c w x d y)
533 (list a b c d w x y)))
534 (lset= string=? s1 s3)))))
535
536 (test-assert "current-build-output-port, UTF-8"
537 ;; Are UTF-8 strings in the build log properly interpreted?
538 (string-contains
539 (with-fluids ((%default-port-encoding "UTF-8")) ;for the string port
540 (call-with-output-string
541 (lambda (port)
542 (parameterize ((current-build-output-port port))
543 (let* ((s "Here’s a Greek letter: λ.")
544 (d (build-expression->derivation
545 %store "foo" `(display ,s)
546 #:guile-for-build
547 (package-derivation s %bootstrap-guile (%current-system)))))
548 (guard (c ((store-protocol-error? c) #t))
549 (build-derivations %store (list d))))))))
550 "Here’s a Greek letter: λ."))
551
552 (test-assert "current-build-output-port, UTF-8 + garbage"
553 ;; What about a mixture of UTF-8 + garbage?
554 (string-contains
555 (with-fluids ((%default-port-encoding "UTF-8")) ;for the string port
556 (call-with-output-string
557 (lambda (port)
558 (parameterize ((current-build-output-port port))
559 (let ((d (build-expression->derivation
560 %store "foo"
561 `(begin
562 (use-modules (rnrs io ports))
563 (display "garbage: ")
564 (put-bytevector (current-output-port) #vu8(128))
565 (display "lambda: λ\n"))
566 #:guile-for-build
567 (package-derivation %store %bootstrap-guile))))
568 (guard (c ((store-protocol-error? c) #t))
569 (build-derivations %store (list d))))))))
570 "garbage: �lambda: λ"))
571
572 (test-assert "log-file, derivation"
573 (let* ((b (add-text-to-store %store "build" "echo $foo > $out" '()))
574 (s (add-to-store %store "bash" #t "sha256"
575 (search-bootstrap-binary "bash"
576 (%current-system))))
577 (d (derivation %store "the-thing"
578 s `("-e" ,b)
579 #:env-vars `(("foo" . ,(random-text)))
580 #:inputs `((,b) (,s)))))
581 (and (build-derivations %store (list d))
582 (file-exists? (pk (log-file %store (derivation-file-name d)))))))
583
584 (test-assert "log-file, output file name"
585 (let* ((b (add-text-to-store %store "build" "echo $foo > $out" '()))
586 (s (add-to-store %store "bash" #t "sha256"
587 (search-bootstrap-binary "bash"
588 (%current-system))))
589 (d (derivation %store "the-thing"
590 s `("-e" ,b)
591 #:env-vars `(("foo" . ,(random-text)))
592 #:inputs `((,b) (,s))))
593 (o (derivation->output-path d)))
594 (and (build-derivations %store (list d))
595 (file-exists? (pk (log-file %store o)))
596 (string=? (log-file %store (derivation-file-name d))
597 (log-file %store o)))))
598
599 (test-assert "no substitutes"
600 (with-store s
601 (let* ((d1 (package-derivation s %bootstrap-guile (%current-system)))
602 (d2 (package-derivation s %bootstrap-glibc (%current-system)))
603 (o (map derivation->output-path (list d1 d2))))
604 (set-build-options s #:use-substitutes? #f)
605 (and (not (has-substitutes? s (derivation-file-name d1)))
606 (not (has-substitutes? s (derivation-file-name d2)))
607 (null? (substitutable-paths s o))
608 (null? (substitutable-path-info s o))))))
609
610 (test-assert "build-things with output path"
611 (with-store s
612 (let* ((c (random-text)) ;contents of the output
613 (d (build-expression->derivation
614 s "substitute-me"
615 `(call-with-output-file %output
616 (lambda (p)
617 (display ,c p)))
618 #:guile-for-build
619 (package-derivation s %bootstrap-guile (%current-system))))
620 (o (derivation->output-path d)))
621 (set-build-options s #:use-substitutes? #f)
622
623 ;; Pass 'build-things' the output file name, O. However, since there
624 ;; are no substitutes for O, it will just do nothing.
625 (build-things s (list o))
626 (not (valid-path? s o)))))
627
628 (test-skip (if (getenv "GUIX_BINARY_SUBSTITUTE_URL") 0 1))
629
630 (test-assert "substitute query"
631 (with-store s
632 (let* ((d (package-derivation s %bootstrap-guile (%current-system)))
633 (o (derivation->output-path d)))
634 ;; Create fake substituter data, to be read by 'guix substitute'.
635 (with-derivation-narinfo d
636 ;; Remove entry from the local cache.
637 (false-if-exception
638 (delete-file-recursively (string-append (getenv "XDG_CACHE_HOME")
639 "/guix/substitute")))
640
641 ;; Make sure 'guix substitute' correctly communicates the above
642 ;; data.
643 (set-build-options s #:use-substitutes? #t
644 #:substitute-urls (%test-substitute-urls))
645 (and (has-substitutes? s o)
646 (equal? (list o) (substitutable-paths s (list o)))
647 (match (pk 'spi (substitutable-path-info s (list o)))
648 (((? substitutable? s))
649 (and (string=? (substitutable-deriver s)
650 (derivation-file-name d))
651 (null? (substitutable-references s))
652 (equal? (substitutable-nar-size s) 1234)))))))))
653
654 (test-assert "substitute query, alternating URLs"
655 (let* ((d (with-store s
656 (package-derivation s %bootstrap-guile (%current-system))))
657 (o (derivation->output-path d)))
658 (with-derivation-narinfo d
659 ;; Remove entry from the local cache.
660 (false-if-exception
661 (delete-file-recursively (string-append (getenv "XDG_CACHE_HOME")
662 "/guix/substitute")))
663
664 ;; Note: We reconnect to the daemon to force a new instance of 'guix
665 ;; substitute' to be used; otherwise the #:substitute-urls of
666 ;; 'set-build-options' would have no effect.
667
668 (and (with-store s ;the right substitute URL
669 (set-build-options s #:use-substitutes? #t
670 #:substitute-urls (%test-substitute-urls))
671 (has-substitutes? s o))
672 (with-store s ;the wrong one
673 (set-build-options s #:use-substitutes? #t
674 #:substitute-urls (list
675 "http://does-not-exist"))
676 (not (has-substitutes? s o)))
677 (with-store s ;the right one again
678 (set-build-options s #:use-substitutes? #t
679 #:substitute-urls (%test-substitute-urls))
680 (has-substitutes? s o))
681 (with-store s ;empty list of URLs
682 (set-build-options s #:use-substitutes? #t
683 #:substitute-urls '())
684 (not (has-substitutes? s o)))))))
685
686 (test-assert "substitute"
687 (with-store s
688 (let* ((c (random-text)) ; contents of the output
689 (d (build-expression->derivation
690 s "substitute-me"
691 `(call-with-output-file %output
692 (lambda (p)
693 (exit 1) ; would actually fail
694 (display ,c p)))
695 #:guile-for-build
696 (package-derivation s %bootstrap-guile (%current-system))))
697 (o (derivation->output-path d)))
698 (with-derivation-substitute d c
699 (set-build-options s #:use-substitutes? #t
700 #:substitute-urls (%test-substitute-urls))
701 (and (has-substitutes? s o)
702 (build-derivations s (list d))
703 (equal? c (call-with-input-file o get-string-all)))))))
704
705 (test-assert "substitute + build-things with output path"
706 (with-store s
707 (let* ((c (random-text)) ;contents of the output
708 (d (build-expression->derivation
709 s "substitute-me"
710 `(call-with-output-file %output
711 (lambda (p)
712 (exit 1) ;would actually fail
713 (display ,c p)))
714 #:guile-for-build
715 (package-derivation s %bootstrap-guile (%current-system))))
716 (o (derivation->output-path d)))
717 (with-derivation-substitute d c
718 (set-build-options s #:use-substitutes? #t
719 #:substitute-urls (%test-substitute-urls))
720 (and (has-substitutes? s o)
721 (build-things s (list o)) ;give the output path
722 (valid-path? s o)
723 (equal? c (call-with-input-file o get-string-all)))))))
724
725 (test-assert "substitute + build-things with specific output"
726 (with-store s
727 (let* ((c (random-text)) ;contents of the output
728 (d (build-expression->derivation
729 s "substitute-me" `(begin ,c (exit 1)) ;would fail
730 #:outputs '("out" "one" "two")
731 #:guile-for-build
732 (package-derivation s %bootstrap-guile (%current-system))))
733 (o (derivation->output-path d)))
734 (with-derivation-substitute d c
735 (set-build-options s #:use-substitutes? #t
736 #:substitute-urls (%test-substitute-urls))
737 (and (has-substitutes? s o)
738
739 ;; Ask for nothing but the "out" output of D.
740 (build-things s `((,(derivation-file-name d) . "out")))
741
742 (valid-path? s o)
743 (equal? c (call-with-input-file o get-string-all)))))))
744
745 (test-assert "substitute, corrupt output hash"
746 ;; Tweak the substituter into installing a substitute whose hash doesn't
747 ;; match the one announced in the narinfo. The daemon must notice this and
748 ;; raise an error.
749 (with-store s
750 (let* ((c "hello, world") ; contents of the output
751 (d (build-expression->derivation
752 s "corrupt-substitute"
753 `(mkdir %output)
754 #:guile-for-build
755 (package-derivation s %bootstrap-guile (%current-system))))
756 (o (derivation->output-path d)))
757 (with-derivation-substitute d c
758 (sha256 => (make-bytevector 32 0)) ;select a hash that doesn't match C
759
760 ;; Make sure we use 'guix substitute'.
761 (set-build-options s
762 #:use-substitutes? #t
763 #:fallback? #f
764 #:substitute-urls (%test-substitute-urls))
765 (and (has-substitutes? s o)
766 (guard (c ((store-protocol-error? c)
767 ;; XXX: the daemon writes "hash mismatch in downloaded
768 ;; path", but the actual error returned to the client
769 ;; doesn't mention that.
770 (pk 'corrupt c)
771 (not (zero? (store-protocol-error-status c)))))
772 (build-derivations s (list d))
773 #f))))))
774
775 (test-assert "substitute --fallback"
776 (with-store s
777 (let* ((t (random-text)) ; contents of the output
778 (d (build-expression->derivation
779 s "substitute-me-not"
780 `(call-with-output-file %output
781 (lambda (p)
782 (display ,t p)))
783 #:guile-for-build
784 (package-derivation s %bootstrap-guile (%current-system))))
785 (o (derivation->output-path d)))
786 ;; Create fake substituter data, to be read by 'guix substitute'.
787 (with-derivation-narinfo d
788 ;; Make sure we use 'guix substitute'.
789 (set-build-options s #:use-substitutes? #t
790 #:substitute-urls (%test-substitute-urls))
791 (and (has-substitutes? s o)
792 (guard (c ((store-protocol-error? c)
793 ;; The substituter failed as expected. Now make
794 ;; sure that #:fallback? #t works correctly.
795 (set-build-options s
796 #:use-substitutes? #t
797 #:substitute-urls
798 (%test-substitute-urls)
799 #:fallback? #t)
800 (and (build-derivations s (list d))
801 (equal? t (call-with-input-file o
802 get-string-all)))))
803 ;; Should fail.
804 (build-derivations s (list d))
805 #f))))))
806
807 (test-assert "export/import several paths"
808 (let* ((texts (unfold (cut >= <> 10)
809 (lambda _ (random-text))
810 1+
811 0))
812 (files (map (cut add-text-to-store %store "text" <>) texts))
813 (dump (call-with-bytevector-output-port
814 (cut export-paths %store files <>))))
815 (delete-paths %store files)
816 (and (every (negate file-exists?) files)
817 (let* ((source (open-bytevector-input-port dump))
818 (imported (import-paths %store source)))
819 (and (equal? imported files)
820 (every file-exists? files)
821 (equal? texts
822 (map (lambda (file)
823 (call-with-input-file file
824 get-string-all))
825 files)))))))
826
827 (test-assert "export/import paths, ensure topological order"
828 (let* ((file0 (add-text-to-store %store "baz" (random-text)))
829 (file1 (add-text-to-store %store "foo" (random-text)
830 (list file0)))
831 (file2 (add-text-to-store %store "bar" (random-text)
832 (list file1)))
833 (files (list file1 file2))
834 (dump1 (call-with-bytevector-output-port
835 (cute export-paths %store (list file1 file2) <>)))
836 (dump2 (call-with-bytevector-output-port
837 (cute export-paths %store (list file2 file1) <>))))
838 (delete-paths %store files)
839 (and (every (negate file-exists?) files)
840 (bytevector=? dump1 dump2)
841 (let* ((source (open-bytevector-input-port dump1))
842 (imported (import-paths %store source)))
843 ;; DUMP1 should contain exactly FILE1 and FILE2, not FILE0.
844 (and (equal? imported (list file1 file2))
845 (every file-exists? files)
846 (equal? (list file0) (references %store file1))
847 (equal? (list file1) (references %store file2)))))))
848
849 (test-assert "export/import incomplete"
850 (let* ((file0 (add-text-to-store %store "baz" (random-text)))
851 (file1 (add-text-to-store %store "foo" (random-text)
852 (list file0)))
853 (file2 (add-text-to-store %store "bar" (random-text)
854 (list file1)))
855 (dump (call-with-bytevector-output-port
856 (cute export-paths %store (list file2) <>))))
857 (delete-paths %store (list file0 file1 file2))
858 (guard (c ((store-protocol-error? c)
859 (and (not (zero? (store-protocol-error-status c)))
860 (string-contains (store-protocol-error-message c)
861 "not valid"))))
862 ;; Here we get an exception because DUMP does not include FILE0 and
863 ;; FILE1, which are dependencies of FILE2.
864 (import-paths %store (open-bytevector-input-port dump)))))
865
866 (test-assert "export/import recursive"
867 (let* ((file0 (add-text-to-store %store "baz" (random-text)))
868 (file1 (add-text-to-store %store "foo" (random-text)
869 (list file0)))
870 (file2 (add-text-to-store %store "bar" (random-text)
871 (list file1)))
872 (dump (call-with-bytevector-output-port
873 (cute export-paths %store (list file2) <>
874 #:recursive? #t))))
875 (delete-paths %store (list file0 file1 file2))
876 (let ((imported (import-paths %store (open-bytevector-input-port dump))))
877 (and (equal? imported (list file0 file1 file2))
878 (every file-exists? (list file0 file1 file2))
879 (equal? (list file0) (references %store file1))
880 (equal? (list file1) (references %store file2))))))
881
882 (test-assert "write-file & export-path yield the same result"
883 ;; Here we compare 'write-file' and the daemon's own implementation.
884 ;; 'write-file' is the reference because we know it sorts file
885 ;; deterministically. Conversely, the daemon uses 'readdir' and the entries
886 ;; currently happen to be sorted as a side-effect of some unrelated
887 ;; operation (search for 'unhacked' in archive.cc.) Make sure we detect any
888 ;; changes there.
889 (run-with-store %store
890 (mlet* %store-monad ((drv1 (package->derivation %bootstrap-guile))
891 (out1 -> (derivation->output-path drv1))
892 (data -> (unfold (cut >= <> 26)
893 (lambda (i)
894 (random-bytevector 128))
895 1+ 0))
896 (build
897 -> #~(begin
898 (use-modules (rnrs io ports) (srfi srfi-1))
899 (let ()
900 (define letters
901 (map (lambda (i)
902 (string
903 (integer->char
904 (+ i (char->integer #\a)))))
905 (iota 26)))
906 (define (touch file data)
907 (call-with-output-file file
908 (lambda (port)
909 (put-bytevector port data))))
910
911 (mkdir #$output)
912 (chdir #$output)
913
914 ;; The files must be different so they have
915 ;; different inode numbers, and the inode
916 ;; order must differ from the lexicographic
917 ;; order.
918 (for-each touch
919 (append (drop letters 10)
920 (take letters 10))
921 (list #$@data))
922 #t)))
923 (drv2 (gexp->derivation "bunch" build))
924 (out2 -> (derivation->output-path drv2))
925 (item-info -> (store-lift query-path-info)))
926 (mbegin %store-monad
927 (built-derivations (list drv1 drv2))
928 (foldm %store-monad
929 (lambda (item result)
930 (define ref-hash
931 (let-values (((port get) (open-sha256-port)))
932 (write-file item port)
933 (close-port port)
934 (get)))
935
936 ;; 'query-path-info' returns a hash produced by using the
937 ;; daemon's C++ 'dump' function, which is the implementation
938 ;; under test.
939 (>>= (item-info item)
940 (lambda (info)
941 (return
942 (and result
943 (bytevector=? (path-info-hash info) ref-hash))))))
944 #t
945 (list out1 out2))))
946 #:guile-for-build (%guile-for-build)))
947
948 (test-assert "import corrupt path"
949 (let* ((text (random-text))
950 (file (add-text-to-store %store "text" text))
951 (dump (call-with-bytevector-output-port
952 (cut export-paths %store (list file) <>))))
953 (delete-paths %store (list file))
954
955 ;; Flip a bit in the stream's payload. INDEX here falls in the middle of
956 ;; the file contents in DUMP, regardless of the store prefix.
957 (let* ((index #x70)
958 (byte (bytevector-u8-ref dump index)))
959 (bytevector-u8-set! dump index (logxor #xff byte)))
960
961 (and (not (file-exists? file))
962 (guard (c ((store-protocol-error? c)
963 (pk 'c c)
964 (and (not (zero? (store-protocol-error-status c)))
965 (string-contains (store-protocol-error-message c)
966 "corrupt"))))
967 (let* ((source (open-bytevector-input-port dump))
968 (imported (import-paths %store source)))
969 (pk 'corrupt-imported imported)
970 #f)))))
971
972 (test-assert "verify-store"
973 (let* ((text (random-text))
974 (file1 (add-text-to-store %store "foo" text))
975 (file2 (add-text-to-store %store "bar" (random-text)
976 (list file1))))
977 (and (pk 'verify1 (verify-store %store)) ;hopefully OK ;
978 (begin
979 (delete-file file1)
980 (not (pk 'verify2 (verify-store %store)))) ;bad! ;
981 (begin
982 ;; Using 'add-text-to-store' here wouldn't work: It would succeed ;
983 ;; without actually creating the file. ;
984 (call-with-output-file file1
985 (lambda (port)
986 (display text port)))
987 (pk 'verify3 (verify-store %store)))))) ;OK again
988
989 (test-assert "verify-store + check-contents"
990 ;; XXX: This test is I/O intensive.
991 (with-store s
992 (let* ((text (random-text))
993 (drv (build-expression->derivation
994 s "corrupt"
995 `(let ((out (assoc-ref %outputs "out")))
996 (call-with-output-file out
997 (lambda (port)
998 (display ,text port)))
999 #t)
1000 #:guile-for-build
1001 (package-derivation s %bootstrap-guile (%current-system))))
1002 (file (derivation->output-path drv)))
1003 (with-derivation-substitute drv text
1004 (and (build-derivations s (list drv))
1005 (verify-store s #:check-contents? #t) ;should be OK
1006 (begin
1007 (chmod file #o644)
1008 (call-with-output-file file
1009 (lambda (port)
1010 (display "corrupt!" port)))
1011 #t)
1012
1013 ;; Make sure the corruption is detected. We don't test repairing
1014 ;; because only "trusted" users are allowed to do it, but we
1015 ;; don't expose that notion of trusted users that nix-daemon
1016 ;; supports because it seems dubious and redundant with what the
1017 ;; OS provides (in Nix "trusted" users have additional
1018 ;; privileges, such as overriding the set of substitute URLs, but
1019 ;; we instead want to allow anyone to modify them, provided
1020 ;; substitutes are signed by a root-approved key.)
1021 (not (verify-store s #:check-contents? #t))
1022
1023 ;; Delete the corrupt item to leave the store in a clean state.
1024 (delete-paths s (list file)))))))
1025
1026 (test-assert "build-things, check mode"
1027 (with-store store
1028 (call-with-temporary-output-file
1029 (lambda (entropy entropy-port)
1030 (write (random-text) entropy-port)
1031 (force-output entropy-port)
1032 (let* ((drv (build-expression->derivation
1033 store "non-deterministic"
1034 `(begin
1035 (use-modules (rnrs io ports))
1036 (let ((out (assoc-ref %outputs "out")))
1037 (call-with-output-file out
1038 (lambda (port)
1039 ;; Rely on the fact that tests do not use the
1040 ;; chroot, and thus ENTROPY is readable.
1041 (display (call-with-input-file ,entropy
1042 get-string-all)
1043 port)))
1044 #t))
1045 #:guile-for-build
1046 (package-derivation store %bootstrap-guile (%current-system))))
1047 (file (derivation->output-path drv)))
1048 (and (build-things store (list (derivation-file-name drv)))
1049 (begin
1050 (write (random-text) entropy-port)
1051 (force-output entropy-port)
1052 (guard (c ((store-protocol-error? c)
1053 (pk 'determinism-exception c)
1054 (and (not (zero? (store-protocol-error-status c)))
1055 (string-contains (store-protocol-error-message c)
1056 "deterministic"))))
1057 ;; This one will produce a different result. Since we're in
1058 ;; 'check' mode, this must fail.
1059 (build-things store (list (derivation-file-name drv))
1060 (build-mode check))
1061 #f))))))))
1062
1063 (test-assert "build-succeeded trace in check mode"
1064 (string-contains
1065 (call-with-output-string
1066 (lambda (port)
1067 (let ((d (build-expression->derivation
1068 %store "foo" '(mkdir (assoc-ref %outputs "out"))
1069 #:guile-for-build
1070 (package-derivation %store %bootstrap-guile))))
1071 (build-derivations %store (list d))
1072 (parameterize ((current-build-output-port port))
1073 (build-derivations %store (list d) (build-mode check))))))
1074 "@ build-succeeded"))
1075
1076 (test-assert "build multiple times"
1077 (with-store store
1078 ;; Ask to build twice.
1079 (set-build-options store #:rounds 2 #:use-substitutes? #f)
1080
1081 (call-with-temporary-output-file
1082 (lambda (entropy entropy-port)
1083 (write (random-text) entropy-port)
1084 (force-output entropy-port)
1085 (let* ((drv (build-expression->derivation
1086 store "non-deterministic"
1087 `(begin
1088 (use-modules (rnrs io ports))
1089 (let ((out (assoc-ref %outputs "out")))
1090 (call-with-output-file out
1091 (lambda (port)
1092 ;; Rely on the fact that tests do not use the
1093 ;; chroot, and thus ENTROPY is accessible.
1094 (display (call-with-input-file ,entropy
1095 get-string-all)
1096 port)
1097 (call-with-output-file ,entropy
1098 (lambda (port)
1099 (write 'foobar port)))))
1100 #t))
1101 #:guile-for-build
1102 (package-derivation store %bootstrap-guile (%current-system))))
1103 (file (derivation->output-path drv)))
1104 (guard (c ((store-protocol-error? c)
1105 (pk 'multiple-build c)
1106 (and (not (zero? (store-protocol-error-status c)))
1107 (string-contains (store-protocol-error-message c)
1108 "deterministic"))))
1109 ;; This one will produce a different result on the second run.
1110 (current-build-output-port (current-error-port))
1111 (build-things store (list (derivation-file-name drv)))
1112 #f))))))
1113
1114 (test-equal "store-lower"
1115 "Lowered."
1116 (let* ((add (store-lower text-file))
1117 (file (add %store "foo" "Lowered.")))
1118 (call-with-input-file file get-string-all)))
1119
1120 (test-equal "current-system"
1121 "bar"
1122 (parameterize ((%current-system "frob"))
1123 (run-with-store %store
1124 (mbegin %store-monad
1125 (set-current-system "bar")
1126 (current-system))
1127 #:system "foo")))
1128
1129 (test-assert "query-path-info"
1130 (let* ((ref (add-text-to-store %store "ref" "foo"))
1131 (item (add-text-to-store %store "item" "bar" (list ref)))
1132 (info (query-path-info %store item)))
1133 (and (equal? (path-info-references info) (list ref))
1134 (equal? (path-info-hash info)
1135 (sha256
1136 (string->utf8
1137 (call-with-output-string (cut write-file item <>))))))))
1138
1139 (test-assert "path-info-deriver"
1140 (let* ((b (add-text-to-store %store "build" "echo $foo > $out" '()))
1141 (s (add-to-store %store "bash" #t "sha256"
1142 (search-bootstrap-binary "bash"
1143 (%current-system))))
1144 (d (derivation %store "the-thing"
1145 s `("-e" ,b)
1146 #:env-vars `(("foo" . ,(random-text)))
1147 #:inputs `((,b) (,s))))
1148 (o (derivation->output-path d)))
1149 (and (build-derivations %store (list d))
1150 (not (path-info-deriver (query-path-info %store b)))
1151 (string=? (derivation-file-name d)
1152 (path-info-deriver (query-path-info %store o))))))
1153
1154 (test-equal "build-cores"
1155 (list 0 42)
1156 (with-store store
1157 (let* ((build (add-text-to-store store "build.sh"
1158 "echo $NIX_BUILD_CORES > $out"))
1159 (bash (add-to-store store "bash" #t "sha256"
1160 (search-bootstrap-binary "bash"
1161 (%current-system))))
1162 (drv1 (derivation store "the-thing" bash
1163 `("-e" ,build)
1164 #:inputs `((,bash) (,build))
1165 #:env-vars `(("x" . ,(random-text)))))
1166 (drv2 (derivation store "the-thing" bash
1167 `("-e" ,build)
1168 #:inputs `((,bash) (,build))
1169 #:env-vars `(("x" . ,(random-text))))))
1170 (and (build-derivations store (list drv1))
1171 (begin
1172 (set-build-options store #:build-cores 42)
1173 (build-derivations store (list drv2)))
1174 (list (call-with-input-file (derivation->output-path drv1)
1175 read)
1176 (call-with-input-file (derivation->output-path drv2)
1177 read))))))
1178
1179 (test-equal "multiplexed-build-output"
1180 '("Hello from first." "Hello from second.")
1181 (with-store store
1182 (let* ((build (add-text-to-store store "build.sh"
1183 "echo Hello from $NAME.; echo > $out"))
1184 (bash (add-to-store store "bash" #t "sha256"
1185 (search-bootstrap-binary "bash"
1186 (%current-system))))
1187 (drv1 (derivation store "one" bash
1188 `("-e" ,build)
1189 #:inputs `((,bash) (,build))
1190 #:env-vars `(("NAME" . "first")
1191 ("x" . ,(random-text)))))
1192 (drv2 (derivation store "two" bash
1193 `("-e" ,build)
1194 #:inputs `((,bash) (,build))
1195 #:env-vars `(("NAME" . "second")
1196 ("x" . ,(random-text))))))
1197 (set-build-options store
1198 #:print-build-trace #t
1199 #:multiplexed-build-output? #t
1200 #:max-build-jobs 10)
1201 (let ((port (open-output-string)))
1202 ;; Send the build log to PORT.
1203 (parameterize ((current-build-output-port port))
1204 (build-derivations store (list drv1 drv2)))
1205
1206 ;; Retrieve the build log; make sure it contains valid "@ build-log"
1207 ;; traces that allow us to retrieve each builder's output (we assume
1208 ;; there's exactly one "build-output" trace for each builder, which is
1209 ;; reasonable.)
1210 (let* ((log (get-output-string port))
1211 (started (fold-matches
1212 (make-regexp "@ build-started ([^ ]+) - ([^ ]+) ([^ ]+) ([0-9]+)")
1213 log '() cons))
1214 (done (fold-matches
1215 (make-regexp "@ build-succeeded (.*) - (.*) (.*) (.*)")
1216 log '() cons))
1217 (output (fold-matches
1218 (make-regexp "@ build-log ([[:digit:]]+) ([[:digit:]]+)\n([A-Za-z .*]+)\n")
1219 log '() cons))
1220 (drv-pid (lambda (name)
1221 (lambda (m)
1222 (let ((drv (match:substring m 1))
1223 (pid (string->number
1224 (match:substring m 4))))
1225 (and (string-suffix? name drv) pid)))))
1226 (pid-log (lambda (pid)
1227 (lambda (m)
1228 (let ((n (string->number
1229 (match:substring m 1)))
1230 (len (string->number
1231 (match:substring m 2)))
1232 (str (match:substring m 3)))
1233 (and (= pid n)
1234 (= (string-length str) (- len 1))
1235 str)))))
1236 (pid1 (any (drv-pid "one.drv") started))
1237 (pid2 (any (drv-pid "two.drv") started)))
1238 (list (any (pid-log pid1) output)
1239 (any (pid-log pid2) output)))))))
1240
1241 (test-end "store")