forked from lix-project/lix
* Make this test a bit more robust. It's still timing dependent
though.
This commit is contained in:
parent
3a87163b24
commit
7aedcf9460
|
@ -2,7 +2,7 @@ echo "DOING $text"
|
||||||
|
|
||||||
|
|
||||||
# increase counter
|
# increase counter
|
||||||
while ! ln -s x $shared.lock; do
|
while ! ln -s x $shared.lock 2> /dev/null; do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
test -f $shared.cur || echo 0 > $shared.cur
|
test -f $shared.cur || echo 0 > $shared.cur
|
||||||
|
@ -17,11 +17,11 @@ rm $shared.lock
|
||||||
|
|
||||||
echo -n $(cat $inputs)$text > $out
|
echo -n $(cat $inputs)$text > $out
|
||||||
|
|
||||||
sleep 3
|
sleep $sleepTime
|
||||||
|
|
||||||
|
|
||||||
# decrease counter
|
# decrease counter
|
||||||
while ! ln -s x $shared.lock; do
|
while ! ln -s x $shared.lock 2> /dev/null; do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
test -f $shared.cur || echo 0 > $shared.cur
|
test -f $shared.cur || echo 0 > $shared.cur
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
{sleepTime ? 3}:
|
||||||
|
|
||||||
with import ./config.nix;
|
with import ./config.nix;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -5,7 +7,7 @@ let
|
||||||
mkDrv = text: inputs: mkDerivation {
|
mkDrv = text: inputs: mkDerivation {
|
||||||
name = "parallel";
|
name = "parallel";
|
||||||
builder = ./parallel.builder.sh;
|
builder = ./parallel.builder.sh;
|
||||||
inherit text inputs shared;
|
inherit text inputs shared sleepTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
a = mkDrv "a" [];
|
a = mkDrv "a" [];
|
||||||
|
|
|
@ -25,21 +25,23 @@ clearStore
|
||||||
|
|
||||||
rm -f $SHARED.cur $SHARED.max
|
rm -f $SHARED.cur $SHARED.max
|
||||||
|
|
||||||
$nixbuild -j1 parallel.nix &
|
cmd="$nixbuild -j1 parallel.nix --argstr sleepTime 7"
|
||||||
|
|
||||||
|
$cmd &
|
||||||
pid1=$!
|
pid1=$!
|
||||||
echo "pid 1 is $pid1"
|
echo "pid 1 is $pid1"
|
||||||
|
|
||||||
$nixbuild -j1 parallel.nix &
|
$cmd &
|
||||||
pid2=$!
|
pid2=$!
|
||||||
echo "pid 2 is $pid2"
|
echo "pid 2 is $pid2"
|
||||||
|
|
||||||
$nixbuild -j1 parallel.nix &
|
$cmd &
|
||||||
pid3=$!
|
pid3=$!
|
||||||
echo "pid 3 is $pid3"
|
echo "pid 3 is $pid3"
|
||||||
|
|
||||||
wait $pid1
|
wait $pid1 || fail "instance 1 failed: $?"
|
||||||
wait $pid2
|
wait $pid2 || fail "instance 2 failed: $?"
|
||||||
wait $pid3
|
wait $pid3 || fail "instance 3 failed: $?"
|
||||||
|
|
||||||
if test "$(cat $SHARED.cur)" != 0; then fail "wrong current process count"; fi
|
if test "$(cat $SHARED.cur)" != 0; then fail "wrong current process count"; fi
|
||||||
if test "$(cat $SHARED.max)" != 3; then fail "not enough parallelism"; fi
|
if test "$(cat $SHARED.max)" != 3; then fail "not enough parallelism"; fi
|
||||||
|
|
Loading…
Reference in a new issue