libdeflate 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
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,37 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e
4
-
5
- do_benchmark() {
6
- usize=$(stat -c %s "$file")
7
- "$HOME/proj/libdeflate/benchmark" -g -s $usize "$@" "$file" \
8
- | grep Compressed | cut -f 4 -d ' '
9
- }
10
-
11
- echo "File | zlib -6 | zlib -9 | libdeflate -6 | libdeflate -9 | libdeflate -12"
12
- echo "-----|---------|---------|---------------|---------------|---------------"
13
-
14
- for file in "$@"; do
15
- echo -n "$(basename "$file")"
16
- results=()
17
- results+=($(do_benchmark -Y -6))
18
- results+=($(do_benchmark -Y -9))
19
- results+=($(do_benchmark -6))
20
- results+=($(do_benchmark -9))
21
- results+=($(do_benchmark -12))
22
- best=2000000000
23
- for result in "${results[@]}"; do
24
- if (( result < best)); then
25
- best=$result
26
- fi
27
- done
28
- for result in "${results[@]}"; do
29
- if (( result == best )); then
30
- em="**"
31
- else
32
- em=""
33
- fi
34
- echo -n " | ${em}${result}${em}"
35
- done
36
- echo
37
- done
@@ -1,305 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Test script for libdeflate
4
- #
5
- # Usage: ./tools/run_tests.sh [TESTGROUP]... [-TESTGROUP]...
6
- #
7
- # By default all tests are run, but it is possible to explicitly include or
8
- # exclude specific test groups.
9
- #
10
-
11
- set -eu -o pipefail
12
- cd "$(dirname "$0")/.."
13
-
14
- TESTGROUPS=(all)
15
-
16
- set_test_groups() {
17
- TESTGROUPS=("$@")
18
- local have_exclusion=0
19
- local have_all=0
20
- for group in "${TESTGROUPS[@]}"; do
21
- if [[ $group == -* ]]; then
22
- have_exclusion=1
23
- elif [[ $group == all ]]; then
24
- have_all=1
25
- fi
26
- done
27
- if (( have_exclusion && !have_all )); then
28
- TESTGROUPS=(all "${TESTGROUPS[@]}")
29
- fi
30
- }
31
-
32
- if [ $# -gt 0 ]; then
33
- set_test_groups "$@"
34
- fi
35
-
36
- SMOKEDATA="${SMOKEDATA:=$HOME/data/smokedata}"
37
- if [ ! -e "$SMOKEDATA" ]; then
38
- echo "SMOKEDATA (value: $SMOKEDATA) does not exist. Set the" \
39
- "environmental variable SMOKEDATA to a file to use in" \
40
- "compression/decompression tests." 1>&2
41
- exit 1
42
- fi
43
-
44
- NDKDIR="${NDKDIR:=/opt/android-ndk}"
45
-
46
- FILES=("$SMOKEDATA" ./tools/exec_tests.sh benchmark test_checksums)
47
- EXEC_TESTS_CMD="WRAPPER= SMOKEDATA=\"$(basename $SMOKEDATA)\" sh exec_tests.sh"
48
- NPROC=$(grep -c processor /proc/cpuinfo)
49
- VALGRIND="valgrind --quiet --error-exitcode=100 --leak-check=full --errors-for-leak-kinds=all"
50
- SANITIZE_CFLAGS="-fsanitize=undefined -fno-sanitize-recover=undefined,integer"
51
-
52
- TMPFILE="$(mktemp)"
53
- trap "rm -f \"$TMPFILE\"" EXIT
54
-
55
- ###############################################################################
56
-
57
- rm -f run_tests.log
58
- exec > >(tee -ia run_tests.log)
59
- exec 2> >(tee -ia run_tests.log >&2)
60
-
61
- TESTS_SKIPPED=0
62
- log_skip() {
63
- log "[WARNING, TEST SKIPPED]: $@"
64
- TESTS_SKIPPED=1
65
- }
66
-
67
- log() {
68
- echo "[$(date)] $@"
69
- }
70
-
71
- run_cmd() {
72
- log "$@"
73
- "$@" > /dev/null
74
- }
75
-
76
- test_group_included() {
77
- local included=0 group
78
- for group in "${TESTGROUPS[@]}"; do
79
- if [ "$group" = "$1" ]; then
80
- included=1 # explicitly included
81
- break
82
- fi
83
- if [ "$group" = "-$1" ]; then
84
- included=0 # explicitly excluded
85
- break
86
- fi
87
- if [ "$group" = "all" ]; then # implicitly included
88
- included=1
89
- fi
90
- done
91
- if (( included )); then
92
- log "Starting test group: $1"
93
- fi
94
- (( included ))
95
- }
96
-
97
- ###############################################################################
98
-
99
- native_build_and_test() {
100
- make "$@" -j$NPROC all test_programs > /dev/null
101
- WRAPPER="$WRAPPER" SMOKEDATA="$SMOKEDATA" sh ./tools/exec_tests.sh \
102
- > /dev/null
103
- }
104
-
105
- native_tests() {
106
- test_group_included native || return 0
107
- local compiler cflags compilers=(gcc)
108
- shopt -s nullglob
109
- compilers+=(/usr/bin/gcc-[0-9]*)
110
- compilers+=(/usr/bin/clang-[0-9]*)
111
- compilers+=(/opt/gcc*/bin/gcc)
112
- compilers+=(/opt/clang*/bin/clang)
113
- shopt -u nullglob
114
- for compiler in ${compilers[@]}; do
115
- for cflags in "" "-march=native" "-m32"; do
116
- if [ "$compiler" = "/usr/bin/gcc-4.8" -a \
117
- "$cflags" = "-m32" ]; then
118
- continue
119
- fi
120
- log "Running tests with CC=$compiler," \
121
- "CFLAGS=$cflags"
122
- WRAPPER= native_build_and_test \
123
- CC=$compiler CFLAGS="$cflags -Werror"
124
- done
125
- done
126
-
127
- log "Running tests with Valgrind"
128
- WRAPPER="$VALGRIND" native_build_and_test
129
-
130
- log "Running tests with undefined behavior sanitizer"
131
- WRAPPER= native_build_and_test CC=clang CFLAGS="$SANITIZE_CFLAGS"
132
- }
133
-
134
- ###############################################################################
135
-
136
- android_build() {
137
- run_cmd ./tools/android_build.sh --ndkdir="$NDKDIR" "$@"
138
- }
139
-
140
- android_build_and_test() {
141
- android_build "$@"
142
- run_cmd adb push "${FILES[@]}" /data/local/tmp/
143
-
144
- # Note: adb shell always returns 0, even if the shell command fails...
145
- log "adb shell \"cd /data/local/tmp && $EXEC_TESTS_CMD\""
146
- adb shell "cd /data/local/tmp && $EXEC_TESTS_CMD" > "$TMPFILE"
147
- if ! grep -q "exec_tests finished successfully" "$TMPFILE"; then
148
- log "Android test failure! adb shell output:"
149
- cat "$TMPFILE"
150
- return 1
151
- fi
152
- }
153
-
154
- android_tests() {
155
- local compiler
156
-
157
- test_group_included android || return 0
158
- if [ ! -e $NDKDIR ]; then
159
- log_skip "Android NDK was not found in NDKDIR=$NDKDIR!" \
160
- "If you want to run the Android tests, set the" \
161
- "environmental variable NDKDIR to the location of" \
162
- "your Android NDK installation"
163
- return 0
164
- fi
165
-
166
- if ! type -P adb > /dev/null; then
167
- log_skip "adb (android-tools) is not installed"
168
- return 0
169
- fi
170
-
171
- if ! adb devices | grep -q 'device$'; then
172
- log_skip "No Android device is currently attached"
173
- return 0
174
- fi
175
-
176
- for compiler in gcc clang; do
177
- android_build_and_test --arch=arm --compiler=$compiler
178
-
179
- android_build_and_test --arch=arm --compiler=$compiler \
180
- --disable-neon
181
-
182
- # arm64: currently compiled but not run
183
- android_build --arch=arm64 --compiler=$compiler
184
- done
185
- }
186
-
187
- ###############################################################################
188
-
189
- mips_tests() {
190
- test_group_included mips || return 0
191
- if ! ping -c 1 dd-wrt > /dev/null; then
192
- log_skip "Can't run MIPS tests: dd-wrt system not available"
193
- return 0
194
- fi
195
- run_cmd ./tools/mips_build.sh
196
- run_cmd scp "${FILES[@]}" root@dd-wrt:
197
- run_cmd ssh root@dd-wrt "$EXEC_TESTS_CMD"
198
- }
199
-
200
- ###############################################################################
201
-
202
- windows_tests() {
203
- local arch
204
-
205
- test_group_included windows || return 0
206
-
207
- # Windows: currently compiled but not run
208
- for arch in i686 x86_64; do
209
- local compiler=${arch}-w64-mingw32-gcc
210
- if ! type -P $compiler > /dev/null; then
211
- log_skip "$compiler not found"
212
- continue
213
- fi
214
- run_cmd make CC=$compiler CFLAGS=-Werror -j$NPROC \
215
- all test_programs
216
- done
217
- }
218
-
219
- ###############################################################################
220
-
221
- static_analysis_tests() {
222
- test_group_included static_analysis || return 0
223
- if ! type -P scan-build > /dev/null; then
224
- log_skip "clang static analyzer (scan-build) not found"
225
- return 0
226
- fi
227
- run_cmd scan-build --status-bugs make -j$NPROC all test_programs
228
- }
229
-
230
- ###############################################################################
231
-
232
- gzip_tests() {
233
- test_group_included gzip || return 0
234
-
235
- local gzip gunzip
236
- run_cmd make -j$NPROC gzip gunzip
237
- for gzip in "$PWD/gzip" /usr/bin/gzip; do
238
- for gunzip in "$PWD/gunzip" /usr/bin/gunzip; do
239
- log "Running gzip program tests with GZIP=$gzip," \
240
- "GUNZIP=$gunzip"
241
- GZIP="$gzip" GUNZIP="$gunzip" SMOKEDATA="$SMOKEDATA" \
242
- ./tools/gzip_tests.sh
243
- done
244
- done
245
-
246
- log "Running gzip program tests with Valgrind"
247
- GZIP="$VALGRIND $PWD/gzip" GUNZIP="$VALGRIND $PWD/gunzip" \
248
- SMOKEDATA="$SMOKEDATA" ./tools/gzip_tests.sh
249
-
250
- log "Running gzip program tests with undefined behavior sanitizer"
251
- run_cmd make -j$NPROC CC=clang CFLAGS="$SANITIZE_CFLAGS" gzip gunzip
252
- GZIP="$PWD/gzip" GUNZIP="$PWD/gunzip" \
253
- SMOKEDATA="$SMOKEDATA" ./tools/gzip_tests.sh
254
- }
255
-
256
- ###############################################################################
257
-
258
- edge_case_tests() {
259
- test_group_included edge_case || return 0
260
-
261
- # Regression test for "deflate_compress: fix corruption with long
262
- # literal run". Try to compress a file longer than 65535 bytes where no
263
- # 2-byte sequence (3 would be sufficient) is repeated <= 32768 bytes
264
- # apart, and the distribution of bytes remains constant throughout, and
265
- # yet not all bytes are used so the data is still slightly compressible.
266
- # There will be no matches in this data, but the compressor should still
267
- # output a compressed block, and this block should contain more than
268
- # 65535 consecutive literals, which triggered the bug.
269
- #
270
- # Note: on random data, this situation is extremely unlikely if the
271
- # compressor uses all matches it finds, since random data will on
272
- # average have a 3-byte match every (256**3)/32768 = 512 bytes.
273
- python3 > "$TMPFILE" << EOF
274
- import sys
275
- for i in range(2):
276
- for stride in range(1,251):
277
- b = bytes(stride*multiple % 251 for multiple in range(251))
278
- sys.stdout.buffer.write(b)
279
- EOF
280
- run_cmd make -j$NPROC benchmark
281
- run_cmd ./benchmark -3 "$TMPFILE"
282
- run_cmd ./benchmark -6 "$TMPFILE"
283
- run_cmd ./benchmark -12 "$TMPFILE"
284
- }
285
-
286
- ###############################################################################
287
-
288
- log "Starting libdeflate tests"
289
- log " TESTGROUPS=(${TESTGROUPS[@]})"
290
- log " SMOKEDATA=$SMOKEDATA"
291
- log " NDKDIR=$NDKDIR"
292
-
293
- native_tests
294
- android_tests
295
- mips_tests
296
- windows_tests
297
- static_analysis_tests
298
- gzip_tests
299
- edge_case_tests
300
-
301
- if (( TESTS_SKIPPED )); then
302
- log "No tests failed, but some tests were skipped. See above."
303
- else
304
- log "All tests passed!"
305
- fi
@@ -1,10 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -eu
4
-
5
- make -j CC=i686-w64-mingw32-gcc all test_programs
6
- cp -vf *.exe /j/exe/
7
- make -j CC=x86_64-w64-mingw32-gcc all test_programs
8
- cp -vf *.exe /j/exe64/
9
-
10
- sudo $HOME/bin/sudo/restart-smbd