2019-08-02 17:07:33 +02:00
|
|
|
source common.sh
|
|
|
|
|
|
|
|
clearStore
|
|
|
|
|
2019-08-29 12:35:15 +02:00
|
|
|
garbage1=$(nix add-to-store --name garbage1 ./nar-access.sh)
|
|
|
|
garbage2=$(nix add-to-store --name garbage2 ./nar-access.sh)
|
|
|
|
garbage3=$(nix add-to-store --name garbage3 ./nar-access.sh)
|
2019-08-02 17:07:33 +02:00
|
|
|
|
2019-08-29 12:10:01 +02:00
|
|
|
ls -l $garbage3
|
2019-08-29 12:35:15 +02:00
|
|
|
POSIXLY_CORRECT=1 du $garbage3
|
2019-08-02 17:07:33 +02:00
|
|
|
|
|
|
|
fake_free=$TEST_ROOT/fake-free
|
|
|
|
export _NIX_TEST_FREE_SPACE_FILE=$fake_free
|
|
|
|
echo 1100 > $fake_free
|
|
|
|
|
|
|
|
expr=$(cat <<EOF
|
|
|
|
with import ./config.nix; mkDerivation {
|
|
|
|
name = "gc-A";
|
|
|
|
buildCommand = ''
|
2019-09-03 15:45:32 +02:00
|
|
|
set -x
|
2019-08-02 17:07:33 +02:00
|
|
|
[[ \$(ls \$NIX_STORE/*-garbage? | wc -l) = 3 ]]
|
|
|
|
mkdir \$out
|
|
|
|
echo foo > \$out/bar
|
|
|
|
echo 1...
|
|
|
|
sleep 2
|
2019-09-03 18:11:43 +02:00
|
|
|
echo 200 > ${fake_free}.tmp1
|
|
|
|
mv ${fake_free}.tmp1 $fake_free
|
2019-08-02 17:07:33 +02:00
|
|
|
echo 2...
|
|
|
|
sleep 2
|
|
|
|
echo 3...
|
2019-09-04 12:52:54 +02:00
|
|
|
sleep 2
|
2019-09-03 18:11:43 +02:00
|
|
|
echo 4...
|
2019-08-02 17:07:33 +02:00
|
|
|
[[ \$(ls \$NIX_STORE/*-garbage? | wc -l) = 1 ]]
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
|
|
|
expr2=$(cat <<EOF
|
|
|
|
with import ./config.nix; mkDerivation {
|
|
|
|
name = "gc-B";
|
|
|
|
buildCommand = ''
|
2019-09-03 15:45:32 +02:00
|
|
|
set -x
|
2019-08-02 17:07:33 +02:00
|
|
|
mkdir \$out
|
|
|
|
echo foo > \$out/bar
|
|
|
|
echo 1...
|
|
|
|
sleep 2
|
2019-09-03 18:11:43 +02:00
|
|
|
echo 200 > ${fake_free}.tmp2
|
|
|
|
mv ${fake_free}.tmp2 $fake_free
|
2019-08-02 17:07:33 +02:00
|
|
|
echo 2...
|
|
|
|
sleep 2
|
|
|
|
echo 3...
|
2019-09-04 12:52:54 +02:00
|
|
|
sleep 2
|
2019-09-03 18:11:43 +02:00
|
|
|
echo 4...
|
2019-08-02 17:07:33 +02:00
|
|
|
'';
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
2019-09-04 13:30:11 +02:00
|
|
|
nix build --impure -v -o $TEST_ROOT/result-A -L "($expr)" \
|
2019-09-03 15:45:32 +02:00
|
|
|
--min-free 1000 --max-free 2000 --min-free-check-interval 1 &
|
|
|
|
pid=$!
|
|
|
|
|
2019-08-29 16:11:38 +02:00
|
|
|
nix build --impure -v -o $TEST_ROOT/result-B -L "($expr2)" \
|
2019-08-02 17:07:33 +02:00
|
|
|
--min-free 1000 --max-free 2000 --min-free-check-interval 1
|
|
|
|
|
|
|
|
wait "$pid"
|
|
|
|
|
|
|
|
[[ foo = $(cat $TEST_ROOT/result-A/bar) ]]
|
|
|
|
[[ foo = $(cat $TEST_ROOT/result-B/bar) ]]
|