From c2dfda007e777a33cd487a5631f0d143f915dd43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Fri, 9 Apr 2021 23:13:08 +0200 Subject: [PATCH] add tests for zstd compression --- src/libstore/binary-cache-store.cc | 3 +++ tests/local.mk | 1 + tests/zstd.sh | 28 ++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 tests/zstd.sh diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index 4f5f8607d1e..09e1c254bd4 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -179,6 +179,9 @@ ref BinaryCacheStore::addToStoreCommon( narInfo->url = "nar/" + narInfo->fileHash->to_string(Base32, false) + ".nar" + (compression == "xz" ? ".xz" : compression == "bzip2" ? ".bz2" : + compression == "zstd" ? ".zst" : + compression == "lzip" ? ".lzip" : + compression == "lz4" ? ".lz4" : compression == "br" ? ".br" : ""); diff --git a/tests/local.mk b/tests/local.mk index aa8b4f9bf91..82894af7892 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -27,6 +27,7 @@ nix_tests = \ signing.sh \ shell.sh \ brotli.sh \ + zstd.sh \ pure-eval.sh \ check.sh \ plugins.sh \ diff --git a/tests/zstd.sh b/tests/zstd.sh new file mode 100644 index 00000000000..ba7c20501fe --- /dev/null +++ b/tests/zstd.sh @@ -0,0 +1,28 @@ +source common.sh + +clearStore +clearCache + +cacheURI="file://$cacheDir?compression=zstd" + +outPath=$(nix-build dependencies.nix --no-out-link) + +nix copy --to $cacheURI $outPath + +HASH=$(nix hash path $outPath) + +clearStore +clearCacheCache + +nix copy --from $cacheURI $outPath --no-check-sigs + +if ls $cacheDir/nar/*.zst &> /dev/null; then + echo "files do exist" +else + echo "nars do not exist" + exit 1 +fi + +HASH2=$(nix hash path $outPath) + +[[ $HASH = $HASH2 ]]