1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2013, 2015, 2017 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 # Test the `guix gc' command-line utility.
25 trap "rm -f guix-gc-root" EXIT
28 # Below we are using 'drv' and 'out' to contain store file names. If 'drv'
29 # and 'out' are environment variables, 'list-runtime-roots' will "see" them
30 # and thus prevent $drv and $out from being garbage-collected. Using 'unset'
31 # allows us to make sure these are truly local shell variables and not
32 # environments variables.
36 # For some operations, passing extra arguments is an error.
37 for option
in "" "-C 500M" "--verify" "--optimize"
39 if guix gc
$option whatever
; then false
; else true
; fi
42 # Check the references of a .drv.
43 drv
="`guix build guile-bootstrap -d`"
44 out
="`guix build guile-bootstrap`"
45 test -f "$drv" && test -d "$out"
47 guix gc
--references "$drv" |
grep -e -bash
48 guix gc
--references "$out"
49 guix gc
--references "$out/bin/guile"
51 if guix gc
--references /dev
/null
;
52 then false
; else true
; fi
54 # Add then reclaim a .drv file.
55 drv
="`guix build idutils -d`"
58 guix gc
--list-dead |
grep "$drv"
59 guix gc
--delete "$drv"
62 # Add a .drv, register it as a root.
63 drv
="`guix build --root=guix-gc-root lsh -d`"
64 test -f "$drv" && test -L guix-gc-root
66 guix gc
--list-live |
grep "$drv"
67 if guix gc
--delete "$drv";
68 then false
; else true
; fi
71 guix gc
--list-dead |
grep "$drv"
72 guix gc
--delete "$drv"
75 # Try a random collection.
78 # Check trivial error cases.
79 if guix gc
--delete /dev
/null
;
80 then false
; else true
; fi
83 out
="`guix build guile-bootstrap`"
86 guix gc
--delete "$out"
90 out
="`guix build guile-bootstrap`"
93 guix gc
--delete "$out/"
97 out
="`guix build guile-bootstrap`"
100 guix gc
--delete "$out/bin/guile"