deflate-ruby 1.0.0 → 1.0.2
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.
- checksums.yaml +4 -4
- data/CLAUDE.md +95 -92
- data/LICENSE.txt +6 -6
- data/README.md +87 -65
- data/Rakefile +23 -0
- data/ext/deflate_ruby/{libdeflate/lib/x86/adler32_impl.h → adler32_impl.h} +8 -7
- data/ext/deflate_ruby/common_defs.h +748 -0
- data/ext/deflate_ruby/{libdeflate/lib/x86/cpu_features.c → cpu_features.c} +46 -16
- data/ext/deflate_ruby/{libdeflate/lib/x86/cpu_features.h → cpu_features.h} +2 -1
- data/ext/deflate_ruby/{libdeflate/lib/x86/crc32_impl.h → crc32_impl.h} +22 -23
- data/ext/deflate_ruby/{libdeflate/lib/crc32_multipliers.h → crc32_multipliers.h} +2 -4
- data/ext/deflate_ruby/{libdeflate/lib/x86/crc32_pclmul_template.h → crc32_pclmul_template.h} +23 -94
- data/ext/deflate_ruby/{libdeflate/lib/crc32_tables.h → crc32_tables.h} +1 -1
- data/ext/deflate_ruby/{libdeflate/lib/deflate_compress.c → deflate_compress.c} +59 -60
- data/ext/deflate_ruby/deflate_ruby.c +392 -218
- data/ext/deflate_ruby/deflate_ruby.h +6 -0
- data/ext/deflate_ruby/extconf.rb +35 -25
- data/ext/deflate_ruby/libdeflate/adler32.c +162 -0
- data/ext/deflate_ruby/libdeflate/{lib/arm → arm}/adler32_impl.h +14 -7
- data/ext/deflate_ruby/libdeflate/{lib/arm → arm}/crc32_impl.h +25 -31
- data/ext/deflate_ruby/libdeflate/arm/crc32_pmull_helpers.h +156 -0
- data/ext/deflate_ruby/libdeflate/arm/crc32_pmull_wide.h +226 -0
- data/ext/deflate_ruby/libdeflate/bt_matchfinder.h +342 -0
- data/ext/deflate_ruby/libdeflate/common_defs.h +2 -1
- data/ext/deflate_ruby/libdeflate/cpu_features_common.h +93 -0
- data/ext/deflate_ruby/libdeflate/crc32.c +262 -0
- data/ext/deflate_ruby/libdeflate/crc32_multipliers.h +375 -0
- data/ext/deflate_ruby/libdeflate/crc32_tables.h +587 -0
- data/ext/deflate_ruby/libdeflate/decompress_template.h +777 -0
- data/ext/deflate_ruby/libdeflate/deflate_compress.c +4128 -0
- data/ext/deflate_ruby/libdeflate/deflate_compress.h +15 -0
- data/ext/deflate_ruby/libdeflate/deflate_constants.h +56 -0
- data/ext/deflate_ruby/libdeflate/deflate_decompress.c +1208 -0
- data/ext/deflate_ruby/libdeflate/gzip_compress.c +90 -0
- data/ext/deflate_ruby/libdeflate/gzip_constants.h +45 -0
- data/ext/deflate_ruby/libdeflate/gzip_decompress.c +144 -0
- data/ext/deflate_ruby/libdeflate/hc_matchfinder.h +401 -0
- data/ext/deflate_ruby/libdeflate/ht_matchfinder.h +234 -0
- data/ext/deflate_ruby/libdeflate/lib_common.h +106 -0
- data/ext/deflate_ruby/libdeflate/libdeflate.h +2 -2
- data/ext/deflate_ruby/libdeflate/{lib/matchfinder_common.h → matchfinder_common.h} +3 -3
- data/ext/deflate_ruby/libdeflate/x86/adler32_impl.h +135 -0
- data/ext/deflate_ruby/libdeflate/x86/adler32_template.h +518 -0
- data/ext/deflate_ruby/libdeflate/x86/cpu_features.c +213 -0
- data/ext/deflate_ruby/libdeflate/x86/cpu_features.h +170 -0
- data/ext/deflate_ruby/libdeflate/x86/crc32_impl.h +159 -0
- data/ext/deflate_ruby/libdeflate/x86/crc32_pclmul_template.h +424 -0
- data/ext/deflate_ruby/libdeflate/x86/decompress_impl.h +57 -0
- data/ext/deflate_ruby/libdeflate.h +411 -0
- data/ext/deflate_ruby/matchfinder_common.h +224 -0
- data/ext/deflate_ruby/matchfinder_impl.h +122 -0
- data/ext/deflate_ruby/utils.c +141 -0
- data/ext/deflate_ruby/zlib_compress.c +82 -0
- data/ext/deflate_ruby/zlib_constants.h +21 -0
- data/ext/deflate_ruby/zlib_decompress.c +104 -0
- data/lib/deflate_ruby/version.rb +1 -1
- data/lib/deflate_ruby.rb +1 -63
- data/sig/deflate_ruby.rbs +4 -0
- data/test/test_deflate_ruby.rb +220 -0
- data/test/test_helper.rb +6 -0
- metadata +89 -144
- data/ext/deflate_ruby/libdeflate/CMakeLists.txt +0 -270
- data/ext/deflate_ruby/libdeflate/NEWS.md +0 -494
- data/ext/deflate_ruby/libdeflate/README.md +0 -228
- data/ext/deflate_ruby/libdeflate/libdeflate-config.cmake.in +0 -3
- data/ext/deflate_ruby/libdeflate/libdeflate.pc.in +0 -18
- data/ext/deflate_ruby/libdeflate/programs/CMakeLists.txt +0 -105
- data/ext/deflate_ruby/libdeflate/programs/benchmark.c +0 -696
- data/ext/deflate_ruby/libdeflate/programs/checksum.c +0 -218
- data/ext/deflate_ruby/libdeflate/programs/config.h.in +0 -19
- data/ext/deflate_ruby/libdeflate/programs/gzip.c +0 -688
- data/ext/deflate_ruby/libdeflate/programs/prog_util.c +0 -521
- data/ext/deflate_ruby/libdeflate/programs/prog_util.h +0 -225
- data/ext/deflate_ruby/libdeflate/programs/test_checksums.c +0 -200
- data/ext/deflate_ruby/libdeflate/programs/test_custom_malloc.c +0 -155
- data/ext/deflate_ruby/libdeflate/programs/test_incomplete_codes.c +0 -385
- data/ext/deflate_ruby/libdeflate/programs/test_invalid_streams.c +0 -130
- data/ext/deflate_ruby/libdeflate/programs/test_litrunlen_overflow.c +0 -72
- data/ext/deflate_ruby/libdeflate/programs/test_overread.c +0 -95
- data/ext/deflate_ruby/libdeflate/programs/test_slow_decompression.c +0 -472
- data/ext/deflate_ruby/libdeflate/programs/test_trailing_bytes.c +0 -151
- data/ext/deflate_ruby/libdeflate/programs/test_util.c +0 -237
- data/ext/deflate_ruby/libdeflate/programs/test_util.h +0 -61
- data/ext/deflate_ruby/libdeflate/programs/tgetopt.c +0 -118
- data/ext/deflate_ruby/libdeflate/scripts/android_build.sh +0 -118
- data/ext/deflate_ruby/libdeflate/scripts/android_tests.sh +0 -69
- data/ext/deflate_ruby/libdeflate/scripts/benchmark.sh +0 -10
- data/ext/deflate_ruby/libdeflate/scripts/checksum.sh +0 -10
- data/ext/deflate_ruby/libdeflate/scripts/checksum_benchmarks.sh +0 -253
- data/ext/deflate_ruby/libdeflate/scripts/cmake-helper.sh +0 -17
- data/ext/deflate_ruby/libdeflate/scripts/deflate_benchmarks.sh +0 -119
- data/ext/deflate_ruby/libdeflate/scripts/exec_tests.sh +0 -38
- data/ext/deflate_ruby/libdeflate/scripts/gen-release-archives.sh +0 -37
- data/ext/deflate_ruby/libdeflate/scripts/gen_bitreverse_tab.py +0 -19
- data/ext/deflate_ruby/libdeflate/scripts/gen_crc32_multipliers.c +0 -199
- data/ext/deflate_ruby/libdeflate/scripts/gen_crc32_tables.c +0 -105
- data/ext/deflate_ruby/libdeflate/scripts/gen_default_litlen_costs.py +0 -44
- data/ext/deflate_ruby/libdeflate/scripts/gen_offset_slot_map.py +0 -29
- data/ext/deflate_ruby/libdeflate/scripts/gzip_tests.sh +0 -523
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/deflate_compress/corpus/0 +0 -0
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/deflate_compress/fuzz.c +0 -95
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/deflate_decompress/corpus/0 +0 -3
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/deflate_decompress/fuzz.c +0 -62
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/fuzz.sh +0 -108
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/gzip_decompress/corpus/0 +0 -0
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/gzip_decompress/fuzz.c +0 -19
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/zlib_decompress/corpus/0 +0 -3
- data/ext/deflate_ruby/libdeflate/scripts/libFuzzer/zlib_decompress/fuzz.c +0 -19
- data/ext/deflate_ruby/libdeflate/scripts/run_tests.sh +0 -416
- data/ext/deflate_ruby/libdeflate/scripts/toolchain-i686-w64-mingw32.cmake +0 -8
- data/ext/deflate_ruby/libdeflate/scripts/toolchain-x86_64-w64-mingw32.cmake +0 -8
- /data/ext/deflate_ruby/{libdeflate/lib/adler32.c → adler32.c} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/x86/adler32_template.h → adler32_template.h} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/bt_matchfinder.h → bt_matchfinder.h} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/cpu_features_common.h → cpu_features_common.h} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/crc32.c → crc32.c} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/arm/crc32_pmull_helpers.h → crc32_pmull_helpers.h} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/arm/crc32_pmull_wide.h → crc32_pmull_wide.h} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/x86/decompress_impl.h → decompress_impl.h} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/decompress_template.h → decompress_template.h} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/deflate_compress.h → deflate_compress.h} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/deflate_constants.h → deflate_constants.h} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/deflate_decompress.c → deflate_decompress.c} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/gzip_compress.c → gzip_compress.c} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/gzip_constants.h → gzip_constants.h} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/gzip_decompress.c → gzip_decompress.c} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/hc_matchfinder.h → hc_matchfinder.h} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/ht_matchfinder.h → ht_matchfinder.h} +0 -0
- /data/ext/deflate_ruby/{libdeflate/lib/lib_common.h → lib_common.h} +0 -0
- /data/ext/deflate_ruby/libdeflate/{lib/arm → arm}/cpu_features.c +0 -0
- /data/ext/deflate_ruby/libdeflate/{lib/arm → arm}/cpu_features.h +0 -0
- /data/ext/deflate_ruby/libdeflate/{lib/arm → arm}/matchfinder_impl.h +0 -0
- /data/ext/deflate_ruby/libdeflate/{lib/riscv → riscv}/matchfinder_impl.h +0 -0
- /data/ext/deflate_ruby/libdeflate/{lib/utils.c → utils.c} +0 -0
- /data/ext/deflate_ruby/libdeflate/{lib/x86 → x86}/matchfinder_impl.h +0 -0
- /data/ext/deflate_ruby/libdeflate/{lib/zlib_compress.c → zlib_compress.c} +0 -0
- /data/ext/deflate_ruby/libdeflate/{lib/zlib_constants.h → zlib_constants.h} +0 -0
- /data/ext/deflate_ruby/libdeflate/{lib/zlib_decompress.c → zlib_decompress.c} +0 -0
|
@@ -1,416 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
#
|
|
3
|
-
# Test script for libdeflate
|
|
4
|
-
#
|
|
5
|
-
# Usage:
|
|
6
|
-
# Run all tests:
|
|
7
|
-
# ./run_tests.sh
|
|
8
|
-
# Run only the given tests:
|
|
9
|
-
# ./run_tests.sh asan valgrind
|
|
10
|
-
# Run all tests other than the given ones:
|
|
11
|
-
# ./run_tests.sh ^asan ^valgrind
|
|
12
|
-
#
|
|
13
|
-
# See TEST_FUNCS for the available tests.
|
|
14
|
-
|
|
15
|
-
set -eu -o pipefail
|
|
16
|
-
cd "$(dirname "$0")/.."
|
|
17
|
-
|
|
18
|
-
# Use CC if specified in environment, else default to "cc".
|
|
19
|
-
: "${CC:=cc}"
|
|
20
|
-
|
|
21
|
-
export CFLAGS="-Werror -DLIBDEFLATE_ENABLE_ASSERTIONS"
|
|
22
|
-
|
|
23
|
-
# No wrapper by default; overridden by valgrind tests
|
|
24
|
-
export WRAPPER=
|
|
25
|
-
|
|
26
|
-
TEST_FUNCS=()
|
|
27
|
-
|
|
28
|
-
CLEANUP_CMDS=()
|
|
29
|
-
cleanup() {
|
|
30
|
-
for cmd in "${CLEANUP_CMDS[@]}"; do
|
|
31
|
-
eval "$cmd"
|
|
32
|
-
done
|
|
33
|
-
}
|
|
34
|
-
trap cleanup EXIT
|
|
35
|
-
|
|
36
|
-
CLEANUP_CMDS+=("rm -rf build")
|
|
37
|
-
|
|
38
|
-
# Use TESTDATA if specified in environment, else generate it.
|
|
39
|
-
if [ -z "${TESTDATA:-}" ]; then
|
|
40
|
-
# Generate default TESTDATA file.
|
|
41
|
-
TESTDATA=$(mktemp -t libdeflate_testdata.XXXXXXXXXX)
|
|
42
|
-
export TESTDATA
|
|
43
|
-
CLEANUP_CMDS+=("rm -f '$TESTDATA'")
|
|
44
|
-
find . '(' -name '*.c' -o -name '*.h' -o -name '*.sh' ')' \
|
|
45
|
-
-exec cat '{}' ';' | head -c 1000000 > "$TESTDATA"
|
|
46
|
-
fi
|
|
47
|
-
|
|
48
|
-
TMPDIR=$(mktemp -d -t libdeflate_test.XXXXXXXXX)
|
|
49
|
-
CLEANUP_CMDS+=("rm -r '$TMPDIR'")
|
|
50
|
-
|
|
51
|
-
MAKE="make -j$(getconf _NPROCESSORS_ONLN)"
|
|
52
|
-
|
|
53
|
-
UNAME=$(uname)
|
|
54
|
-
ARCH=$(uname -m)
|
|
55
|
-
|
|
56
|
-
SHLIB=build/libdeflate.so
|
|
57
|
-
if [ "$UNAME" = Darwin ]; then
|
|
58
|
-
SHLIB=build/libdeflate.dylib
|
|
59
|
-
fi
|
|
60
|
-
|
|
61
|
-
###############################################################################
|
|
62
|
-
|
|
63
|
-
INDENT=0
|
|
64
|
-
|
|
65
|
-
log()
|
|
66
|
-
{
|
|
67
|
-
echo -n "[$(date)] "
|
|
68
|
-
if (( INDENT != 0 )); then
|
|
69
|
-
head -c $(( INDENT * 4 )) /dev/zero | tr '\0' ' '
|
|
70
|
-
fi
|
|
71
|
-
echo "$@"
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
begin()
|
|
75
|
-
{
|
|
76
|
-
log "$@"
|
|
77
|
-
(( INDENT++ )) || true
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
end()
|
|
81
|
-
{
|
|
82
|
-
(( INDENT-- )) || true
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
run_cmd()
|
|
86
|
-
{
|
|
87
|
-
log "$@"
|
|
88
|
-
"$@" > /dev/null
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
fail()
|
|
92
|
-
{
|
|
93
|
-
echo 1>&2 "$@"
|
|
94
|
-
exit 1
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
file_count()
|
|
98
|
-
{
|
|
99
|
-
local dir=$1
|
|
100
|
-
|
|
101
|
-
find "$dir" -type f -o -type l | wc -l
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
cflags_supported()
|
|
105
|
-
{
|
|
106
|
-
# -Werror is needed here in order for old versions of clang to reject
|
|
107
|
-
# invalid options.
|
|
108
|
-
echo 'int main(void){ return 0; }' \
|
|
109
|
-
| $CC "$@" -Werror -x c - -o /dev/null 2>/dev/null
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
# Build libdeflate, including the test programs. Set the special test support
|
|
113
|
-
# flag to get support for LIBDEFLATE_DISABLE_CPU_FEATURES.
|
|
114
|
-
build()
|
|
115
|
-
{
|
|
116
|
-
CFLAGS="$CFLAGS -DTEST_SUPPORT__DO_NOT_USE=1" scripts/cmake-helper.sh \
|
|
117
|
-
-DLIBDEFLATE_BUILD_TESTS=1 "$@" > /dev/null
|
|
118
|
-
$MAKE -C build > /dev/null
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
build_and_run_tests()
|
|
122
|
-
{
|
|
123
|
-
local quick=false
|
|
124
|
-
if [ "${1:-}" = "--quick" ]; then
|
|
125
|
-
quick=true
|
|
126
|
-
shift
|
|
127
|
-
fi
|
|
128
|
-
|
|
129
|
-
begin "CC=$CC CFLAGS=\"$CFLAGS\" WRAPPER=\"$WRAPPER\" $*"
|
|
130
|
-
|
|
131
|
-
build "$@"
|
|
132
|
-
|
|
133
|
-
# When not using -march=native, run the tests multiple times with
|
|
134
|
-
# different combinations of CPU features disabled. This is needed to
|
|
135
|
-
# test all variants of dynamically-dispatched code.
|
|
136
|
-
#
|
|
137
|
-
# For now, we aren't super exhausive in which combinations of features
|
|
138
|
-
# we test disabling. We just disable the features roughly in order from
|
|
139
|
-
# newest to oldest for each architecture, cumulatively. In practice,
|
|
140
|
-
# that's good enough to cover all the code.
|
|
141
|
-
local features=('')
|
|
142
|
-
if ! [[ "$CFLAGS" =~ "-march=native" ]] && ! $quick; then
|
|
143
|
-
case "$ARCH" in
|
|
144
|
-
i386|x86_64)
|
|
145
|
-
features+=(zmm avx512_vnni avx512vl avx_vnni vpclmulqdq
|
|
146
|
-
avx2 avx bmi2 pclmulqdq sse2)
|
|
147
|
-
;;
|
|
148
|
-
arm*|aarch*)
|
|
149
|
-
features+=(dotprod sha3 prefer_pmull crc32 pmull neon)
|
|
150
|
-
;;
|
|
151
|
-
esac
|
|
152
|
-
fi
|
|
153
|
-
local disable_str=""
|
|
154
|
-
local feature
|
|
155
|
-
for feature in "${features[@]}"; do
|
|
156
|
-
if [ -n "$feature" ]; then
|
|
157
|
-
if [ -n "$disable_str" ]; then
|
|
158
|
-
disable_str+=","
|
|
159
|
-
fi
|
|
160
|
-
disable_str+="$feature"
|
|
161
|
-
fi
|
|
162
|
-
log "Using LIBDEFLATE_DISABLE_CPU_FEATURES=$disable_str"
|
|
163
|
-
LIBDEFLATE_DISABLE_CPU_FEATURES="$disable_str" \
|
|
164
|
-
sh ./scripts/exec_tests.sh build/programs/ > /dev/null
|
|
165
|
-
done
|
|
166
|
-
end
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
is_compatible_system_gzip()
|
|
170
|
-
{
|
|
171
|
-
local prog=$1
|
|
172
|
-
|
|
173
|
-
# Needs to exist.
|
|
174
|
-
if ! [ -e "$prog" ]; then
|
|
175
|
-
return 1
|
|
176
|
-
fi
|
|
177
|
-
# Needs to be GNU gzip.
|
|
178
|
-
if ! "$prog" -V 2>&1 | grep -q 'Free Software Foundation'; then
|
|
179
|
-
return 1
|
|
180
|
-
fi
|
|
181
|
-
# Needs to support the -k option, i.e. be v1.6 or later.
|
|
182
|
-
if echo | { "$prog" -k 2>&1 >/dev/null || true; } \
|
|
183
|
-
| grep -q 'invalid option'; then
|
|
184
|
-
return 1
|
|
185
|
-
fi
|
|
186
|
-
return 0
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
gzip_tests()
|
|
190
|
-
{
|
|
191
|
-
local gzips=("$PWD/build/programs/libdeflate-gzip")
|
|
192
|
-
local gunzips=("$PWD/build/programs/libdeflate-gzip -d")
|
|
193
|
-
if [ "${1:-}" != "--quick" ]; then
|
|
194
|
-
if is_compatible_system_gzip /bin/gzip; then
|
|
195
|
-
gzips+=(/bin/gzip)
|
|
196
|
-
gunzips+=(/bin/gunzip)
|
|
197
|
-
elif is_compatible_system_gzip /usr/bin/gzip; then
|
|
198
|
-
gzips+=(/usr/bin/gzip)
|
|
199
|
-
gunzips+=(/usr/bin/gunzip)
|
|
200
|
-
else
|
|
201
|
-
log "Unsupported system gzip; skipping comparison with system gzip"
|
|
202
|
-
fi
|
|
203
|
-
fi
|
|
204
|
-
local gzip gunzip
|
|
205
|
-
|
|
206
|
-
begin "Running gzip program tests with CC=\"$CC\" CFLAGS=\"$CFLAGS\""
|
|
207
|
-
build
|
|
208
|
-
for gzip in "${gzips[@]}"; do
|
|
209
|
-
for gunzip in "${gunzips[@]}"; do
|
|
210
|
-
log "GZIP=$gzip, GUNZIP=$gunzip"
|
|
211
|
-
GZIP="$gzip" GUNZIP="$gunzip" TESTDATA="$TESTDATA" \
|
|
212
|
-
./scripts/gzip_tests.sh
|
|
213
|
-
done
|
|
214
|
-
done
|
|
215
|
-
end
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
do_run_tests()
|
|
219
|
-
{
|
|
220
|
-
build_and_run_tests "$@"
|
|
221
|
-
gzip_tests "$@"
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
################################################################################
|
|
225
|
-
|
|
226
|
-
regular_test()
|
|
227
|
-
{
|
|
228
|
-
do_run_tests
|
|
229
|
-
}
|
|
230
|
-
TEST_FUNCS+=(regular_test)
|
|
231
|
-
|
|
232
|
-
O3_test()
|
|
233
|
-
{
|
|
234
|
-
CFLAGS="$CFLAGS -O3" do_run_tests
|
|
235
|
-
}
|
|
236
|
-
TEST_FUNCS+=(O3_test)
|
|
237
|
-
|
|
238
|
-
march_native_test()
|
|
239
|
-
{
|
|
240
|
-
if ! cflags_supported "-march=native"; then
|
|
241
|
-
log "Compiler doesn't support -march=native; skipping test"
|
|
242
|
-
return
|
|
243
|
-
fi
|
|
244
|
-
CFLAGS="$CFLAGS -march=native" do_run_tests
|
|
245
|
-
}
|
|
246
|
-
TEST_FUNCS+=(march_native_test)
|
|
247
|
-
|
|
248
|
-
valgrind_version_at_least()
|
|
249
|
-
{
|
|
250
|
-
local want_vers=$1
|
|
251
|
-
local vers
|
|
252
|
-
|
|
253
|
-
if ! type -P valgrind &> /dev/null; then
|
|
254
|
-
return 1
|
|
255
|
-
fi
|
|
256
|
-
|
|
257
|
-
vers=$(valgrind --version | grep -E -o '[0-9\.]+' | head -1)
|
|
258
|
-
|
|
259
|
-
[ "$want_vers" = "$(echo -e "$vers\n$want_vers" | sort -V | head -1)" ]
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
valgrind_test()
|
|
263
|
-
{
|
|
264
|
-
# Need valgrind 3.9.0 for '--errors-for-leak-kinds=all'
|
|
265
|
-
# Need valgrind 3.12.0 for armv8 crypto and crc instructions
|
|
266
|
-
if ! valgrind_version_at_least 3.12.0; then
|
|
267
|
-
log "valgrind not found; skipping test"
|
|
268
|
-
return
|
|
269
|
-
fi
|
|
270
|
-
WRAPPER="valgrind --quiet --error-exitcode=100 --leak-check=full --errors-for-leak-kinds=all" \
|
|
271
|
-
do_run_tests --quick
|
|
272
|
-
}
|
|
273
|
-
TEST_FUNCS+=(valgrind_test)
|
|
274
|
-
|
|
275
|
-
ubsan_test()
|
|
276
|
-
{
|
|
277
|
-
local cflags=("-fsanitize=undefined" "-fno-sanitize-recover=undefined")
|
|
278
|
-
if ! cflags_supported "${cflags[@]}"; then
|
|
279
|
-
log "Compiler doesn't support UBSAN; skipping test"
|
|
280
|
-
return
|
|
281
|
-
fi
|
|
282
|
-
CFLAGS="$CFLAGS ${cflags[*]}" do_run_tests --quick
|
|
283
|
-
}
|
|
284
|
-
TEST_FUNCS+=(ubsan_test)
|
|
285
|
-
|
|
286
|
-
asan_test()
|
|
287
|
-
{
|
|
288
|
-
local cflags=("-fsanitize=address" "-fno-sanitize-recover=address")
|
|
289
|
-
if ! cflags_supported "${cflags[@]}"; then
|
|
290
|
-
log "Compiler doesn't support ASAN; skipping test"
|
|
291
|
-
return
|
|
292
|
-
fi
|
|
293
|
-
CFLAGS="$CFLAGS ${cflags[*]}" do_run_tests --quick
|
|
294
|
-
}
|
|
295
|
-
TEST_FUNCS+=(asan_test)
|
|
296
|
-
|
|
297
|
-
cfi_test()
|
|
298
|
-
{
|
|
299
|
-
local cflags=("-fsanitize=cfi" "-fno-sanitize-recover=cfi" "-flto"
|
|
300
|
-
"-fvisibility=hidden")
|
|
301
|
-
if ! cflags_supported "${cflags[@]}"; then
|
|
302
|
-
log "Compiler doesn't support CFI; skipping test"
|
|
303
|
-
return
|
|
304
|
-
fi
|
|
305
|
-
CFLAGS="$CFLAGS ${cflags[*]}" AR=llvm-ar do_run_tests --quick
|
|
306
|
-
}
|
|
307
|
-
TEST_FUNCS+=(cfi_test)
|
|
308
|
-
|
|
309
|
-
install_test()
|
|
310
|
-
{
|
|
311
|
-
build
|
|
312
|
-
$MAKE -C build install DESTDIR=inst > /dev/null
|
|
313
|
-
}
|
|
314
|
-
TEST_FUNCS+=(install_test)
|
|
315
|
-
|
|
316
|
-
symbol_prefix_test()
|
|
317
|
-
{
|
|
318
|
-
build
|
|
319
|
-
log "Checking that all global symbols are prefixed with \"libdeflate_\""
|
|
320
|
-
if nm build/libdeflate.a | grep ' T ' | grep -E -v " _?libdeflate_"
|
|
321
|
-
then
|
|
322
|
-
fail "Some global symbols aren't prefixed with \"libdeflate_\""
|
|
323
|
-
fi
|
|
324
|
-
log "Checking that all exported symbols are prefixed with \"libdeflate\""
|
|
325
|
-
if nm $SHLIB | grep ' T ' \
|
|
326
|
-
| grep -E -v " _?(libdeflate_|_init\>|_fini\>)"; then
|
|
327
|
-
fail "Some exported symbols aren't prefixed with \"libdeflate_\""
|
|
328
|
-
fi
|
|
329
|
-
}
|
|
330
|
-
TEST_FUNCS+=(symbol_prefix_test)
|
|
331
|
-
|
|
332
|
-
is_dynamically_linked()
|
|
333
|
-
{
|
|
334
|
-
local prog=$1
|
|
335
|
-
|
|
336
|
-
if [ "$UNAME" = Darwin ]; then
|
|
337
|
-
otool -L "$prog" | grep -q libdeflate
|
|
338
|
-
else
|
|
339
|
-
ldd "$prog" | grep -q libdeflate
|
|
340
|
-
fi
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
use_shared_lib_test()
|
|
344
|
-
{
|
|
345
|
-
log "Testing USE_SHARED_LIB=1"
|
|
346
|
-
build
|
|
347
|
-
if is_dynamically_linked build/programs/libdeflate-gzip; then
|
|
348
|
-
fail "Binary should be statically linked by default"
|
|
349
|
-
fi
|
|
350
|
-
build -DLIBDEFLATE_USE_SHARED_LIB=1 > /dev/null
|
|
351
|
-
if ! is_dynamically_linked build/programs/libdeflate-gzip; then
|
|
352
|
-
fail "Binary isn't dynamically linked"
|
|
353
|
-
fi
|
|
354
|
-
}
|
|
355
|
-
TEST_FUNCS+=(use_shared_lib_test)
|
|
356
|
-
|
|
357
|
-
freestanding_test()
|
|
358
|
-
{
|
|
359
|
-
if [ "$UNAME" = Darwin ]; then
|
|
360
|
-
log "Skipping freestanding build tests due to unsupported OS"
|
|
361
|
-
return
|
|
362
|
-
fi
|
|
363
|
-
build_and_run_tests --quick -DLIBDEFLATE_FREESTANDING=1
|
|
364
|
-
if nm $SHLIB | grep -v '\<__stack_chk_fail\>' | grep -q ' U '; then
|
|
365
|
-
echo 1>&2 "Freestanding lib links to external functions!:"
|
|
366
|
-
nm $SHLIB | grep ' U '
|
|
367
|
-
return 1
|
|
368
|
-
fi
|
|
369
|
-
if ldd $SHLIB | grep -q -v '\<statically linked\>'; then
|
|
370
|
-
echo 1>&2 "Freestanding lib links to external libraries!:"
|
|
371
|
-
ldd $SHLIB
|
|
372
|
-
return 1
|
|
373
|
-
fi
|
|
374
|
-
}
|
|
375
|
-
TEST_FUNCS+=(freestanding_test)
|
|
376
|
-
|
|
377
|
-
###############################################################################
|
|
378
|
-
|
|
379
|
-
declare -A all_tests
|
|
380
|
-
for test_func in "${TEST_FUNCS[@]}"; do
|
|
381
|
-
all_tests["${test_func%_test}"]=true
|
|
382
|
-
done
|
|
383
|
-
declare -A tests_to_run
|
|
384
|
-
|
|
385
|
-
# Determine the set of tests to run by applying any inclusions and exclusions
|
|
386
|
-
# given on the command line. If no inclusions were given, then default to all
|
|
387
|
-
# tests (subject to exclusions).
|
|
388
|
-
all=true
|
|
389
|
-
for arg; do
|
|
390
|
-
if [[ $arg != ^* ]]; then
|
|
391
|
-
all=false
|
|
392
|
-
fi
|
|
393
|
-
done
|
|
394
|
-
if $all; then
|
|
395
|
-
for t in "${!all_tests[@]}"; do
|
|
396
|
-
tests_to_run[$t]=true
|
|
397
|
-
done
|
|
398
|
-
fi
|
|
399
|
-
for arg; do
|
|
400
|
-
if [[ $arg == ^* ]]; then
|
|
401
|
-
unset "tests_to_run[${arg#^}]"
|
|
402
|
-
elif [[ -z ${all_tests["$arg"]:-} ]]; then
|
|
403
|
-
fail "Unknown test '$arg'. Options are: ${!all_tests[*]}"
|
|
404
|
-
else
|
|
405
|
-
tests_to_run["$arg"]=true
|
|
406
|
-
fi
|
|
407
|
-
done
|
|
408
|
-
|
|
409
|
-
# Actually run the tests.
|
|
410
|
-
log "Running libdeflate tests: ${!tests_to_run[*]}"
|
|
411
|
-
for t in "${!tests_to_run[@]}"; do
|
|
412
|
-
begin "Running ${t}_test"
|
|
413
|
-
eval "${t}_test"
|
|
414
|
-
end
|
|
415
|
-
done
|
|
416
|
-
log "All tests passed!"
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
set(CMAKE_SYSTEM_NAME Windows)
|
|
2
|
-
set(CMAKE_SYSTEM_PROCESSOR i686)
|
|
3
|
-
set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
|
|
4
|
-
set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
|
|
5
|
-
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
6
|
-
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
7
|
-
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
|
8
|
-
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
set(CMAKE_SYSTEM_NAME Windows)
|
|
2
|
-
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
|
3
|
-
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
|
|
4
|
-
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
|
|
5
|
-
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
6
|
-
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
7
|
-
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
|
8
|
-
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|