xref: /aosp_15_r20/external/zstd/tests/cli-tests/compression/levels.sh.stderr.exact (revision 01826a4963a0d8a59bc3812d29bdf0fb76416722)
1*01826a49SYabin Cui
2*01826a49SYabin Cuidatagen > file
3*01826a49SYabin Cui
4*01826a49SYabin Cui# Compress with various levels and ensure that their sizes are ordered
5*01826a49SYabin Cuizstd --fast=10 file -o file-f10.zst -q
6*01826a49SYabin Cuizstd --fast=1 file -o file-f1.zst -q
7*01826a49SYabin Cuizstd -1 file -o file-1.zst -q
8*01826a49SYabin Cuizstd -19 file -o file-19.zst -q
9*01826a49SYabin Cui
10*01826a49SYabin Cuizstd -t file-f10.zst file-f1.zst file-1.zst file-19.zst
11*01826a49SYabin Cui4 files decompressed : 262148 bytes total
12*01826a49SYabin Cui
13*01826a49SYabin Cuicmp_size -lt file-19.zst file-1.zst
14*01826a49SYabin Cuicmp_size -lt file-1.zst file-f1.zst
15*01826a49SYabin Cuicmp_size -lt file-f1.zst file-f10.zst
16*01826a49SYabin Cui
17*01826a49SYabin Cui# Test default levels
18*01826a49SYabin Cuizstd --fast file -f -q
19*01826a49SYabin Cuicmp file.zst file-f1.zst || die "--fast is not level -1"
20*01826a49SYabin Cui
21*01826a49SYabin Cuizstd -0 file -o file-0.zst -q
22*01826a49SYabin Cuizstd -f file -q
23*01826a49SYabin Cuicmp file.zst file-0.zst || die "Level 0 is not the default level"
24*01826a49SYabin Cui
25*01826a49SYabin Cui# Test level clamping
26*01826a49SYabin Cuizstd -99 file -o file-99.zst -q
27*01826a49SYabin Cuicmp file-19.zst file-99.zst || die "Level 99 is clamped to 19"
28*01826a49SYabin Cuizstd --fast=200000 file -c | zstd -t
29*01826a49SYabin Cui/*stdin*\           : 65537 bytes
30*01826a49SYabin Cui
31*01826a49SYabin Cuizstd -5000000000 -f file       && die "Level too large, must fail" ||:
32*01826a49SYabin Cuierror: numeric value overflows 32-bit unsigned int
33*01826a49SYabin Cuizstd --fast=5000000000 -f file && die "Level too large, must fail" ||:
34*01826a49SYabin Cuierror: numeric value overflows 32-bit unsigned int
35*01826a49SYabin Cui
36*01826a49SYabin Cui# Test setting a level through the environment variable
37*01826a49SYabin CuiZSTD_CLEVEL=-10 zstd file -o file-f10-env.zst -q
38*01826a49SYabin CuiZSTD_CLEVEL=1 zstd file -o file-1-env.zst -q
39*01826a49SYabin CuiZSTD_CLEVEL=+19 zstd file -o file-19-env.zst -q
40*01826a49SYabin CuiZSTD_CLEVEL=+99 zstd file -o file-99-env.zst -q
41*01826a49SYabin Cui
42*01826a49SYabin Cuicmp file-f10.zst file-f10-env.zst || die "Environment variable failed to set level"
43*01826a49SYabin Cuicmp file-1.zst file-1-env.zst || die "Environment variable failed to set level"
44*01826a49SYabin Cuicmp file-19.zst file-19-env.zst || die "Environment variable failed to set level"
45*01826a49SYabin Cuicmp file-99.zst file-99-env.zst || die "Environment variable failed to set level"
46*01826a49SYabin Cui
47*01826a49SYabin Cui# Test invalid environment clevel is the default level
48*01826a49SYabin Cuizstd -f file -q
49*01826a49SYabin CuiZSTD_CLEVEL=- zstd -f file -o file-env.zst -q      ; cmp file.zst file-env.zst
50*01826a49SYabin CuiIgnore environment variable setting ZSTD_CLEVEL=-: not a valid integer value
51*01826a49SYabin CuiZSTD_CLEVEL=+ zstd -f file -o file-env.zst -q      ; cmp file.zst file-env.zst
52*01826a49SYabin CuiIgnore environment variable setting ZSTD_CLEVEL=+: not a valid integer value
53*01826a49SYabin CuiZSTD_CLEVEL=a zstd -f file -o file-env.zst -q      ; cmp file.zst file-env.zst
54*01826a49SYabin CuiIgnore environment variable setting ZSTD_CLEVEL=a: not a valid integer value
55*01826a49SYabin CuiZSTD_CLEVEL=-a zstd -f file -o file-env.zst -q     ; cmp file.zst file-env.zst
56*01826a49SYabin CuiIgnore environment variable setting ZSTD_CLEVEL=-a: not a valid integer value
57*01826a49SYabin CuiZSTD_CLEVEL=+a zstd -f file -o file-env.zst -q     ; cmp file.zst file-env.zst
58*01826a49SYabin CuiIgnore environment variable setting ZSTD_CLEVEL=+a: not a valid integer value
59*01826a49SYabin CuiZSTD_CLEVEL=3a7 zstd -f file -o file-env.zst -q    ; cmp file.zst file-env.zst
60*01826a49SYabin CuiIgnore environment variable setting ZSTD_CLEVEL=3a7: not a valid integer value
61*01826a49SYabin CuiZSTD_CLEVEL=5000000000 zstd -f file -o file-env.zst -q ; cmp file.zst file-env.zst
62*01826a49SYabin CuiIgnore environment variable setting ZSTD_CLEVEL=5000000000: numeric value too large
63*01826a49SYabin Cui
64*01826a49SYabin Cui# Test environment clevel is overridden by command line
65*01826a49SYabin CuiZSTD_CLEVEL=10 zstd -f file -1 -o file-1-env.zst -q
66*01826a49SYabin CuiZSTD_CLEVEL=10 zstd -f file --fast=1 -o file-f1-env.zst -q
67*01826a49SYabin Cui
68*01826a49SYabin Cuicmp file-1.zst file-1-env.zst  || die "Environment variable not overridden"
69*01826a49SYabin Cuicmp file-f1.zst file-f1-env.zst || die "Environment variable not overridden"
70