about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2008-08-14T09·26+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2008-08-14T09·26+0000
commitc03b729319997b4e38c3f586d7c76352228b22e7 (patch)
tree90b7d1288117975295b7d6f990c5f9e6698775a5
parent5664b6d7ba28453ccdd6d1c07a707f98608500ff (diff)
* Increase the sleep periods a bit to make the test less likely to
  fail on slow machines.  Of course it would be better if this test
  wasn't timing dependent...

-rw-r--r--src/libstore/gc.cc4
-rw-r--r--tests/gc-concurrent.builder.sh7
-rw-r--r--tests/gc-concurrent.sh20
-rw-r--r--tests/gc-concurrent2.builder.sh2
4 files changed, 17 insertions, 16 deletions
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc
index 8f5a1b6e5c99..a960281ece88 100644
--- a/src/libstore/gc.cc
+++ b/src/libstore/gc.cc
@@ -638,10 +638,6 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
         else
             tempRootsClosed.insert(*i);
 
-    /* For testing - see tests/gc-concurrent.sh. */
-    if (getenv("NIX_DEBUG_GC_WAIT"))
-        sleep(2);
-    
     /* After this point the set of roots or temporary roots cannot
        increase, since we hold locks on everything.  So everything
        that is not currently in in `livePaths' or `tempRootsClosed'
diff --git a/tests/gc-concurrent.builder.sh b/tests/gc-concurrent.builder.sh
index 6b2177ddff2e..0cd67df3aeda 100644
--- a/tests/gc-concurrent.builder.sh
+++ b/tests/gc-concurrent.builder.sh
@@ -1,8 +1,11 @@
 mkdir $out
 echo $(cat $input1/foo)$(cat $input2/bar) > $out/foobar
 
-sleep 5
-mkdir $out || true
+sleep 10
+
+# $out should not have been GC'ed while we were sleeping, but just in
+# case...
+mkdir -p $out
 
 # Check that the GC hasn't deleted the lock on our output.
 test -e "$out.lock"
diff --git a/tests/gc-concurrent.sh b/tests/gc-concurrent.sh
index 446e79f138a6..6cf65207887a 100644
--- a/tests/gc-concurrent.sh
+++ b/tests/gc-concurrent.sh
@@ -1,5 +1,7 @@
 source common.sh
 
+$NIX_BIN_DIR/nix-collect-garbage -vvvvv
+
 drvPath1=$($nixinstantiate gc-concurrent.nix)
 outPath1=$($nixstore -q $drvPath1)
 
@@ -13,15 +15,13 @@ ln -s $drvPath2 "$NIX_STATE_DIR"/gcroots/foo
 $nixstore -rvv "$drvPath1" &
 pid1=$!
 
-# Start build #2 in the background after 3 seconds.
-(sleep 3 && $nixstore -rvv "$drvPath2") &
+# Start build #2 in the background after 6 seconds.
+(sleep 6 && $nixstore -rvv "$drvPath2") &
 pid2=$!
 
-# 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_DEBUG_GC_WAIT=1 $NIX_BIN_DIR/nix-collect-garbage -vvvvv
+# Run the garbage collector while the build is running.
+sleep 4
+$NIX_BIN_DIR/nix-collect-garbage -vvvvv
 
 # Wait for build #1/#2 to finish.
 echo waiting for pid $pid1 to finish...
@@ -30,11 +30,13 @@ echo waiting for pid $pid2 to finish...
 wait $pid2
 
 # Check that the root of build #1 and its dependencies haven't been
-# deleted.
+# deleted.  The should not be deleted by the GC because they were
+# being built during the GC.
 cat $outPath1/foobar
 cat $outPath1/input-2/bar
 
-# Build #2 should have failed because its derivation got garbage collected.
+# Check that build #2 has succeeded.  It should succeed because the
+# derivation is a GC root.
 cat $outPath2/foobar
 
 rm "$NIX_STATE_DIR"/gcroots/foo
diff --git a/tests/gc-concurrent2.builder.sh b/tests/gc-concurrent2.builder.sh
index f7b6094e8b44..4bfb33103e73 100644
--- a/tests/gc-concurrent2.builder.sh
+++ b/tests/gc-concurrent2.builder.sh
@@ -4,4 +4,4 @@ echo $(cat $input1/foo)$(cat $input2/bar)xyzzy > $out/foobar
 # Check that the GC hasn't deleted the lock on our output.
 test -e "$out.lock"
 
-sleep 3
\ No newline at end of file
+sleep 6