···194194 test_zstd_level 9 # High compression
195195}
196196197197+# Test lz4 compression
198198+test_lz4() {
199199+ tmpdir
200200+ echo "Testing lz4 in $PWD"
201201+ echo "Creating random data"
202202+ random_file 1000000 file
203203+ echo "Compressing with lz4 and cmprss"
204204+ lz4 -c file >lz4_file.lz4
205205+ cmprss lz4 file cmprss_file.lz4 --progress=off
206206+ # Compare the two archives
207207+ # The archives may have slight variations (versioning or whatever) so we
208208+ # only compare the sizes to make sure they are similar
209209+ compare_size lz4_file.lz4 cmprss_file.lz4
210210+ # Decompress the 4 variations
211211+ echo "Decompressing"
212212+ lz4 -d -c lz4_file.lz4 >lz4_lz4
213213+ lz4 -d -c cmprss_file.lz4 >cmprss_lz4
214214+ cmprss lz4 --extract cmprss_file.lz4 cmprss_cmprss --progress=off
215215+ cmprss lz4 --extract lz4_file.lz4 lz4_cmprss --progress=off
216216+ echo "Comparing the decompressed files"
217217+ compare file lz4_lz4
218218+ compare file lz4_cmprss
219219+ compare file cmprss_cmprss
220220+ compare file cmprss_lz4
221221+ echo "No errors detected"
222222+}
223223+197224# Run all the tests if no arguments are given
198225if [ $# -eq 0 ]; then
199199- set -- gzip xz bzip2 zstd
226226+ set -- gzip xz bzip2 zstd lz4
200227fi
201228202229# Run the tests given on the command line