diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2004-05-04 17:04:17 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2004-05-04 17:04:17 +0000 |
commit | a9858c9f26c5be743e0bbe1949954f6bd2497306 (patch) | |
tree | 9ee029ebea9b1ce561eff31a3a6ccfa9b5f26ae5 /tests | |
parent | f044ccf7025137ec541e165e7988772f27080a23 (diff) |
* A test to verify that Nix executes build jobs in parallel, if
possible.
This test fails right now because this hasn't been implemented right
now. Yes, I'm doing Test-Driven Development! ;-)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 12 | ||||
-rw-r--r-- | tests/parallel.builder.sh | 32 | ||||
-rw-r--r-- | tests/parallel.nix.in | 19 | ||||
-rw-r--r-- | tests/parallel.sh | 20 |
4 files changed, 80 insertions, 3 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index ba45a3ad8..d540290b4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,7 @@ TEST_ROOT = $(shell pwd)/test-tmp +extra1 = $(TEST_ROOT)/shared + TESTS_ENVIRONMENT = TEST_ROOT=$(TEST_ROOT) \ NIX_STORE_DIR=$(TEST_ROOT)/store \ NIX_DATA_DIR=$(TEST_ROOT)/data \ @@ -7,19 +9,23 @@ TESTS_ENVIRONMENT = TEST_ROOT=$(TEST_ROOT) \ NIX_STATE_DIR=$(TEST_ROOT)/state \ NIX_DB_DIR=$(TEST_ROOT)/db \ TOP=$(shell pwd)/.. \ + SHARED=$(extra1) \ $(SHELL) -e -x simple.sh: simple.nix dependencies.sh: dependencies.nix locking.sh: locking.nix +parallel.sh: parallel.nix -TESTS = init.sh simple.sh dependencies.sh locking.sh +TESTS = init.sh simple.sh dependencies.sh parallel.sh +#locking.sh parallel.sh -XFAIL_TESTS = +XFAIL_TESTS = parallel.sh include ../substitute.mk EXTRA_DIST = $(TESTS) \ simple.nix.in simple.builder.sh \ dependencies.nix.in dependencies.builder*.sh \ - locking.nix.in locking.builder.sh
\ No newline at end of file + locking.nix.in locking.builder.sh \ + parallel.nix.in parallel.builder.sh diff --git a/tests/parallel.builder.sh b/tests/parallel.builder.sh new file mode 100644 index 000000000..d6d0bedf4 --- /dev/null +++ b/tests/parallel.builder.sh @@ -0,0 +1,32 @@ +echo "DOING $text" + + +export PATH=/bin:/usr/bin:$PATH + + +# increase counter +while ! ln -s x $shared.lock; do + sleep 1 +done +test -f $shared.cur || echo 0 > $shared.cur +test -f $shared.max || echo 0 > $shared.max +new=$(($(cat $shared.cur) + 1)) +if test $new -gt $(cat $shared.max); then + echo $new > $shared.max +fi +echo $new > $shared.cur +rm $shared.lock + + +echo -n $(cat $inputs)$text > $out + +sleep 3 + + +# decrease counter +while ! ln -s x $shared.lock; do + sleep 1 +done +test -f $shared.cur || echo 0 > $shared.cur +echo $(($(cat $shared.cur) - 1)) > $shared.cur +rm $shared.lock diff --git a/tests/parallel.nix.in b/tests/parallel.nix.in new file mode 100644 index 000000000..41d6776d1 --- /dev/null +++ b/tests/parallel.nix.in @@ -0,0 +1,19 @@ +let { + + mkDrv = text: inputs: derivation { + name = "parallel"; + system = "@system@"; + builder = "@shell@"; + args = ["-e" "-x" ./parallel.builder.sh]; + shared = "@extra1@"; + inherit text inputs; + }; + + a = mkDrv "a" []; + b = mkDrv "b" [a]; + c = mkDrv "c" [b]; + d = mkDrv "d" [c]; + e = mkDrv "e" [b c d]; + + body = e; +}
\ No newline at end of file diff --git a/tests/parallel.sh b/tests/parallel.sh new file mode 100644 index 000000000..7040f7ad9 --- /dev/null +++ b/tests/parallel.sh @@ -0,0 +1,20 @@ +storeExpr=$($TOP/src/nix-instantiate/nix-instantiate parallel.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 + +if test "$(cat $SHARED.cur)" != 0; then exit 1; fi +if test "$(cat $SHARED.max)" != 3; then exit 1; fi |