1 2datagen > file 3 4# Retrieve the program's version information 5# Note: command echoing differs between macos and linux, so it's disabled below 6set +v 7 8# Compress with various levels and ensure that their sizes are ordered 9zstd --fast=10 file -o file-f10.zst -q 10zstd --fast=1 file -o file-f1.zst -q 11zstd -1 file -o file-1.zst -q 12zstd -19 file -o file-19.zst -q 13if echo "$version_info" | grep -q '32-bit'; then 14 # skip --max test: not enough address space 15 cp file-19.zst file-max.zst 16else 17 zstd --max file -o file-max.zst -q 18fi 19 20zstd -t file-f10.zst file-f1.zst file-1.zst file-19.zst file-max.zst 215 files decompressed : 327685 bytes total 22 23cmp_size -le file-max.zst file-19.zst 24cmp_size -lt file-19.zst file-1.zst 25cmp_size -lt file-1.zst file-f1.zst 26cmp_size -lt file-f1.zst file-f10.zst 27 28# Test default levels 29zstd --fast file -f -q 30cmp file.zst file-f1.zst || die "--fast is not level -1" 31 32zstd -0 file -o file-0.zst -q 33zstd -f file -q 34cmp file.zst file-0.zst || die "Level 0 is not the default level" 35 36# Test level clamping 37zstd -99 file -o file-99.zst -q 38cmp file-19.zst file-99.zst || die "Level 99 is clamped to 19" 39zstd --fast=200000 file -c | zstd -t 40/*stdin*\ : 65537 bytes 41 42zstd -5000000000 -f file && die "Level too large, must fail" ||: 43error: numeric value overflows 32-bit unsigned int 44zstd --fast=5000000000 -f file && die "Level too large, must fail" ||: 45error: numeric value overflows 32-bit unsigned int 46 47# Test setting a level through the environment variable 48ZSTD_CLEVEL=-10 zstd file -o file-f10-env.zst -q 49ZSTD_CLEVEL=1 zstd file -o file-1-env.zst -q 50ZSTD_CLEVEL=+19 zstd file -o file-19-env.zst -q 51ZSTD_CLEVEL=+99 zstd file -o file-99-env.zst -q 52 53cmp file-f10.zst file-f10-env.zst || die "Environment variable failed to set level" 54cmp file-1.zst file-1-env.zst || die "Environment variable failed to set level" 55cmp file-19.zst file-19-env.zst || die "Environment variable failed to set level" 56cmp file-99.zst file-99-env.zst || die "Environment variable failed to set level" 57 58# Test invalid environment clevel is the default level 59zstd -f file -q 60ZSTD_CLEVEL=- zstd -f file -o file-env.zst -q ; cmp file.zst file-env.zst 61Ignore environment variable setting ZSTD_CLEVEL=-: not a valid integer value 62ZSTD_CLEVEL=+ zstd -f file -o file-env.zst -q ; cmp file.zst file-env.zst 63Ignore environment variable setting ZSTD_CLEVEL=+: not a valid integer value 64ZSTD_CLEVEL=a zstd -f file -o file-env.zst -q ; cmp file.zst file-env.zst 65Ignore environment variable setting ZSTD_CLEVEL=a: not a valid integer value 66ZSTD_CLEVEL=-a zstd -f file -o file-env.zst -q ; cmp file.zst file-env.zst 67Ignore environment variable setting ZSTD_CLEVEL=-a: not a valid integer value 68ZSTD_CLEVEL=+a zstd -f file -o file-env.zst -q ; cmp file.zst file-env.zst 69Ignore environment variable setting ZSTD_CLEVEL=+a: not a valid integer value 70ZSTD_CLEVEL=3a7 zstd -f file -o file-env.zst -q ; cmp file.zst file-env.zst 71Ignore environment variable setting ZSTD_CLEVEL=3a7: not a valid integer value 72ZSTD_CLEVEL=5000000000 zstd -f file -o file-env.zst -q ; cmp file.zst file-env.zst 73Ignore environment variable setting ZSTD_CLEVEL=5000000000: numeric value too large 74 75# Test environment clevel is overridden by command line 76ZSTD_CLEVEL=10 zstd -f file -1 -o file-1-env.zst -q 77ZSTD_CLEVEL=10 zstd -f file --fast=1 -o file-f1-env.zst -q 78 79cmp file-1.zst file-1-env.zst || die "Environment variable not overridden" 80cmp file-f1.zst file-f1-env.zst || die "Environment variable not overridden" 81