forked from lix-project/lix
Add a test for the non-blocking GC
This commit is contained in:
parent
ac54c6faa6
commit
10f9a8e77d
|
@ -735,6 +735,10 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
|
|||
}
|
||||
};
|
||||
|
||||
/* Synchronisation point for testing, see tests/gc-concurrent.sh. */
|
||||
if (auto p = getEnv("_NIX_TEST_GC_SYNC"))
|
||||
readFile(*p);
|
||||
|
||||
/* Either delete all garbage paths, or just the specified
|
||||
paths (for gcDeleteSpecific). */
|
||||
if (options.action == GCOptions::gcDeleteSpecific) {
|
||||
|
|
33
tests/gc-non-blocking.sh
Normal file
33
tests/gc-non-blocking.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Test whether the collector is non-blocking, i.e. a build can run in
|
||||
# parallel with it.
|
||||
source common.sh
|
||||
|
||||
needLocalStore "the GC test needs a synchronisation point"
|
||||
|
||||
clearStore
|
||||
|
||||
fifo=$TEST_ROOT/test.fifo
|
||||
mkfifo "$fifo"
|
||||
|
||||
dummy=$(nix store add-path ./simple.nix)
|
||||
|
||||
running=$TEST_ROOT/running
|
||||
touch $running
|
||||
|
||||
(_NIX_TEST_GC_SYNC=$fifo nix-store --gc -vvvvv; rm $running) &
|
||||
pid=$!
|
||||
|
||||
sleep 2
|
||||
|
||||
outPath=$(nix-build -o "$TEST_ROOT/result" -E "
|
||||
with import ./config.nix;
|
||||
mkDerivation {
|
||||
name = \"non-blocking\";
|
||||
buildCommand = \"set -x; test -e $running; mkdir \$out; echo > $fifo\";
|
||||
}")
|
||||
|
||||
wait $pid
|
||||
|
||||
(! test -e $running)
|
||||
(! test -e $dummy)
|
||||
test -e $outPath
|
|
@ -4,6 +4,7 @@ nix_tests = \
|
|||
gc.sh \
|
||||
ca/gc.sh \
|
||||
gc-concurrent.sh \
|
||||
gc-non-blocking.sh \
|
||||
gc-auto.sh \
|
||||
referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \
|
||||
gc-runtime.sh check-refs.sh filter-source.sh \
|
||||
|
|
Loading…
Reference in a new issue