2006-03-01 12:15:33 +00:00
|
|
|
source common.sh
|
|
|
|
|
2009-03-18 14:48:42 +00:00
|
|
|
$NIX_BIN_DIR/nix-collect-garbage
|
2008-08-14 09:26:30 +00:00
|
|
|
|
2009-03-17 17:11:55 +00:00
|
|
|
drvPath1=$($nixinstantiate gc-concurrent.nix -A test1)
|
2006-03-01 12:51:18 +00:00
|
|
|
outPath1=$($nixstore -q $drvPath1)
|
2005-01-31 22:01:55 +00:00
|
|
|
|
2009-03-17 17:11:55 +00:00
|
|
|
drvPath2=$($nixinstantiate gc-concurrent.nix -A test2)
|
2006-03-01 12:51:18 +00:00
|
|
|
outPath2=$($nixstore -q $drvPath2)
|
2005-01-28 20:36:46 +00:00
|
|
|
|
2008-12-12 17:03:18 +00:00
|
|
|
drvPath3=$($nixinstantiate simple.nix)
|
|
|
|
outPath3=$($nixstore -r $drvPath3)
|
|
|
|
|
|
|
|
! test -e $outPath3.lock
|
|
|
|
touch $outPath3.lock
|
|
|
|
|
|
|
|
rm -f "$NIX_STATE_DIR"/gcroots/foo*
|
2006-03-01 13:25:08 +00:00
|
|
|
ln -s $drvPath2 "$NIX_STATE_DIR"/gcroots/foo
|
2008-12-12 17:03:18 +00:00
|
|
|
ln -s $outPath3 "$NIX_STATE_DIR"/gcroots/foo2
|
2005-01-31 22:23:49 +00:00
|
|
|
|
2005-01-31 22:01:55 +00:00
|
|
|
# Start build #1 in the background. It starts immediately.
|
2006-03-01 12:51:18 +00:00
|
|
|
$nixstore -rvv "$drvPath1" &
|
2005-01-31 22:01:55 +00:00
|
|
|
pid1=$!
|
2005-01-28 20:36:46 +00:00
|
|
|
|
2008-08-14 09:26:30 +00:00
|
|
|
# Start build #2 in the background after 6 seconds.
|
|
|
|
(sleep 6 && $nixstore -rvv "$drvPath2") &
|
2005-01-31 22:01:55 +00:00
|
|
|
pid2=$!
|
2005-01-28 20:36:46 +00:00
|
|
|
|
2008-08-14 09:26:30 +00:00
|
|
|
# Run the garbage collector while the build is running.
|
|
|
|
sleep 4
|
2009-03-18 14:48:42 +00:00
|
|
|
$NIX_BIN_DIR/nix-collect-garbage
|
2005-01-31 22:01:55 +00:00
|
|
|
|
|
|
|
# Wait for build #1/#2 to finish.
|
|
|
|
echo waiting for pid $pid1 to finish...
|
|
|
|
wait $pid1
|
|
|
|
echo waiting for pid $pid2 to finish...
|
|
|
|
wait $pid2
|
2005-01-28 20:36:46 +00:00
|
|
|
|
2005-01-31 22:01:55 +00:00
|
|
|
# Check that the root of build #1 and its dependencies haven't been
|
2008-08-14 09:26:30 +00:00
|
|
|
# deleted. The should not be deleted by the GC because they were
|
|
|
|
# being built during the GC.
|
2005-01-31 22:01:55 +00:00
|
|
|
cat $outPath1/foobar
|
|
|
|
cat $outPath1/input-2/bar
|
2005-01-28 20:36:46 +00:00
|
|
|
|
2008-08-14 09:26:30 +00:00
|
|
|
# Check that build #2 has succeeded. It should succeed because the
|
|
|
|
# derivation is a GC root.
|
2005-01-31 22:01:55 +00:00
|
|
|
cat $outPath2/foobar
|
2006-03-01 13:25:08 +00:00
|
|
|
|
2008-12-12 17:03:18 +00:00
|
|
|
rm -f "$NIX_STATE_DIR"/gcroots/foo*
|
|
|
|
|
|
|
|
# The collector should have deleted lock files for paths that have
|
|
|
|
# been built previously.
|
|
|
|
! test -e $outPath3.lock
|
|
|
|
|
|
|
|
# If we run the collector now, it should delete outPath1/2.
|
2009-03-18 14:48:42 +00:00
|
|
|
$NIX_BIN_DIR/nix-collect-garbage
|
2008-12-12 17:03:18 +00:00
|
|
|
! test -e $outPath1
|
|
|
|
! test -e $outPath2
|