diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2004-05-04T13·56+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2004-05-04T13·56+0000 |
commit | f044ccf7025137ec541e165e7988772f27080a23 (patch) | |
tree | 90a3215c4c66682841ba628467e1863e20416fa8 | |
parent | a7bbe739717c7419a374b29e6e4887325b1af7fd (diff) |
* 1000th revision!
* A test to verify that locking of output paths (caused by concurrent invocations of Nix) works correctly.
-rw-r--r-- | tests/Makefile.am | 8 | ||||
-rw-r--r-- | tests/locking.builder.sh | 9 | ||||
-rw-r--r-- | tests/locking.nix.in | 18 | ||||
-rw-r--r-- | tests/locking.sh | 17 |
4 files changed, 50 insertions, 2 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 2119221bbcc2..ba45a3ad8fd0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -11,11 +11,15 @@ TESTS_ENVIRONMENT = TEST_ROOT=$(TEST_ROOT) \ simple.sh: simple.nix dependencies.sh: dependencies.nix +locking.sh: locking.nix -TESTS = init.sh simple.sh dependencies.sh +TESTS = init.sh simple.sh dependencies.sh locking.sh + +XFAIL_TESTS = include ../substitute.mk EXTRA_DIST = $(TESTS) \ simple.nix.in simple.builder.sh \ - dependencies.nix.in dependencies.builder*.sh + dependencies.nix.in dependencies.builder*.sh \ + locking.nix.in locking.builder.sh \ No newline at end of file diff --git a/tests/locking.builder.sh b/tests/locking.builder.sh new file mode 100644 index 000000000000..5c3dfdafbc59 --- /dev/null +++ b/tests/locking.builder.sh @@ -0,0 +1,9 @@ +export PATH=/bin:/usr/bin:$PATH + +sleep 3 + +touch $out +# Use `>>'; without proper locking this will cause text duplication. +echo -n $(cat $inputs)$text >> $out + +sleep 2 \ No newline at end of file diff --git a/tests/locking.nix.in b/tests/locking.nix.in new file mode 100644 index 000000000000..72070678f07a --- /dev/null +++ b/tests/locking.nix.in @@ -0,0 +1,18 @@ +let { + + mkDrv = text: inputs: derivation { + name = "locking"; + system = "@system@"; + builder = "@shell@"; + args = ["-e" "-x" ./locking.builder.sh]; + inherit text inputs; + }; + + a = mkDrv "a" []; + b = mkDrv "b" [a]; + c = mkDrv "c" [a b]; + d = mkDrv "d" [a]; + e = mkDrv "e" [c d]; + + body = e; +} \ No newline at end of file diff --git a/tests/locking.sh b/tests/locking.sh new file mode 100644 index 000000000000..5728aee93727 --- /dev/null +++ b/tests/locking.sh @@ -0,0 +1,17 @@ +storeExpr=$($TOP/src/nix-instantiate/nix-instantiate locking.nix) + +echo "store expr is $storeExpr" + +for i in $(seq 1 5); do + echo "WORKER $i" + $TOP/src/nix-store/nix-store -rvvB "$storeExpr" & +done + +sleep 5 + +outPath=$($TOP/src/nix-store/nix-store -qnfvvvvv "$storeExpr") + +echo "output path is $outPath" + +text=$(cat "$outPath") +if test "$text" != "aabcade"; then exit 1; fi |