store.scm 50 KB

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