1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012 Ludovic Courtès <ludo@gnu.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (test-store)
21 #:use-module (guix store)
22 #:use-module (guix utils)
23 #:use-module (guix base32)
24 #:use-module (gnu packages bootstrap)
25 #:use-module (ice-9 match)
26 #:use-module (srfi srfi-1)
27 #:use-module (srfi srfi-11)
28 #:use-module (srfi srfi-64))
30 ;; Test the (guix store) module.
33 (false-if-exception (open-connection)))
36 ;; Make sure we build everything by ourselves.
37 (set-build-options %store #:use-substitutes? #f))
40 (seed->random-state (logxor (getpid) (car (gettimeofday)))))
43 (number->string (random (expt 2 256) %seed) 16))
48 (test-skip (if %store 0 10))
50 (test-assert "dead-paths"
51 (let ((p (add-text-to-store %store "random-text"
53 (member p (dead-paths %store))))
55 ;; FIXME: Find a test for `live-paths'.
57 ;; (test-assert "temporary root is in live-paths"
58 ;; (let* ((p1 (add-text-to-store %store "random-text"
59 ;; (random-text) '()))
60 ;; (b (add-text-to-store %store "link-builder"
61 ;; (format #f "echo ~a > $out" p1)
63 ;; (d1 (derivation %store "link" (%current-system)
64 ;; "/bin/sh" `("-e" ,b) '()
66 ;; (p2 (derivation-path->output-path d1)))
67 ;; (and (add-temp-root %store p2)
68 ;; (build-derivations %store (list d1))
69 ;; (valid-path? %store p1)
70 ;; (member (pk p2) (live-paths %store)))))
72 (test-assert "dead path can be explicitly collected"
73 (let ((p (add-text-to-store %store "random-text"
75 (let-values (((paths freed) (delete-paths %store (list p))))
76 (and (equal? paths (list p))
78 (not (file-exists? p))))))
83 (exit (= (test-runner-fail-count (test-runner-current)) 0))
86 ;;; eval: (put 'test-assert 'scheme-indent-function 1)