diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-01-31 22:01:55 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-01-31 22:01:55 +0000 |
commit | 89c9bc11abc02cc746838bfef101e5fecc59a6c5 (patch) | |
tree | ff3f905443476b0c41be7560851cd90b2823b8df /tests/gc-concurrent.sh | |
parent | 207bdcbe86bac5fb9e650d26b22ae33c667151e4 (diff) |
* Add a test for a more subtle race: a process starting after the
temporary root files have been read but creating outputs before the
store directory has been read.
Diffstat (limited to 'tests/gc-concurrent.sh')
-rw-r--r-- | tests/gc-concurrent.sh | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/tests/gc-concurrent.sh b/tests/gc-concurrent.sh index c41475fb6..fd329b457 100644 --- a/tests/gc-concurrent.sh +++ b/tests/gc-concurrent.sh @@ -1,21 +1,34 @@ -storeExpr=$($TOP/src/nix-instantiate/nix-instantiate gc-concurrent.nix) -outPath=$($TOP/src/nix-store/nix-store -q $storeExpr) +storeExpr1=$($TOP/src/nix-instantiate/nix-instantiate gc-concurrent.nix) +outPath1=$($TOP/src/nix-store/nix-store -q $storeExpr1) + +storeExpr2=$($TOP/src/nix-instantiate/nix-instantiate gc-concurrent2.nix) +outPath2=$($TOP/src/nix-store/nix-store -q $storeExpr2) ls -l test-tmp/state/temproots +# Start build #1 in the background. It starts immediately. +$TOP/src/nix-store/nix-store -rvv "$storeExpr1" & +pid1=$! -# Start a build in the background. -$TOP/src/nix-store/nix-store -rvv "$storeExpr" & -pid=$! +# Start build #2 in the background after 3 seconds. +(sleep 3 && $TOP/src/nix-store/nix-store -rvv "$storeExpr2") & +pid2=$! -# Run the garbage collector while the build is running. +# Run the garbage collector while the build is running. Note: the GC +# sleeps for *another* 2 seconds after acquiring the GC lock. This +# checks whether build #1 sleep 2 -$NIX_BIN_DIR/nix-collect-garbage -vvvvv +NIX_DEBUG_GC_WAIT=1 $NIX_BIN_DIR/nix-collect-garbage -vvvvv + +# 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 -# Wait for the build to finish. -echo waiting for pid $pid to finish... -wait $pid +# Check that the root of build #1 and its dependencies haven't been +# deleted. +cat $outPath1/foobar +cat $outPath1/input-2/bar -# Check that the root and its dependencies haven't been deleted. -cat $outPath/foobar -cat $outPath/input-2/bar +cat $outPath2/foobar |