libdeflate 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/test.yml +34 -0
  3. data/README.md +1 -6
  4. data/ext/libdeflate/extconf.rb +18 -7
  5. data/ext/libdeflate/libdeflate_ext.c +17 -17
  6. data/lib/libdeflate/version.rb +1 -1
  7. data/libdeflate.gemspec +2 -1
  8. metadata +13 -84
  9. data/.gitmodules +0 -3
  10. data/.travis.yml +0 -5
  11. data/ext/libdeflate/libdeflate/.gitignore +0 -19
  12. data/ext/libdeflate/libdeflate/COPYING +0 -21
  13. data/ext/libdeflate/libdeflate/Makefile +0 -231
  14. data/ext/libdeflate/libdeflate/Makefile.msc +0 -64
  15. data/ext/libdeflate/libdeflate/NEWS +0 -57
  16. data/ext/libdeflate/libdeflate/README.md +0 -170
  17. data/ext/libdeflate/libdeflate/common/common_defs.h +0 -351
  18. data/ext/libdeflate/libdeflate/common/compiler_gcc.h +0 -134
  19. data/ext/libdeflate/libdeflate/common/compiler_msc.h +0 -95
  20. data/ext/libdeflate/libdeflate/lib/adler32.c +0 -213
  21. data/ext/libdeflate/libdeflate/lib/adler32_impl.h +0 -281
  22. data/ext/libdeflate/libdeflate/lib/aligned_malloc.c +0 -57
  23. data/ext/libdeflate/libdeflate/lib/aligned_malloc.h +0 -13
  24. data/ext/libdeflate/libdeflate/lib/bt_matchfinder.h +0 -357
  25. data/ext/libdeflate/libdeflate/lib/crc32.c +0 -368
  26. data/ext/libdeflate/libdeflate/lib/crc32_impl.h +0 -286
  27. data/ext/libdeflate/libdeflate/lib/crc32_table.h +0 -526
  28. data/ext/libdeflate/libdeflate/lib/decompress_impl.h +0 -404
  29. data/ext/libdeflate/libdeflate/lib/deflate_compress.c +0 -2817
  30. data/ext/libdeflate/libdeflate/lib/deflate_compress.h +0 -14
  31. data/ext/libdeflate/libdeflate/lib/deflate_constants.h +0 -66
  32. data/ext/libdeflate/libdeflate/lib/deflate_decompress.c +0 -889
  33. data/ext/libdeflate/libdeflate/lib/gzip_compress.c +0 -95
  34. data/ext/libdeflate/libdeflate/lib/gzip_constants.h +0 -45
  35. data/ext/libdeflate/libdeflate/lib/gzip_decompress.c +0 -130
  36. data/ext/libdeflate/libdeflate/lib/hc_matchfinder.h +0 -405
  37. data/ext/libdeflate/libdeflate/lib/lib_common.h +0 -35
  38. data/ext/libdeflate/libdeflate/lib/matchfinder_avx2.h +0 -53
  39. data/ext/libdeflate/libdeflate/lib/matchfinder_common.h +0 -205
  40. data/ext/libdeflate/libdeflate/lib/matchfinder_neon.h +0 -61
  41. data/ext/libdeflate/libdeflate/lib/matchfinder_sse2.h +0 -53
  42. data/ext/libdeflate/libdeflate/lib/unaligned.h +0 -202
  43. data/ext/libdeflate/libdeflate/lib/x86_cpu_features.c +0 -169
  44. data/ext/libdeflate/libdeflate/lib/x86_cpu_features.h +0 -48
  45. data/ext/libdeflate/libdeflate/lib/zlib_compress.c +0 -87
  46. data/ext/libdeflate/libdeflate/lib/zlib_constants.h +0 -21
  47. data/ext/libdeflate/libdeflate/lib/zlib_decompress.c +0 -91
  48. data/ext/libdeflate/libdeflate/libdeflate.h +0 -274
  49. data/ext/libdeflate/libdeflate/programs/benchmark.c +0 -558
  50. data/ext/libdeflate/libdeflate/programs/checksum.c +0 -197
  51. data/ext/libdeflate/libdeflate/programs/detect.sh +0 -62
  52. data/ext/libdeflate/libdeflate/programs/gzip.c +0 -603
  53. data/ext/libdeflate/libdeflate/programs/prog_util.c +0 -530
  54. data/ext/libdeflate/libdeflate/programs/prog_util.h +0 -162
  55. data/ext/libdeflate/libdeflate/programs/test_checksums.c +0 -135
  56. data/ext/libdeflate/libdeflate/programs/tgetopt.c +0 -118
  57. data/ext/libdeflate/libdeflate/tools/afl-fuzz/Makefile +0 -12
  58. data/ext/libdeflate/libdeflate/tools/afl-fuzz/deflate_compress/fuzz.c +0 -40
  59. data/ext/libdeflate/libdeflate/tools/afl-fuzz/deflate_compress/inputs/0 +0 -0
  60. data/ext/libdeflate/libdeflate/tools/afl-fuzz/deflate_decompress/fuzz.c +0 -28
  61. data/ext/libdeflate/libdeflate/tools/afl-fuzz/deflate_decompress/inputs/0 +0 -3
  62. data/ext/libdeflate/libdeflate/tools/afl-fuzz/gzip_decompress/fuzz.c +0 -28
  63. data/ext/libdeflate/libdeflate/tools/afl-fuzz/gzip_decompress/inputs/0 +0 -0
  64. data/ext/libdeflate/libdeflate/tools/afl-fuzz/prepare_for_fuzz.sh +0 -14
  65. data/ext/libdeflate/libdeflate/tools/afl-fuzz/zlib_decompress/fuzz.c +0 -28
  66. data/ext/libdeflate/libdeflate/tools/afl-fuzz/zlib_decompress/inputs/0 +0 -3
  67. data/ext/libdeflate/libdeflate/tools/android_build.sh +0 -104
  68. data/ext/libdeflate/libdeflate/tools/checksum_benchmarks.sh +0 -76
  69. data/ext/libdeflate/libdeflate/tools/exec_tests.sh +0 -30
  70. data/ext/libdeflate/libdeflate/tools/gen_crc32_multipliers.c +0 -108
  71. data/ext/libdeflate/libdeflate/tools/gen_crc32_table.c +0 -100
  72. data/ext/libdeflate/libdeflate/tools/gzip_tests.sh +0 -412
  73. data/ext/libdeflate/libdeflate/tools/make-windows-releases +0 -21
  74. data/ext/libdeflate/libdeflate/tools/mips_build.sh +0 -9
  75. data/ext/libdeflate/libdeflate/tools/msc_test.bat +0 -3
  76. data/ext/libdeflate/libdeflate/tools/pgo_build.sh +0 -23
  77. data/ext/libdeflate/libdeflate/tools/produce_gzip_benchmark_table.sh +0 -37
  78. data/ext/libdeflate/libdeflate/tools/run_tests.sh +0 -305
  79. data/ext/libdeflate/libdeflate/tools/windows_build.sh +0 -10
