about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/dependencies.sh2
-rw-r--r--tests/export.sh31
-rw-r--r--tests/init.sh3
-rw-r--r--tests/referrers.sh48
5 files changed, 78 insertions, 8 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bab9e8ee4771..c65f68584663 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,7 +19,7 @@ TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \
   fallback.sh nix-push.sh gc.sh gc-concurrent.sh verify.sh nix-pull.sh \
   referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \
   gc-runtime.sh install-package.sh check-refs.sh filter-source.sh \
-  remote-store.sh
+  remote-store.sh export.sh
 
 XFAIL_TESTS =
 
diff --git a/tests/dependencies.sh b/tests/dependencies.sh
index 434027e461fe..440b6fae0c68 100644
--- a/tests/dependencies.sh
+++ b/tests/dependencies.sh
@@ -11,7 +11,7 @@ $nixstore -q --graph "$drvPath" > $TEST_ROOT/graph
 if test -n "$dot"; then
     # Does it parse?
     $dot < $TEST_ROOT/graph
-fi    
+fi
 
 outPath=$($nixstore -rvv "$drvPath")
 
diff --git a/tests/export.sh b/tests/export.sh
new file mode 100644
index 000000000000..53c9ec3c68df
--- /dev/null
+++ b/tests/export.sh
@@ -0,0 +1,31 @@
+source common.sh
+
+clearStore
+
+outPath=$($nixstore -r $($nixinstantiate dependencies.nix))
+
+$nixstore --export $outPath > $TEST_ROOT/exp
+
+$nixstore --export $($nixstore -qR $outPath) > $TEST_ROOT/exp_all
+
+
+clearStore
+
+if $nixstore --import < $TEST_ROOT/exp; then
+    echo "importing a non-closure should fail"
+    exit 1
+fi
+
+
+clearStore
+
+$nixstore --import < $TEST_ROOT/exp_all
+
+$nixstore --export $($nixstore -qR $outPath) > $TEST_ROOT/exp_all2
+
+
+clearStore
+
+# Regression test: the derivers in exp_all2 are empty, which shouldn't
+# cause a failure.
+$nixstore --import < $TEST_ROOT/exp_all2
diff --git a/tests/init.sh b/tests/init.sh
index 2713aa590b9f..7becc422e373 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -95,4 +95,5 @@ chmod +x $NIX_BIN_DIR/nix/download-using-manifests.pl
 $nixstore --init
 
 # Did anything happen?
-test -e "$NIX_DB_DIR"/validpaths
+test -e "$NIX_DB_DIR"/info
+test -e "$NIX_DB_DIR"/referrer
diff --git a/tests/referrers.sh b/tests/referrers.sh
index 4d2aaab5a2b8..2fdf0cf7c47e 100644
--- a/tests/referrers.sh
+++ b/tests/referrers.sh
@@ -9,12 +9,50 @@ reference=$NIX_STORE_DIR/abcdef
 touch $reference
 (echo $reference && echo && echo 0) | $nixstore --register-validity 
 
-echo "registering..."
-time for ((n = 0; n < $max; n++)); do
+echo "making registration..."
+
+for ((n = 0; n < $max; n++)); do
     storePath=$NIX_STORE_DIR/$n
     touch $storePath
-    (echo $storePath && echo && echo 1 && echo $reference)
-done | $nixstore --register-validity 
+    ref2=$NIX_STORE_DIR/$((n+1))
+    if test $((n+1)) = $max; then
+        ref2=$reference
+    fi
+    (echo $storePath && echo && echo 2 && echo $reference && echo $ref2)
+done > $TEST_ROOT/reg_info
+
+echo "registering..."
+
+time $nixstore --register-validity < $TEST_ROOT/reg_info
+
+oldTime=$(cat test-tmp/db/info/1 | grep Registered-At)
+
+echo "sleeping..."
+
+sleep 2
+
+echo "reregistering..."
+
+time $nixstore --register-validity --reregister < $TEST_ROOT/reg_info
+
+newTime=$(cat test-tmp/db/info/1 | grep Registered-At)
+
+if test "$newTime" != "$oldTime"; then
+    echo "reregistration changed original registration time"
+    exit 1
+fi
+
+if test "$(cat test-tmp/db/referrer/1 | wc -w)" != 1; then
+    echo "reregistration duplicated referrers"
+    exit 1
+fi
 
 echo "collecting garbage..."
-time $nixstore --gc 2> /dev/null
+ln -sfn $reference "$NIX_STATE_DIR"/gcroots/ref
+time $nixstore --gc
+
+if test "$(cat test-tmp/db/referrer/abcdef | wc -w)" != 0; then
+    echo "referrers not cleaned up"
+    exit 1
+fi
+