diff options
Diffstat (limited to 'tests/binary-cache.sh')
-rw-r--r-- | tests/binary-cache.sh | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/tests/binary-cache.sh b/tests/binary-cache.sh index c72d2defa5d0..48bc62d311de 100644 --- a/tests/binary-cache.sh +++ b/tests/binary-cache.sh @@ -1,7 +1,6 @@ source common.sh clearStore -clearManifests clearCache # Create the binary cache. @@ -13,7 +12,7 @@ nix-push --dest $cacheDir $outPath # By default, a binary cache doesn't support "nix-env -qas", but does # support installation. clearStore -rm -f $NIX_STATE_DIR/binary-cache* +clearCacheCache export _NIX_CACHE_FILE_URLS=1 @@ -26,7 +25,7 @@ nix-store --option binary-caches "file://$cacheDir" -r $outPath # But with the right configuration, "nix-env -qas" should also work. clearStore -rm -f $NIX_STATE_DIR/binary-cache* +clearCacheCache echo "WantMassQuery: 1" >> $cacheDir/nix-cache-info nix-env --option binary-caches "file://$cacheDir" -f dependencies.nix -qas \* | grep -- "--S" @@ -49,15 +48,14 @@ mkdir -p $TEST_ROOT/empty nix-store --dump $TEST_ROOT/empty | xz > $nar nix-build --option binary-caches "file://$cacheDir" dependencies.nix -o $TEST_ROOT/result 2>&1 | tee $TEST_ROOT/log -grep -q "hash mismatch in downloaded path" $TEST_ROOT/log +grep -q "hash mismatch" $TEST_ROOT/log mv $nar.good $nar # Test whether this unsigned cache is rejected if the user requires signed caches. clearStore - -rm -f $NIX_STATE_DIR/binary-cache* +clearCacheCache if nix-store --option binary-caches "file://$cacheDir" --option signed-binary-caches '*' -r $outPath; then echo "unsigned binary cache incorrectly accepted" @@ -86,7 +84,7 @@ clearStore rm $(grep -l "StorePath:.*dependencies-input-2" $cacheDir/*.narinfo) nix-build --option binary-caches "file://$cacheDir" dependencies.nix -o $TEST_ROOT/result 2>&1 | tee $TEST_ROOT/log -grep -q "Downloading" $TEST_ROOT/log +grep -q "fetching path" $TEST_ROOT/log if [ -n "$HAVE_SODIUM" ]; then @@ -108,16 +106,14 @@ nix-push --dest $cacheDir --key-file $TEST_ROOT/sk1 $outPath # Downloading should fail if we don't provide a key. clearStore - -rm -f $NIX_STATE_DIR/binary-cache* +clearCacheCache (! nix-store -r $outPath --option binary-caches "file://$cacheDir" --option signed-binary-caches '*' ) # And it should fail if we provide an incorrect key. clearStore - -rm -f $NIX_STATE_DIR/binary-cache* +clearCacheCache (! nix-store -r $outPath --option binary-caches "file://$cacheDir" --option signed-binary-caches '*' --option binary-cache-public-keys "$badKey") @@ -129,13 +125,21 @@ nix-store -r $outPath --option binary-caches "file://$cacheDir" --option signed- # It should fail if we corrupt the .narinfo. clearStore -for i in $cacheDir/*.narinfo; do +cacheDir2=$TEST_ROOT/binary-cache-2 +rm -rf $cacheDir2 +cp -r $cacheDir $cacheDir2 + +for i in $cacheDir2/*.narinfo; do grep -v References $i > $i.tmp mv $i.tmp $i done -rm -f $NIX_STATE_DIR/binary-cache* +clearCacheCache + +(! nix-store -r $outPath --option binary-caches "file://$cacheDir2" --option signed-binary-caches '*' --option binary-cache-public-keys "$publicKey") + +# If we provide a bad and a good binary cache, it should succeed. -(! nix-store -r $outPath --option binary-caches "file://$cacheDir" --option signed-binary-caches '*' --option binary-cache-public-keys "$publicKey") +nix-store -r $outPath --option binary-caches "file://$cacheDir2 file://$cacheDir" --option signed-binary-caches '*' --option binary-cache-public-keys "$publicKey" fi # HAVE_LIBSODIUM |