@@ -1,108 +0,0 @@
1
- /*
2
- * gen_crc32_multipliers.c
3
- *
4
- * Copyright 2016 Eric Biggers
5
- *
6
- * Permission is hereby granted, free of charge, to any person
7
- * obtaining a copy of this software and associated documentation
8
- * files (the "Software"), to deal in the Software without
9
- * restriction, including without limitation the rights to use,
10
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the
12
- * Software is furnished to do so, subject to the following
13
- * conditions:
14
- *
15
- * The above copyright notice and this permission notice shall be
16
- * included in all copies or substantial portions of the Software.
17
- *
18
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
- * OTHER DEALINGS IN THE SOFTWARE.
26
- */
27
-
28
- #include <inttypes.h>
29
- #include <stdio.h>
30
-
31
- /* generator polynomial G(x) */
32
- #define CRCPOLY 0xEDB88320 /* G(x) without x^32 term */
33
- #define CRCPOLY_FULL (((uint64_t)CRCPOLY << 1) | 1) /* G(x) */
34
-
35
- /* Compute x^D mod G(x) */
36
- static uint32_t
37
- compute_multiplier(int D)
38
- {
39
- /* Start with x^0 mod G(x) */
40
- uint32_t remainder = 0x80000000;
41
-
42
- /* Each iteration, 'remainder' becomes x^i mod G(x) */
43
- for (int i = 1; i <= D; i++)
44
- remainder = (remainder >> 1) ^ ((remainder & 1) ? CRCPOLY : 0);
45
-
46
- /* Now 'remainder' is x^D mod G(x) */
47
- return remainder;
48
- }
49
-
50
- /* Compute floor(x^64 / G(x)) */
51
- static uint64_t
52
- compute_barrett_reduction_constant(void)
53
- {
54
- uint64_t quotient = 0;
55
- uint64_t dividend = 0x1;
56
-
57
- for (int i = 0; i < 64 - 32 + 1; i++) {
58
- if ((dividend >> i) & 1) {
59
- quotient |= (uint64_t)1 << i;
60
- dividend ^= CRCPOLY_FULL << i;
61
- }
62
- }
63
-
64
- return quotient;
65
- }
66
-
67
- /*
68
- * This program computes the constant multipliers needed for carryless
69
- * multiplication accelerated CRC-32. It assumes 128-bit vectors divided into
70
- * two 64-bit halves which are multiplied separately with different 32-bit
71
- * multipliers, producing two 95-bit products. For a given number of 128-bit
72
- * vectors per iteration, the program outputs a pair of multipliers, one for
73
- * each 64-bit half.
74
- *
75
- * Careful: all polynomials are "bit-reversed", meaning that the low-order bits
76
- * have the highest degree and the high-order bits have the lowest degree!
77
- */
78
- int
79
- main(void)
80
- {
81
- printf("\t/* Constants precomputed by gen_crc32_multipliers.c. "
82
- "Do not edit! */\n");
83
-
84
- /* High and low multipliers for each needed vector count */
85
- for (int order = 2; order >= 0; order--) {
86
- int vecs_per_iteration = 1 << order;
87
- int right = (128 * vecs_per_iteration) + 95;
88
- printf("\tconst __v2di multipliers_%d = (__v2di)"
89
- "{ 0x%08"PRIX32", 0x%08"PRIX32" };\n",
90
- vecs_per_iteration,
91
- compute_multiplier(right - 64) /* higher degree half */,
92
- compute_multiplier(right - 128) /* lower degree half */);
93
- }
94
-
95
- /* Multiplier for final 96 => 64 bit fold */
96
- printf("\tconst __v2di final_multiplier = (__v2di){ 0x%08"PRIX32" };\n",
97
- compute_multiplier(63));
98
-
99
- /* 32-bit mask */
100
- printf("\tconst __m128i mask32 = (__m128i)(__v4si){ 0xFFFFFFFF };\n");
101
-
102
- /* Constants for final 64 => 32 bit reduction */
103
- printf("\tconst __v2di barrett_reduction_constants =\n"
104
- "\t\t\t(__v2di){ 0x%016"PRIX64", 0x%016"PRIX64" };\n",
105
- compute_barrett_reduction_constant(), CRCPOLY_FULL);
106
-
107
- return 0;
108
- }
@@ -1,100 +0,0 @@
1
- /*
2
- * gen_crc32_table.c - a program for CRC-32 table generation
3
- *
4
- * Originally public domain; changes after 2016-09-07 are copyrighted.
5
- *
6
- * Copyright 2016 Eric Biggers
7
- *
8
- * Permission is hereby granted, free of charge, to any person
9
- * obtaining a copy of this software and associated documentation
10
- * files (the "Software"), to deal in the Software without
11
- * restriction, including without limitation the rights to use,
12
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
13
- * copies of the Software, and to permit persons to whom the
14
- * Software is furnished to do so, subject to the following
15
- * conditions:
16
- *
17
- * The above copyright notice and this permission notice shall be
18
- * included in all copies or substantial portions of the Software.
19
- *
20
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
- * OTHER DEALINGS IN THE SOFTWARE.
28
- */
29
-
30
- #include <stdint.h>
31
- #include <stdio.h>
32
-
33
- static uint32_t crc32_table[0x800];
34
-
35
- static uint32_t
36
- crc32_update_bit(uint32_t remainder, uint8_t next_bit)
37
- {
38
- return (remainder >> 1) ^
39
- (((remainder ^ next_bit) & 1) ? 0xEDB88320 : 0);
40
- }
41
-
42
- static uint32_t
43
- crc32_update_byte(uint32_t remainder, uint8_t next_byte)
44
- {
45
- for (int j = 0; j < 8; j++, next_byte >>= 1)
46
- remainder = crc32_update_bit(remainder, next_byte & 1);
47
- return remainder;
48
- }
49
-
50
- static void
51
- print_256_entries(const uint32_t *entries)
52
- {
53
- for (size_t i = 0; i < 256 / 4; i++) {
54
- printf("\t");
55
- for (size_t j = 0; j < 4; j++) {
56
- printf("0x%08x,", entries[i * 4 + j]);
57
- if (j != 3)
58
- printf(" ");
59
- }
60
- printf("\n");
61
- }
62
- }
63
-
64
- int
65
- main(void)
66
- {
67
- /* crc32_table[i] for 0 <= i < 0x100 is the CRC-32 of byte i. */
68
- for (int i = 0; i < 0x100; i++)
69
- crc32_table[i] = crc32_update_byte(0, i);
70
-
71
- /* crc32_table[i] for 0x100 <= i < 0x800 is the CRC-32 of byte i % 0x100
72
- * followed by i / 0x100 zero bytes. */
73
- for (int i = 0x100; i < 0x800; i++)
74
- crc32_table[i] = crc32_update_byte(crc32_table[i - 0x100], 0);
75
-
76
- printf("/*\n");
77
- printf(" * crc32_table.h - data table to accelerate CRC-32 computation\n");
78
- printf(" *\n");
79
- printf(" * THIS FILE WAS AUTOMATICALLY GENERATED "
80
- "BY gen_crc32_table.c. DO NOT EDIT.\n");
81
- printf(" */\n");
82
- printf("\n");
83
- printf("#include <stdint.h>\n");
84
- printf("\n");
85
- printf("static const uint32_t crc32_table[] = {\n");
86
- print_256_entries(&crc32_table[0x000]);
87
- printf("#if defined(CRC32_SLICE4) || defined(CRC32_SLICE8)\n");
88
- print_256_entries(&crc32_table[0x100]);
89
- print_256_entries(&crc32_table[0x200]);
90
- print_256_entries(&crc32_table[0x300]);
91
- printf("#endif /* CRC32_SLICE4 || CRC32_SLICE8 */\n");
92
- printf("#if defined(CRC32_SLICE8)\n");
93
- print_256_entries(&crc32_table[0x400]);
94
- print_256_entries(&crc32_table[0x500]);
95
- print_256_entries(&crc32_table[0x600]);
96
- print_256_entries(&crc32_table[0x700]);
97
- printf("#endif /* CRC32_SLICE8 */\n");
98
- printf("};\n");
99
- return 0;
100
- }
@@ -1,412 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Test script for libdeflate's gzip and gunzip programs.
4
- #
5
- # To run, you must set GZIP and GUNZIP in the environment to the absolute paths
6
- # to the gzip and gunzip programs to test. All tests should pass regardless of
7
- # whether the GNU versions or the libdeflate versions, or a combination, of
8
- # these programs are used.
9
- #
10
- # The environmental variable SMOKEDATA must also be set to a file containing
11
- # test data.
12
- #
13
-
14
- set -eu -o pipefail
15
-
16
- export -n GZIP GUNZIP SMOKEDATA
17
-
18
- TMPDIR="$(mktemp -d)"
19
- CURRENT_TEST=
20
-
21
- cleanup() {
22
- if [ -n "$CURRENT_TEST" ]; then
23
- echo "TEST FAILED: \"$CURRENT_TEST\""
24
- fi
25
- rm -rf -- "$TMPDIR"
26
- }
27
-
28
- trap cleanup EXIT
29
-
30
- SMOKEDATA="$(realpath "$SMOKEDATA")"
31
- cd "$TMPDIR"
32
-
33
- begin_test() {
34
- CURRENT_TEST="$1"
35
- rm -rf -- "$TMPDIR"/*
36
- cp "$SMOKEDATA" file
37
- }
38
-
39
- gzip() {
40
- $GZIP "$@"
41
- }
42
-
43
- gunzip() {
44
- $GUNZIP "$@"
45
- }
46
-
47
- assert_status() {
48
- local expected_status="$1"
49
- local expected_msg="$2"
50
- shift 2
51
- (
52
- set +e
53
- eval "$*" 2>&1 >/dev/null
54
- local actual_status=$?
55
- if [ $actual_status -ne $expected_status ]; then
56
- echo 1>&2 "Command '$*' exited with status" \
57
- "$actual_status but expected status" \
58
- "$expected_status"
59
- exit 1
60
- fi
61
- exit 0
62
- ) > command_output
63
- if ! egrep -q "$expected_msg" command_output; then
64
- echo 1>&2 "Expected output of command '$*' to match regex" \
65
- "'$expected_msg'"
66
- echo 1>&2 "Actual output was:"
67
- echo 1>&2 "---------------------------------------------------"
68
- cat 1>&2 command_output
69
- echo 1>&2 "---------------------------------------------------"
70
- return 1
71
- fi
72
- }
73
-
74
- assert_error() {
75
- assert_status 1 "$@"
76
- }
77
-
78
- assert_warning() {
79
- assert_status 2 "$@"
80
- }
81
-
82
- assert_skipped() {
83
- assert_warning '\<(ignored|skipping|unchanged)\>' "$@"
84
- }
85
-
86
-
87
- begin_test 'Basic compression and decompression works'
88
- cp file orig
89
- gzip file
90
- [ ! -e file -a -e file.gz ]
91
- gunzip file.gz
92
- [ -e file -a ! -e file.gz ]
93
- cmp file orig
94
-
95
-
96
- begin_test 'gzip -d is gunzip'
97
- cp file orig
98
- gzip file
99
- gzip -d file.gz
100
- cmp file orig
101
-
102
-
103
- begin_test '-k (keep original file) works'
104
- cp file orig
105
- gzip -k file
106
- cmp file orig
107
- rm file
108
- cp file.gz orig.gz
109
- gunzip -k file.gz
110
- cmp file.gz orig.gz
111
-
112
-
113
- begin_test '-c (write to stdout) works'
114
- cp file orig
115
- gzip -k file
116
- gzip -c file > 2.gz
117
- cmp file orig
118
- cmp file.gz 2.gz
119
- gunzip -c 2.gz > file
120
- cmp file.gz 2.gz
121
- cmp file orig
122
-
123
-
124
- begin_test 'Reading from stdin works'
125
- gzip < file > 1.gz
126
- gzip - < file > 2.gz
127
- cat file | gzip > 3.gz
128
- cat file | gzip - > 4.gz
129
- cmp file <(gunzip < 1.gz)
130
- cmp file <(gunzip - < 2.gz)
131
- cmp file <(cat 3.gz | gunzip)
132
- cmp file <(cat 4.gz | gunzip -)
133
-
134
-
135
- begin_test '-n option is accepted'
136
- gzip -n file
137
- gunzip -n file.gz
138
-
139
-
140
- begin_test 'can specify multiple options'
141
- gzip -fk1 file
142
- cmp <(gzip -c -1 file) file.gz
143
- gunzip -kfd file.gz
144
-
145
-
146
- begin_test 'Compression levels'
147
- if [ "$GZIP" = /usr/bin/gzip ]; then
148
- assert_error '\<invalid option\>' gzip -10
149
- max_level=9
150
- else
151
- for level in 13 99999 1a; do
152
- assert_error '\<Invalid compression level\>' gzip -$level
153
- done
154
- max_level=12
155
- fi
156
- for level in `seq 1 $max_level`; do
157
- gzip -c -$level file > file$level
158
- cmp file <(gunzip -c file$level)
159
- done
160
- rm file command_output
161
- cmp <(ls -S) <(ls -v) # file,file{1..max_level} have decreasing size
162
-
163
-
164
- begin_test 'Overwriting output file requires -f'
165
- cp file orig
166
- echo -n > file.gz
167
- gzip -c file > 2.gz
168
- assert_warning 'already exists' gzip file </dev/null
169
- cmp file.gz /dev/null
170
- gzip -f file
171
- cmp 2.gz file.gz
172
- echo -n > file
173
- assert_warning 'already exists' gunzip file.gz </dev/null
174
- gunzip -f file.gz
175
- cmp file orig
176
-
177
-
178
- begin_test 'Nonexistent input file fails, even with -f'
179
- for prog in 'gzip' 'gzip -f' 'gunzip' 'gunzip -f'; do
180
- assert_error 'No such file or directory' $prog NONEXISTENT
181
- done
182
-
183
-
184
- begin_test 'Compressing already-suffixed file requires -f or -c'
185
- gzip file
186
- gzip -c file.gz > c.gz
187
- gzip file.gz 2>&1 >/dev/null | grep -q 'already has .gz suffix'
188
- [ -e file.gz -a ! -e file.gz.gz ]
189
- gzip -f file.gz
190
- [ ! -e file.gz -a -e file.gz.gz ]
191
- cmp file.gz.gz c.gz
192
-
193
-
194
- begin_test 'Decompressing unsuffixed file only works with -c'
195
- gzip file && mv file.gz file
196
- assert_skipped gunzip file
197
- assert_skipped gunzip -f file
198
- gunzip -c file > orig
199
- mv file file.gz && gunzip file.gz && cmp file orig
200
-
201
-
202
- begin_test '... unless there is a corresponding suffixed file'
203
- cp file orig
204
- gzip file
205
- [ ! -e file -a -e file.gz ]
206
- gunzip -c file > tmp
207
- cmp tmp orig
208
- rm tmp
209
- ln -s NONEXISTENT file
210
- gunzip -c file > tmp
211
- cmp tmp orig
212
- rm tmp file
213
- gunzip file
214
- [ -e file -a ! -e file.gz ]
215
- cmp file orig
216
-
217
-
218
- begin_test 'Directory is skipped, even with -f'
219
- mkdir dir
220
- mkdir dir.gz
221
- for opt in '' '-f' '-c'; do
222
- assert_skipped gzip $opt dir
223
- done
224
- #assert_skipped gzip dir.gz # XXX: GNU gzip warns, libdeflate gzip no-ops
225
- for opt in '' '-f' '-c'; do
226
- for name in dir dir.gz; do
227
- assert_skipped gunzip $opt $name
228
- done
229
- done
230
-
231
-
232
- begin_test '(gzip) symlink is rejected without -f or -c'
233
- ln -s file symlink1
234
- ln -s file symlink2
235
- assert_error 'Too many levels of symbolic links' gzip symlink1
236
- [ -e file -a -e symlink1 -a ! -e symlink1.gz ]
237
- gzip -f symlink1
238
- [ -e file -a ! -e symlink1 -a -e symlink1.gz ]
239
- gzip -c symlink2 > /dev/null
240
-
241
-
242
- begin_test '(gunzip) symlink is rejected without -f or -c'
243
- gzip file
244
- ln -s file.gz symlink1.gz
245
- ln -s file.gz symlink2.gz
246
- assert_error 'Too many levels of symbolic links' gunzip symlink1
247
- [ -e file.gz -a -e symlink1.gz -a ! -e symlink1 ]
248
- gunzip -f symlink1.gz
249
- [ -e file.gz -a ! -e symlink1.gz -a -e symlink1 ]
250
- gunzip -c symlink2.gz > /dev/null
251
-
252
-
253
- begin_test 'FIFO is skipped, even with -f'
254
- mkfifo foo
255
- mkfifo foo.gz
256
- assert_skipped gzip foo
257
- assert_skipped gzip -f foo
258
- #assert_skipped gzip -c foo # XXX: works with GNU gzip, not libdeflate's
259
- assert_skipped gunzip foo.gz
260
- assert_skipped gunzip -f foo.gz
261
- #assert_skipped gunzip -c foo.gz # XXX: works with GNU gzip, not libdeflate's
262
-
263
-
264
- begin_test '(gzip) overwriting symlink does not follow symlink'
265
- echo 1 > 1
266
- echo 2 > 2
267
- gzip 1
268
- ln -s 1.gz 2.gz
269
- gzip -f 2
270
- gunzip 1.gz
271
- cmp <(echo 1) 1
272
-
273
-
274
- begin_test '(gunzip) overwriting symlink does not follow symlink'
275
- echo 1 > 1
276
- echo 2 > 2
277
- gzip 2
278
- ln -s 1 2
279
- gunzip -f 2.gz
280
- cmp <(echo 1) 1
281
- cmp <(echo 2) 2
282
-
283
-
284
- begin_test '(gzip) hard linked file skipped without -f or -c'
285
- cp file orig
286
- ln file link
287
- [ $(stat -c %h file) -eq 2 ]
288
- assert_skipped gzip file
289
- gzip -c file > /dev/null
290
- [ $(stat -c %h file) -eq 2 ]
291
- gzip -f file
292
- [ $(stat -c %h link) -eq 1 ]
293
- [ $(stat -c %h file.gz) -eq 1 ]
294
- cmp link orig
295
- # XXX: GNU gzip skips hard linked files with -k, libdeflate's doesn't
296
-
297
-
298
- begin_test '(gunzip) hard linked file skipped without -f or -c'
299
- gzip file
300
- ln file.gz link.gz
301
- cp file.gz orig.gz
302
- [ $(stat -c %h file.gz) -eq 2 ]
303
- assert_skipped gunzip file.gz
304
- gunzip -c file.gz > /dev/null
305
- [ $(stat -c %h file.gz) -eq 2 ]
306
- gunzip -f file
307
- [ $(stat -c %h link.gz) -eq 1 ]
308
- [ $(stat -c %h file) -eq 1 ]
309
- cmp link.gz orig.gz
310
-
311
-
312
- begin_test 'Multiple files'
313
- cp file file2
314
- gzip file file2
315
- [ ! -e file -a ! -e file2 -a -e file.gz -a -e file2.gz ]
316
- gunzip file.gz file2.gz
317
- [ -e file -a -e file2 -a ! -e file.gz -a ! -e file2.gz ]
318
-
319
-
320
- begin_test 'Multiple files, continue on warning'
321
- mkdir 1
322
- cp file 2
323
- assert_skipped gzip 1 2
324
- [ ! -e 1.gz ]
325
- cmp file <(gunzip -c 2.gz)
326
- rmdir 1
327
- mkdir 1.gz
328
- assert_skipped gunzip 1.gz 2.gz
329
- [ ! -e 1 ]
330
- cmp 2 file
331
-
332
-
333
- begin_test 'Multiple files, continue on error'
334
- cp file 1
335
- cp file 2
336
- chmod -r 1
337
- assert_error 'Permission denied' gzip 1 2
338
- [ ! -e 1.gz ]
339
- cmp file <(gunzip -c 2.gz)
340
- rm -f 1
341
- cp 2.gz 1.gz
342
- chmod -r 1.gz
343
- assert_error 'Permission denied' gunzip 1.gz 2.gz
344
- [ ! -e 1 ]
345
- cmp 2 file
346
-
347
-
348
- begin_test 'Compressing empty file'
349
- echo -n > empty
350
- gzip empty
351
- gunzip empty.gz
352
- cmp /dev/null empty
353
-
354
-
355
- begin_test 'Decompressing malformed file'
356
- echo -n > foo.gz
357
- assert_error '\<(not in gzip format|unexpected end of file)\>' \
358
- gunzip foo.gz
359
- echo 1 > foo.gz
360
- assert_error '\<not in gzip format\>' gunzip foo.gz
361
- echo abcdefgh > foo.gz
362
- assert_error '\<not in gzip format\>' gunzip foo.gz
363
- xxd -r > foo.gz <<-EOF
364
- 00000000: 1f8b 0800 0000 0000 00ff 4b4c 4a4e 4924 ..........KLJNI$
365
- 00000010: 1673 0100 6c5b a262 2e00 0000 .s..l[.b....
366
- EOF
367
- assert_error '\<(not in gzip format|crc error)\>' gunzip foo.gz
368
-
369
-
370
- for suf in .foo foo .blaaaaaaaaaaaaaaaargh; do
371
- begin_test "Custom suffix: $suf"
372
- gzip -S $suf file
373
- [ ! -e file -a ! -e file.gz -a -e file$suf ]
374
- assert_skipped gunzip file$suf
375
- gunzip -S $suf file$suf
376
- [ -e file -a ! -e file.gz -a ! -e file$suf ]
377
- done
378
- # DIFFERENCE: GNU gzip lower cases suffix, we don't
379
-
380
-
381
- begin_test 'Empty suffix is rejected'
382
- assert_error '\<invalid suffix\>' gzip -S '""' file
383
- assert_error '\<invalid suffix\>' gunzip -S '""' file
384
-
385
-
386
- begin_test 'Timestamps and mode are preserved'
387
- chmod 777 file
388
- orig_stat="$(stat -c '%a;%x;%y' file)"
389
- gzip file
390
- sleep 1
391
- gunzip file.gz
392
- [ "$(stat -c '%a;%x;%y' file)" = "$orig_stat" ]
393
-
394
-
395
- begin_test 'Help option'
396
- gzip -h 2>&1 | grep -q 'Usage'
397
- gunzip -h 2>&1 | grep -q 'Usage'
398
-
399
-
400
- begin_test 'Incorrect usage'
401
- for prog in gzip gunzip; do
402
- for opt in '--invalid-option' '-0'; do
403
- assert_error '\<(unrecognized|invalid) option\>' $prog $opt
404
- done
405
- done
406
-
407
-
408
- begin_test 'Version information'
409
- gzip -V | grep -q Copyright
410
- gunzip -V | grep -q Copyright
411
-
412
- CURRENT_TEST=
@@ -1,21 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -eu
4
-
5
- for arch in 'i686' 'x86_64'; do
6
- make clean
7
- make -j CC=${arch}-w64-mingw32-gcc CFLAGS="-Werror" all \
8
- benchmark.exe checksum.exe
9
- dir=libdeflate-$(git describe --tags | tr -d v)-windows-${arch}-bin
10
- rm -rf $dir ${dir}.zip
11
- mkdir $dir
12
- cp libdeflate.dll libdeflate.lib libdeflate.h *.exe $dir
13
- ${arch}-w64-mingw32-strip ${dir}/libdeflate.dll ${dir}/*.exe
14
- for file in COPYING NEWS; do
15
- sed < $file > ${dir}/${file}.txt -e 's/$/\r/g'
16
- done
17
- for file in README.md; do
18
- sed < $file > ${dir}/${file} -e 's/$/\r/g'
19
- done
20
- (cd ${dir} && zip -r ../${dir}.zip .)
21
- done
@@ -1,9 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -eu
4
-
5
- TOOLCHAIN_DIR=$HOME/src/ddwrt-toolchains/toolchain-mips_34kc_gcc-5.1.0_musl-1.1.9
6
-
7
- make -j$(grep -c processor /proc/cpuinfo) test_programs \
8
- CC="$TOOLCHAIN_DIR/bin/mips-openwrt-linux-musl-gcc" \
9
- CFLAGS="-DNEED_PRINTF -Werror"
@@ -1,3 +0,0 @@
1
- nmake /f Makefile.msc clean
2
- nmake /f Makefile.msc
3
- copy /y *.exe j:\exe\
@@ -1,23 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Try gcc profile-guided optimizations
4
-
5
- set -eu
6
-
7
- MAKE="make -j$(grep -c processor /proc/cpuinfo)"
8
- DATAFILE="$HOME/data/silesia"
9
-
10
- $MAKE benchmark > /dev/null
11
- echo "====================="
12
- echo "Original performance:"
13
- echo "---------------------"
14
- ./benchmark "$@" "$DATAFILE"
15
-
16
- $MAKE CFLAGS=-fprofile-generate LDFLAGS=-fprofile-generate benchmark > /dev/null
17
- ./benchmark "$@" "$DATAFILE" > /dev/null
18
- $MAKE CFLAGS=-fprofile-use benchmark > /dev/null
19
- rm -f {lib,programs}/*.gcda
20
- echo "=========================="
21
- echo "PGO-optimized performance:"
22
- echo "--------------------------"
23
- ./benchmark "$@" "$DATAFILE"