zstd-native-ruby 1.0.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 (651) hide show
  1. checksums.yaml +7 -0
  2. data/CLAUDE.md +101 -0
  3. data/LICENSE +19 -0
  4. data/README.md +47 -0
  5. data/ext/zstd_ruby/extconf.rb +35 -0
  6. data/ext/zstd_ruby/zstd_ruby.c +221 -0
  7. data/lib/zstd_ruby.rb +68 -0
  8. data/vendor/zstd/CHANGELOG +863 -0
  9. data/vendor/zstd/CMakeLists.txt +11 -0
  10. data/vendor/zstd/CODE_OF_CONDUCT.md +5 -0
  11. data/vendor/zstd/CONTRIBUTING.md +494 -0
  12. data/vendor/zstd/COPYING +339 -0
  13. data/vendor/zstd/LICENSE +30 -0
  14. data/vendor/zstd/Makefile +470 -0
  15. data/vendor/zstd/Package.swift +36 -0
  16. data/vendor/zstd/README.md +244 -0
  17. data/vendor/zstd/SECURITY.md +15 -0
  18. data/vendor/zstd/TESTING.md +43 -0
  19. data/vendor/zstd/build/LICENSE +0 -0
  20. data/vendor/zstd/build/README.md +56 -0
  21. data/vendor/zstd/build/VS2008/fullbench/fullbench.vcproj +549 -0
  22. data/vendor/zstd/build/VS2008/fuzzer/fuzzer.vcproj +585 -0
  23. data/vendor/zstd/build/VS2008/zstd/zstd.vcproj +677 -0
  24. data/vendor/zstd/build/VS2008/zstd.sln +56 -0
  25. data/vendor/zstd/build/VS2008/zstdlib/zstdlib.vcproj +635 -0
  26. data/vendor/zstd/build/VS2010/CompileAsCpp.props +8 -0
  27. data/vendor/zstd/build/VS2010/datagen/datagen.vcxproj +170 -0
  28. data/vendor/zstd/build/VS2010/fullbench/fullbench.vcxproj +220 -0
  29. data/vendor/zstd/build/VS2010/fuzzer/fuzzer.vcxproj +224 -0
  30. data/vendor/zstd/build/VS2010/libzstd/libzstd.vcxproj +243 -0
  31. data/vendor/zstd/build/VS2010/libzstd-dll/libzstd-dll.rc +51 -0
  32. data/vendor/zstd/build/VS2010/libzstd-dll/libzstd-dll.vcxproj +250 -0
  33. data/vendor/zstd/build/VS2010/zstd/zstd.rc +51 -0
  34. data/vendor/zstd/build/VS2010/zstd/zstd.vcxproj +266 -0
  35. data/vendor/zstd/build/VS2010/zstd.sln +84 -0
  36. data/vendor/zstd/build/VS_scripts/README.md +64 -0
  37. data/vendor/zstd/build/VS_scripts/build.VS2010.cmd +7 -0
  38. data/vendor/zstd/build/VS_scripts/build.VS2012.cmd +6 -0
  39. data/vendor/zstd/build/VS_scripts/build.VS2013.cmd +7 -0
  40. data/vendor/zstd/build/VS_scripts/build.VS2015.cmd +7 -0
  41. data/vendor/zstd/build/VS_scripts/build.VS2017.cmd +7 -0
  42. data/vendor/zstd/build/VS_scripts/build.VS2017Community.cmd +7 -0
  43. data/vendor/zstd/build/VS_scripts/build.VS2017Enterprise.cmd +7 -0
  44. data/vendor/zstd/build/VS_scripts/build.VS2017Professional.cmd +7 -0
  45. data/vendor/zstd/build/VS_scripts/build.VSPreview.cmd +7 -0
  46. data/vendor/zstd/build/VS_scripts/build.generic.cmd +67 -0
  47. data/vendor/zstd/build/cmake/CMakeLists.txt +81 -0
  48. data/vendor/zstd/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake +138 -0
  49. data/vendor/zstd/build/cmake/CMakeModules/FindLibLZ4.cmake +49 -0
  50. data/vendor/zstd/build/cmake/CMakeModules/GetZstdLibraryVersion.cmake +10 -0
  51. data/vendor/zstd/build/cmake/CMakeModules/JoinPaths.cmake +23 -0
  52. data/vendor/zstd/build/cmake/CMakeModules/ZstdBuild.cmake +42 -0
  53. data/vendor/zstd/build/cmake/CMakeModules/ZstdDependencies.cmake +30 -0
  54. data/vendor/zstd/build/cmake/CMakeModules/ZstdOptions.cmake +68 -0
  55. data/vendor/zstd/build/cmake/CMakeModules/ZstdPackage.cmake +42 -0
  56. data/vendor/zstd/build/cmake/CMakeModules/ZstdVersion.cmake +31 -0
  57. data/vendor/zstd/build/cmake/README.md +155 -0
  58. data/vendor/zstd/build/cmake/contrib/CMakeLists.txt +13 -0
  59. data/vendor/zstd/build/cmake/contrib/gen_html/CMakeLists.txt +30 -0
  60. data/vendor/zstd/build/cmake/contrib/pzstd/CMakeLists.txt +39 -0
  61. data/vendor/zstd/build/cmake/lib/CMakeLists.txt +298 -0
  62. data/vendor/zstd/build/cmake/lib/cmake_uninstall.cmake.in +22 -0
  63. data/vendor/zstd/build/cmake/programs/CMakeLists.txt +144 -0
  64. data/vendor/zstd/build/cmake/tests/CMakeLists.txt +118 -0
  65. data/vendor/zstd/build/cmake/zstdConfig.cmake.in +10 -0
  66. data/vendor/zstd/build/meson/GetZstdLibraryVersion.py +39 -0
  67. data/vendor/zstd/build/meson/InstallSymlink.py +55 -0
  68. data/vendor/zstd/build/meson/README.md +38 -0
  69. data/vendor/zstd/build/meson/contrib/gen_html/meson.build +30 -0
  70. data/vendor/zstd/build/meson/contrib/meson.build +12 -0
  71. data/vendor/zstd/build/meson/contrib/pzstd/meson.build +25 -0
  72. data/vendor/zstd/build/meson/lib/meson.build +175 -0
  73. data/vendor/zstd/build/meson/meson.build +155 -0
  74. data/vendor/zstd/build/meson/meson_options.txt +36 -0
  75. data/vendor/zstd/build/meson/programs/meson.build +124 -0
  76. data/vendor/zstd/build/meson/tests/meson.build +217 -0
  77. data/vendor/zstd/build/meson/tests/valgrindTest.py +90 -0
  78. data/vendor/zstd/build/single_file_libs/README.md +33 -0
  79. data/vendor/zstd/build/single_file_libs/build_decoder_test.sh +91 -0
  80. data/vendor/zstd/build/single_file_libs/build_library_test.sh +98 -0
  81. data/vendor/zstd/build/single_file_libs/combine.py +234 -0
  82. data/vendor/zstd/build/single_file_libs/combine.sh +249 -0
  83. data/vendor/zstd/build/single_file_libs/create_single_file_decoder.sh +19 -0
  84. data/vendor/zstd/build/single_file_libs/create_single_file_library.sh +19 -0
  85. data/vendor/zstd/build/single_file_libs/examples/README.md +11 -0
  86. data/vendor/zstd/build/single_file_libs/examples/emscripten.c +340 -0
  87. data/vendor/zstd/build/single_file_libs/examples/roundtrip.c +83 -0
  88. data/vendor/zstd/build/single_file_libs/examples/shell.html +31 -0
  89. data/vendor/zstd/build/single_file_libs/examples/simple.c +75 -0
  90. data/vendor/zstd/build/single_file_libs/examples/testcard-dxt1.inl +2731 -0
  91. data/vendor/zstd/build/single_file_libs/examples/testcard-zstd.inl +261 -0
  92. data/vendor/zstd/build/single_file_libs/examples/testcard.png +0 -0
  93. data/vendor/zstd/build/single_file_libs/zstd-in.c +91 -0
  94. data/vendor/zstd/build/single_file_libs/zstddeclib-in.c +62 -0
  95. data/vendor/zstd/contrib/VS2005/README.md +3 -0
  96. data/vendor/zstd/contrib/VS2005/fullbench/fullbench.vcproj +440 -0
  97. data/vendor/zstd/contrib/VS2005/fuzzer/fuzzer.vcproj +488 -0
  98. data/vendor/zstd/contrib/VS2005/zstd/zstd.vcproj +552 -0
  99. data/vendor/zstd/contrib/VS2005/zstd.sln +55 -0
  100. data/vendor/zstd/contrib/VS2005/zstdlib/zstdlib.vcproj +546 -0
  101. data/vendor/zstd/contrib/cleanTabs +2 -0
  102. data/vendor/zstd/contrib/diagnose_corruption/Makefile +35 -0
  103. data/vendor/zstd/contrib/diagnose_corruption/check_flipped_bits.c +400 -0
  104. data/vendor/zstd/contrib/docker/Dockerfile +20 -0
  105. data/vendor/zstd/contrib/docker/README.md +20 -0
  106. data/vendor/zstd/contrib/externalSequenceProducer/Makefile +40 -0
  107. data/vendor/zstd/contrib/externalSequenceProducer/README.md +14 -0
  108. data/vendor/zstd/contrib/externalSequenceProducer/main.c +108 -0
  109. data/vendor/zstd/contrib/externalSequenceProducer/sequence_producer.c +80 -0
  110. data/vendor/zstd/contrib/externalSequenceProducer/sequence_producer.h +26 -0
  111. data/vendor/zstd/contrib/freestanding_lib/freestanding.py +774 -0
  112. data/vendor/zstd/contrib/gen_html/Makefile +51 -0
  113. data/vendor/zstd/contrib/gen_html/README.md +31 -0
  114. data/vendor/zstd/contrib/gen_html/gen-zstd-manual.sh +9 -0
  115. data/vendor/zstd/contrib/gen_html/gen_html.cpp +225 -0
  116. data/vendor/zstd/contrib/largeNbDicts/Makefile +58 -0
  117. data/vendor/zstd/contrib/largeNbDicts/README.md +33 -0
  118. data/vendor/zstd/contrib/largeNbDicts/largeNbDicts.c +1087 -0
  119. data/vendor/zstd/contrib/linux-kernel/Makefile +108 -0
  120. data/vendor/zstd/contrib/linux-kernel/README.md +14 -0
  121. data/vendor/zstd/contrib/linux-kernel/btrfs-benchmark.sh +104 -0
  122. data/vendor/zstd/contrib/linux-kernel/btrfs-extract-benchmark.sh +99 -0
  123. data/vendor/zstd/contrib/linux-kernel/decompress_sources.h +34 -0
  124. data/vendor/zstd/contrib/linux-kernel/linux.mk +44 -0
  125. data/vendor/zstd/contrib/linux-kernel/linux_zstd.h +691 -0
  126. data/vendor/zstd/contrib/linux-kernel/mem.h +262 -0
  127. data/vendor/zstd/contrib/linux-kernel/squashfs-benchmark.sh +39 -0
  128. data/vendor/zstd/contrib/linux-kernel/test/Makefile +49 -0
  129. data/vendor/zstd/contrib/linux-kernel/test/include/linux/compiler.h +23 -0
  130. data/vendor/zstd/contrib/linux-kernel/test/include/linux/errno.h +15 -0
  131. data/vendor/zstd/contrib/linux-kernel/test/include/linux/kernel.h +19 -0
  132. data/vendor/zstd/contrib/linux-kernel/test/include/linux/limits.h +15 -0
  133. data/vendor/zstd/contrib/linux-kernel/test/include/linux/math64.h +15 -0
  134. data/vendor/zstd/contrib/linux-kernel/test/include/linux/module.h +20 -0
  135. data/vendor/zstd/contrib/linux-kernel/test/include/linux/printk.h +15 -0
  136. data/vendor/zstd/contrib/linux-kernel/test/include/linux/stddef.h +15 -0
  137. data/vendor/zstd/contrib/linux-kernel/test/include/linux/swab.h +16 -0
  138. data/vendor/zstd/contrib/linux-kernel/test/include/linux/types.h +16 -0
  139. data/vendor/zstd/contrib/linux-kernel/test/include/linux/unaligned.h +187 -0
  140. data/vendor/zstd/contrib/linux-kernel/test/include/linux/xxhash.h +745 -0
  141. data/vendor/zstd/contrib/linux-kernel/test/macro-test.sh +44 -0
  142. data/vendor/zstd/contrib/linux-kernel/test/static_test.c +52 -0
  143. data/vendor/zstd/contrib/linux-kernel/test/test.c +229 -0
  144. data/vendor/zstd/contrib/linux-kernel/zstd_common_module.c +29 -0
  145. data/vendor/zstd/contrib/linux-kernel/zstd_compress_module.c +286 -0
  146. data/vendor/zstd/contrib/linux-kernel/zstd_decompress_module.c +141 -0
  147. data/vendor/zstd/contrib/linux-kernel/zstd_deps.h +121 -0
  148. data/vendor/zstd/contrib/match_finders/README.md +42 -0
  149. data/vendor/zstd/contrib/match_finders/zstd_edist.c +558 -0
  150. data/vendor/zstd/contrib/match_finders/zstd_edist.h +70 -0
  151. data/vendor/zstd/contrib/premake/premake4.lua +6 -0
  152. data/vendor/zstd/contrib/premake/zstd.lua +81 -0
  153. data/vendor/zstd/contrib/pzstd/BUCK +72 -0
  154. data/vendor/zstd/contrib/pzstd/ErrorHolder.h +54 -0
  155. data/vendor/zstd/contrib/pzstd/Logging.h +73 -0
  156. data/vendor/zstd/contrib/pzstd/Makefile +265 -0
  157. data/vendor/zstd/contrib/pzstd/Options.cpp +424 -0
  158. data/vendor/zstd/contrib/pzstd/Options.h +71 -0
  159. data/vendor/zstd/contrib/pzstd/Pzstd.cpp +626 -0
  160. data/vendor/zstd/contrib/pzstd/Pzstd.h +153 -0
  161. data/vendor/zstd/contrib/pzstd/README.md +56 -0
  162. data/vendor/zstd/contrib/pzstd/SkippableFrame.cpp +30 -0
  163. data/vendor/zstd/contrib/pzstd/SkippableFrame.h +64 -0
  164. data/vendor/zstd/contrib/pzstd/images/Cspeed.png +0 -0
  165. data/vendor/zstd/contrib/pzstd/images/Dspeed.png +0 -0
  166. data/vendor/zstd/contrib/pzstd/main.cpp +27 -0
  167. data/vendor/zstd/contrib/pzstd/test/BUCK +37 -0
  168. data/vendor/zstd/contrib/pzstd/test/OptionsTest.cpp +536 -0
  169. data/vendor/zstd/contrib/pzstd/test/PzstdTest.cpp +147 -0
  170. data/vendor/zstd/contrib/pzstd/test/RoundTrip.h +86 -0
  171. data/vendor/zstd/contrib/pzstd/test/RoundTripTest.cpp +84 -0
  172. data/vendor/zstd/contrib/pzstd/utils/BUCK +75 -0
  173. data/vendor/zstd/contrib/pzstd/utils/Buffer.h +99 -0
  174. data/vendor/zstd/contrib/pzstd/utils/FileSystem.h +96 -0
  175. data/vendor/zstd/contrib/pzstd/utils/Likely.h +28 -0
  176. data/vendor/zstd/contrib/pzstd/utils/Portability.h +16 -0
  177. data/vendor/zstd/contrib/pzstd/utils/Range.h +133 -0
  178. data/vendor/zstd/contrib/pzstd/utils/ResourcePool.h +96 -0
  179. data/vendor/zstd/contrib/pzstd/utils/ScopeGuard.h +50 -0
  180. data/vendor/zstd/contrib/pzstd/utils/ThreadPool.h +58 -0
  181. data/vendor/zstd/contrib/pzstd/utils/WorkQueue.h +182 -0
  182. data/vendor/zstd/contrib/pzstd/utils/test/BUCK +35 -0
  183. data/vendor/zstd/contrib/pzstd/utils/test/BufferTest.cpp +89 -0
  184. data/vendor/zstd/contrib/pzstd/utils/test/RangeTest.cpp +82 -0
  185. data/vendor/zstd/contrib/pzstd/utils/test/ResourcePoolTest.cpp +72 -0
  186. data/vendor/zstd/contrib/pzstd/utils/test/ScopeGuardTest.cpp +28 -0
  187. data/vendor/zstd/contrib/pzstd/utils/test/ThreadPoolTest.cpp +71 -0
  188. data/vendor/zstd/contrib/pzstd/utils/test/WorkQueueTest.cpp +282 -0
  189. data/vendor/zstd/contrib/recovery/Makefile +35 -0
  190. data/vendor/zstd/contrib/recovery/recover_directory.c +152 -0
  191. data/vendor/zstd/contrib/seekable_format/README.md +42 -0
  192. data/vendor/zstd/contrib/seekable_format/examples/Makefile +55 -0
  193. data/vendor/zstd/contrib/seekable_format/examples/parallel_compression.c +254 -0
  194. data/vendor/zstd/contrib/seekable_format/examples/parallel_processing.c +191 -0
  195. data/vendor/zstd/contrib/seekable_format/examples/seekable_compression.c +136 -0
  196. data/vendor/zstd/contrib/seekable_format/examples/seekable_decompression.c +141 -0
  197. data/vendor/zstd/contrib/seekable_format/examples/seekable_decompression_mem.c +147 -0
  198. data/vendor/zstd/contrib/seekable_format/tests/Makefile +58 -0
  199. data/vendor/zstd/contrib/seekable_format/tests/seekable_tests.c +375 -0
  200. data/vendor/zstd/contrib/seekable_format/zstd_seekable.h +226 -0
  201. data/vendor/zstd/contrib/seekable_format/zstd_seekable_compression_format.md +116 -0
  202. data/vendor/zstd/contrib/seekable_format/zstdseek_compress.c +365 -0
  203. data/vendor/zstd/contrib/seekable_format/zstdseek_decompress.c +600 -0
  204. data/vendor/zstd/contrib/seqBench/Makefile +58 -0
  205. data/vendor/zstd/contrib/seqBench/seqBench.c +53 -0
  206. data/vendor/zstd/contrib/snap/snapcraft.yaml +28 -0
  207. data/vendor/zstd/doc/README.md +26 -0
  208. data/vendor/zstd/doc/decompressor_errata.md +148 -0
  209. data/vendor/zstd/doc/decompressor_permissive.md +80 -0
  210. data/vendor/zstd/doc/educational_decoder/Makefile +62 -0
  211. data/vendor/zstd/doc/educational_decoder/README.md +36 -0
  212. data/vendor/zstd/doc/educational_decoder/harness.c +119 -0
  213. data/vendor/zstd/doc/educational_decoder/zstd_decompress.c +2323 -0
  214. data/vendor/zstd/doc/educational_decoder/zstd_decompress.h +61 -0
  215. data/vendor/zstd/doc/images/CSpeed2.png +0 -0
  216. data/vendor/zstd/doc/images/DCspeed5.png +0 -0
  217. data/vendor/zstd/doc/images/DSpeed3.png +0 -0
  218. data/vendor/zstd/doc/images/cdict_v136.png +0 -0
  219. data/vendor/zstd/doc/images/dict-cr.png +0 -0
  220. data/vendor/zstd/doc/images/dict-cs.png +0 -0
  221. data/vendor/zstd/doc/images/dict-ds.png +0 -0
  222. data/vendor/zstd/doc/images/zstd_cdict_v1_3_5.png +0 -0
  223. data/vendor/zstd/doc/images/zstd_logo86.png +0 -0
  224. data/vendor/zstd/doc/zstd_compression_format.md +1772 -0
  225. data/vendor/zstd/doc/zstd_manual.html +2244 -0
  226. data/vendor/zstd/examples/Makefile +93 -0
  227. data/vendor/zstd/examples/README.md +46 -0
  228. data/vendor/zstd/examples/common.h +246 -0
  229. data/vendor/zstd/examples/dictionary_compression.c +107 -0
  230. data/vendor/zstd/examples/dictionary_decompression.c +99 -0
  231. data/vendor/zstd/examples/multiple_simple_compression.c +116 -0
  232. data/vendor/zstd/examples/multiple_streaming_compression.c +133 -0
  233. data/vendor/zstd/examples/simple_compression.c +68 -0
  234. data/vendor/zstd/examples/simple_decompression.c +65 -0
  235. data/vendor/zstd/examples/streaming_compression.c +146 -0
  236. data/vendor/zstd/examples/streaming_compression_thread_pool.c +180 -0
  237. data/vendor/zstd/examples/streaming_decompression.c +100 -0
  238. data/vendor/zstd/examples/streaming_memory_usage.c +137 -0
  239. data/vendor/zstd/lib/BUCK +232 -0
  240. data/vendor/zstd/lib/Makefile +389 -0
  241. data/vendor/zstd/lib/README.md +267 -0
  242. data/vendor/zstd/lib/common/allocations.h +55 -0
  243. data/vendor/zstd/lib/common/bits.h +205 -0
  244. data/vendor/zstd/lib/common/bitstream.h +454 -0
  245. data/vendor/zstd/lib/common/compiler.h +482 -0
  246. data/vendor/zstd/lib/common/cpu.h +249 -0
  247. data/vendor/zstd/lib/common/debug.c +30 -0
  248. data/vendor/zstd/lib/common/debug.h +107 -0
  249. data/vendor/zstd/lib/common/debug.o +0 -0
  250. data/vendor/zstd/lib/common/entropy_common.c +340 -0
  251. data/vendor/zstd/lib/common/entropy_common.o +0 -0
  252. data/vendor/zstd/lib/common/error_private.c +64 -0
  253. data/vendor/zstd/lib/common/error_private.h +158 -0
  254. data/vendor/zstd/lib/common/error_private.o +0 -0
  255. data/vendor/zstd/lib/common/fse.h +625 -0
  256. data/vendor/zstd/lib/common/fse_decompress.c +315 -0
  257. data/vendor/zstd/lib/common/fse_decompress.o +0 -0
  258. data/vendor/zstd/lib/common/huf.h +277 -0
  259. data/vendor/zstd/lib/common/mem.h +422 -0
  260. data/vendor/zstd/lib/common/pool.c +371 -0
  261. data/vendor/zstd/lib/common/pool.h +81 -0
  262. data/vendor/zstd/lib/common/pool.o +0 -0
  263. data/vendor/zstd/lib/common/portability_macros.h +190 -0
  264. data/vendor/zstd/lib/common/threading.c +196 -0
  265. data/vendor/zstd/lib/common/threading.h +142 -0
  266. data/vendor/zstd/lib/common/threading.o +0 -0
  267. data/vendor/zstd/lib/common/xxhash.c +18 -0
  268. data/vendor/zstd/lib/common/xxhash.h +7094 -0
  269. data/vendor/zstd/lib/common/xxhash.o +0 -0
  270. data/vendor/zstd/lib/common/zstd_common.c +57 -0
  271. data/vendor/zstd/lib/common/zstd_common.o +0 -0
  272. data/vendor/zstd/lib/common/zstd_deps.h +123 -0
  273. data/vendor/zstd/lib/common/zstd_internal.h +326 -0
  274. data/vendor/zstd/lib/common/zstd_trace.h +156 -0
  275. data/vendor/zstd/lib/compress/clevels.h +134 -0
  276. data/vendor/zstd/lib/compress/fse_compress.c +625 -0
  277. data/vendor/zstd/lib/compress/fse_compress.o +0 -0
  278. data/vendor/zstd/lib/compress/hist.c +446 -0
  279. data/vendor/zstd/lib/compress/hist.h +86 -0
  280. data/vendor/zstd/lib/compress/hist.o +0 -0
  281. data/vendor/zstd/lib/compress/huf_compress.c +1465 -0
  282. data/vendor/zstd/lib/compress/huf_compress.o +0 -0
  283. data/vendor/zstd/lib/compress/zstd_compress.c +8362 -0
  284. data/vendor/zstd/lib/compress/zstd_compress.o +0 -0
  285. data/vendor/zstd/lib/compress/zstd_compress_internal.h +1636 -0
  286. data/vendor/zstd/lib/compress/zstd_compress_literals.c +235 -0
  287. data/vendor/zstd/lib/compress/zstd_compress_literals.h +39 -0
  288. data/vendor/zstd/lib/compress/zstd_compress_literals.o +0 -0
  289. data/vendor/zstd/lib/compress/zstd_compress_sequences.c +442 -0
  290. data/vendor/zstd/lib/compress/zstd_compress_sequences.h +55 -0
  291. data/vendor/zstd/lib/compress/zstd_compress_sequences.o +0 -0
  292. data/vendor/zstd/lib/compress/zstd_compress_superblock.c +688 -0
  293. data/vendor/zstd/lib/compress/zstd_compress_superblock.h +32 -0
  294. data/vendor/zstd/lib/compress/zstd_compress_superblock.o +0 -0
  295. data/vendor/zstd/lib/compress/zstd_cwksp.h +765 -0
  296. data/vendor/zstd/lib/compress/zstd_double_fast.c +778 -0
  297. data/vendor/zstd/lib/compress/zstd_double_fast.h +42 -0
  298. data/vendor/zstd/lib/compress/zstd_double_fast.o +0 -0
  299. data/vendor/zstd/lib/compress/zstd_fast.c +985 -0
  300. data/vendor/zstd/lib/compress/zstd_fast.h +30 -0
  301. data/vendor/zstd/lib/compress/zstd_fast.o +0 -0
  302. data/vendor/zstd/lib/compress/zstd_lazy.c +2243 -0
  303. data/vendor/zstd/lib/compress/zstd_lazy.h +193 -0
  304. data/vendor/zstd/lib/compress/zstd_lazy.o +0 -0
  305. data/vendor/zstd/lib/compress/zstd_ldm.c +745 -0
  306. data/vendor/zstd/lib/compress/zstd_ldm.h +109 -0
  307. data/vendor/zstd/lib/compress/zstd_ldm.o +0 -0
  308. data/vendor/zstd/lib/compress/zstd_ldm_geartab.h +106 -0
  309. data/vendor/zstd/lib/compress/zstd_opt.c +1572 -0
  310. data/vendor/zstd/lib/compress/zstd_opt.h +72 -0
  311. data/vendor/zstd/lib/compress/zstd_opt.o +0 -0
  312. data/vendor/zstd/lib/compress/zstd_preSplit.c +238 -0
  313. data/vendor/zstd/lib/compress/zstd_preSplit.h +33 -0
  314. data/vendor/zstd/lib/compress/zstd_preSplit.o +0 -0
  315. data/vendor/zstd/lib/compress/zstdmt_compress.c +1924 -0
  316. data/vendor/zstd/lib/compress/zstdmt_compress.h +102 -0
  317. data/vendor/zstd/lib/compress/zstdmt_compress.o +0 -0
  318. data/vendor/zstd/lib/decompress/huf_decompress.c +1953 -0
  319. data/vendor/zstd/lib/decompress/huf_decompress.o +0 -0
  320. data/vendor/zstd/lib/decompress/huf_decompress_amd64.S +766 -0
  321. data/vendor/zstd/lib/decompress/zstd_ddict.c +244 -0
  322. data/vendor/zstd/lib/decompress/zstd_ddict.h +44 -0
  323. data/vendor/zstd/lib/decompress/zstd_ddict.o +0 -0
  324. data/vendor/zstd/lib/decompress/zstd_decompress.c +2410 -0
  325. data/vendor/zstd/lib/decompress/zstd_decompress.o +0 -0
  326. data/vendor/zstd/lib/decompress/zstd_decompress_block.c +2311 -0
  327. data/vendor/zstd/lib/decompress/zstd_decompress_block.h +73 -0
  328. data/vendor/zstd/lib/decompress/zstd_decompress_block.o +0 -0
  329. data/vendor/zstd/lib/decompress/zstd_decompress_internal.h +240 -0
  330. data/vendor/zstd/lib/deprecated/zbuff.h +214 -0
  331. data/vendor/zstd/lib/deprecated/zbuff_common.c +26 -0
  332. data/vendor/zstd/lib/deprecated/zbuff_compress.c +167 -0
  333. data/vendor/zstd/lib/deprecated/zbuff_decompress.c +77 -0
  334. data/vendor/zstd/lib/dictBuilder/cover.c +1333 -0
  335. data/vendor/zstd/lib/dictBuilder/cover.h +152 -0
  336. data/vendor/zstd/lib/dictBuilder/divsufsort.c +1913 -0
  337. data/vendor/zstd/lib/dictBuilder/divsufsort.h +57 -0
  338. data/vendor/zstd/lib/dictBuilder/fastcover.c +765 -0
  339. data/vendor/zstd/lib/dictBuilder/zdict.c +1137 -0
  340. data/vendor/zstd/lib/dll/example/Makefile +48 -0
  341. data/vendor/zstd/lib/dll/example/README.md +63 -0
  342. data/vendor/zstd/lib/dll/example/build_package.bat +55 -0
  343. data/vendor/zstd/lib/dll/example/fullbench-dll.sln +25 -0
  344. data/vendor/zstd/lib/dll/example/fullbench-dll.vcxproj +181 -0
  345. data/vendor/zstd/lib/install_oses.mk +17 -0
  346. data/vendor/zstd/lib/legacy/zstd_legacy.h +452 -0
  347. data/vendor/zstd/lib/legacy/zstd_v01.c +2128 -0
  348. data/vendor/zstd/lib/legacy/zstd_v01.h +94 -0
  349. data/vendor/zstd/lib/legacy/zstd_v02.c +3465 -0
  350. data/vendor/zstd/lib/legacy/zstd_v02.h +93 -0
  351. data/vendor/zstd/lib/legacy/zstd_v03.c +3105 -0
  352. data/vendor/zstd/lib/legacy/zstd_v03.h +93 -0
  353. data/vendor/zstd/lib/legacy/zstd_v04.c +3598 -0
  354. data/vendor/zstd/lib/legacy/zstd_v04.h +142 -0
  355. data/vendor/zstd/lib/legacy/zstd_v05.c +4005 -0
  356. data/vendor/zstd/lib/legacy/zstd_v05.h +162 -0
  357. data/vendor/zstd/lib/legacy/zstd_v06.c +4110 -0
  358. data/vendor/zstd/lib/legacy/zstd_v06.h +172 -0
  359. data/vendor/zstd/lib/legacy/zstd_v07.c +4490 -0
  360. data/vendor/zstd/lib/legacy/zstd_v07.h +187 -0
  361. data/vendor/zstd/lib/libzstd.mk +238 -0
  362. data/vendor/zstd/lib/libzstd.pc.in +17 -0
  363. data/vendor/zstd/lib/module.modulemap +35 -0
  364. data/vendor/zstd/lib/zdict.h +481 -0
  365. data/vendor/zstd/lib/zstd.h +3209 -0
  366. data/vendor/zstd/lib/zstd_errors.h +107 -0
  367. data/vendor/zstd/programs/BUCK +44 -0
  368. data/vendor/zstd/programs/Makefile +445 -0
  369. data/vendor/zstd/programs/README.md +344 -0
  370. data/vendor/zstd/programs/benchfn.c +256 -0
  371. data/vendor/zstd/programs/benchfn.h +173 -0
  372. data/vendor/zstd/programs/benchzstd.c +1270 -0
  373. data/vendor/zstd/programs/benchzstd.h +191 -0
  374. data/vendor/zstd/programs/datagen.c +186 -0
  375. data/vendor/zstd/programs/datagen.h +38 -0
  376. data/vendor/zstd/programs/dibio.c +447 -0
  377. data/vendor/zstd/programs/dibio.h +39 -0
  378. data/vendor/zstd/programs/fileio.c +3717 -0
  379. data/vendor/zstd/programs/fileio.h +171 -0
  380. data/vendor/zstd/programs/fileio_asyncio.c +663 -0
  381. data/vendor/zstd/programs/fileio_asyncio.h +195 -0
  382. data/vendor/zstd/programs/fileio_common.h +121 -0
  383. data/vendor/zstd/programs/fileio_types.h +86 -0
  384. data/vendor/zstd/programs/lorem.c +285 -0
  385. data/vendor/zstd/programs/lorem.h +32 -0
  386. data/vendor/zstd/programs/platform.h +217 -0
  387. data/vendor/zstd/programs/timefn.c +170 -0
  388. data/vendor/zstd/programs/timefn.h +59 -0
  389. data/vendor/zstd/programs/util.c +1731 -0
  390. data/vendor/zstd/programs/util.h +364 -0
  391. data/vendor/zstd/programs/windres/verrsrc.h +17 -0
  392. data/vendor/zstd/programs/windres/zstd.rc +51 -0
  393. data/vendor/zstd/programs/windres/zstd32.res +0 -0
  394. data/vendor/zstd/programs/windres/zstd64.res +0 -0
  395. data/vendor/zstd/programs/zstd.1 +580 -0
  396. data/vendor/zstd/programs/zstd.1.md +714 -0
  397. data/vendor/zstd/programs/zstdcli.c +1675 -0
  398. data/vendor/zstd/programs/zstdcli_trace.c +173 -0
  399. data/vendor/zstd/programs/zstdcli_trace.h +24 -0
  400. data/vendor/zstd/programs/zstdgrep +134 -0
  401. data/vendor/zstd/programs/zstdgrep.1 +26 -0
  402. data/vendor/zstd/programs/zstdgrep.1.md +30 -0
  403. data/vendor/zstd/programs/zstdless +8 -0
  404. data/vendor/zstd/programs/zstdless.1 +14 -0
  405. data/vendor/zstd/programs/zstdless.1.md +16 -0
  406. data/vendor/zstd/tests/DEPRECATED-test-zstd-speed.py +378 -0
  407. data/vendor/zstd/tests/Makefile +485 -0
  408. data/vendor/zstd/tests/README.md +184 -0
  409. data/vendor/zstd/tests/automated_benchmarking.py +326 -0
  410. data/vendor/zstd/tests/checkTag.c +65 -0
  411. data/vendor/zstd/tests/check_size.py +31 -0
  412. data/vendor/zstd/tests/cli-tests/README.md +258 -0
  413. data/vendor/zstd/tests/cli-tests/basic/args.sh +10 -0
  414. data/vendor/zstd/tests/cli-tests/basic/args.sh.exit +1 -0
  415. data/vendor/zstd/tests/cli-tests/basic/args.sh.stderr.glob +28 -0
  416. data/vendor/zstd/tests/cli-tests/basic/help.sh +10 -0
  417. data/vendor/zstd/tests/cli-tests/basic/help.sh.stdout.glob +34 -0
  418. data/vendor/zstd/tests/cli-tests/basic/memlimit.sh +40 -0
  419. data/vendor/zstd/tests/cli-tests/basic/memlimit.sh.stderr.exact +13 -0
  420. data/vendor/zstd/tests/cli-tests/basic/memlimit.sh.stdout.exact +13 -0
  421. data/vendor/zstd/tests/cli-tests/basic/output_dir.sh +7 -0
  422. data/vendor/zstd/tests/cli-tests/basic/output_dir.sh.stderr.exact +2 -0
  423. data/vendor/zstd/tests/cli-tests/basic/output_dir.sh.stdout.exact +2 -0
  424. data/vendor/zstd/tests/cli-tests/basic/version.sh +6 -0
  425. data/vendor/zstd/tests/cli-tests/basic/version.sh.stdout.glob +2 -0
  426. data/vendor/zstd/tests/cli-tests/bin/cmp_size +44 -0
  427. data/vendor/zstd/tests/cli-tests/bin/datagen +3 -0
  428. data/vendor/zstd/tests/cli-tests/bin/die +4 -0
  429. data/vendor/zstd/tests/cli-tests/bin/println +2 -0
  430. data/vendor/zstd/tests/cli-tests/bin/unzstd +1 -0
  431. data/vendor/zstd/tests/cli-tests/bin/zstd +9 -0
  432. data/vendor/zstd/tests/cli-tests/bin/zstdcat +1 -0
  433. data/vendor/zstd/tests/cli-tests/bin/zstdgrep +2 -0
  434. data/vendor/zstd/tests/cli-tests/bin/zstdless +2 -0
  435. data/vendor/zstd/tests/cli-tests/cltools/setup +6 -0
  436. data/vendor/zstd/tests/cli-tests/cltools/zstdgrep.sh +8 -0
  437. data/vendor/zstd/tests/cli-tests/cltools/zstdgrep.sh.exit +1 -0
  438. data/vendor/zstd/tests/cli-tests/cltools/zstdgrep.sh.stderr.exact +1 -0
  439. data/vendor/zstd/tests/cli-tests/cltools/zstdgrep.sh.stdout.glob +4 -0
  440. data/vendor/zstd/tests/cli-tests/cltools/zstdless.sh +10 -0
  441. data/vendor/zstd/tests/cli-tests/cltools/zstdless.sh.stderr.exact +2 -0
  442. data/vendor/zstd/tests/cli-tests/cltools/zstdless.sh.stdout.glob +5 -0
  443. data/vendor/zstd/tests/cli-tests/common/format.sh +19 -0
  444. data/vendor/zstd/tests/cli-tests/common/mtime.sh +13 -0
  445. data/vendor/zstd/tests/cli-tests/common/permissions.sh +18 -0
  446. data/vendor/zstd/tests/cli-tests/common/platform.sh +47 -0
  447. data/vendor/zstd/tests/cli-tests/compression/adapt.sh +14 -0
  448. data/vendor/zstd/tests/cli-tests/compression/basic.sh +36 -0
  449. data/vendor/zstd/tests/cli-tests/compression/compress-literals.sh +10 -0
  450. data/vendor/zstd/tests/cli-tests/compression/format.sh +16 -0
  451. data/vendor/zstd/tests/cli-tests/compression/golden.sh +16 -0
  452. data/vendor/zstd/tests/cli-tests/compression/gzip-compat.sh +17 -0
  453. data/vendor/zstd/tests/cli-tests/compression/levels.sh +75 -0
  454. data/vendor/zstd/tests/cli-tests/compression/levels.sh.stderr.exact +80 -0
  455. data/vendor/zstd/tests/cli-tests/compression/long-distance-matcher.sh +7 -0
  456. data/vendor/zstd/tests/cli-tests/compression/multi-threaded.sh +22 -0
  457. data/vendor/zstd/tests/cli-tests/compression/multi-threaded.sh.stderr.exact +21 -0
  458. data/vendor/zstd/tests/cli-tests/compression/multiple-files.sh +21 -0
  459. data/vendor/zstd/tests/cli-tests/compression/multiple-files.sh.stdout.exact +12 -0
  460. data/vendor/zstd/tests/cli-tests/compression/row-match-finder.sh +7 -0
  461. data/vendor/zstd/tests/cli-tests/compression/setup +7 -0
  462. data/vendor/zstd/tests/cli-tests/compression/stream-size.sh +7 -0
  463. data/vendor/zstd/tests/cli-tests/compression/verbose-wlog.sh +11 -0
  464. data/vendor/zstd/tests/cli-tests/compression/verbose-wlog.sh.stderr.glob +5 -0
  465. data/vendor/zstd/tests/cli-tests/compression/verbose-wlog.sh.stdout.glob +5 -0
  466. data/vendor/zstd/tests/cli-tests/compression/window-resize.sh +9 -0
  467. data/vendor/zstd/tests/cli-tests/compression/window-resize.sh.stderr.ignore +0 -0
  468. data/vendor/zstd/tests/cli-tests/compression/window-resize.sh.stdout.glob +3 -0
  469. data/vendor/zstd/tests/cli-tests/decompression/detectErrors.sh +11 -0
  470. data/vendor/zstd/tests/cli-tests/decompression/golden.sh +7 -0
  471. data/vendor/zstd/tests/cli-tests/decompression/pass-through.sh +57 -0
  472. data/vendor/zstd/tests/cli-tests/decompression/pass-through.sh.stderr.exact +11 -0
  473. data/vendor/zstd/tests/cli-tests/decompression/pass-through.sh.stdout.exact +25 -0
  474. data/vendor/zstd/tests/cli-tests/determinism/basic.sh +36 -0
  475. data/vendor/zstd/tests/cli-tests/determinism/basic.sh.stderr.exact +0 -0
  476. data/vendor/zstd/tests/cli-tests/determinism/basic.sh.stdout.exact +880 -0
  477. data/vendor/zstd/tests/cli-tests/determinism/multithread.sh +45 -0
  478. data/vendor/zstd/tests/cli-tests/determinism/multithread.sh.stderr.exact +0 -0
  479. data/vendor/zstd/tests/cli-tests/determinism/multithread.sh.stdout.exact +260 -0
  480. data/vendor/zstd/tests/cli-tests/determinism/reuse.sh +44 -0
  481. data/vendor/zstd/tests/cli-tests/determinism/reuse.sh.stderr.exact +0 -0
  482. data/vendor/zstd/tests/cli-tests/determinism/reuse.sh.stdout.exact +19 -0
  483. data/vendor/zstd/tests/cli-tests/determinism/setup +5 -0
  484. data/vendor/zstd/tests/cli-tests/determinism/setup_once +30 -0
  485. data/vendor/zstd/tests/cli-tests/dict-builder/empty-input.sh +9 -0
  486. data/vendor/zstd/tests/cli-tests/dict-builder/empty-input.sh.stderr.exact +1 -0
  487. data/vendor/zstd/tests/cli-tests/dict-builder/no-inputs.sh +3 -0
  488. data/vendor/zstd/tests/cli-tests/dict-builder/no-inputs.sh.exit +1 -0
  489. data/vendor/zstd/tests/cli-tests/dict-builder/no-inputs.sh.stderr.exact +5 -0
  490. data/vendor/zstd/tests/cli-tests/dictionaries/dictionary-mismatch.sh +29 -0
  491. data/vendor/zstd/tests/cli-tests/dictionaries/dictionary-mismatch.sh.stderr.exact +7 -0
  492. data/vendor/zstd/tests/cli-tests/dictionaries/golden.sh +9 -0
  493. data/vendor/zstd/tests/cli-tests/dictionaries/setup +6 -0
  494. data/vendor/zstd/tests/cli-tests/dictionaries/setup_once +24 -0
  495. data/vendor/zstd/tests/cli-tests/file-handling/directory-mirror.sh +49 -0
  496. data/vendor/zstd/tests/cli-tests/file-handling/directory-mirror.sh.stderr.exact +0 -0
  497. data/vendor/zstd/tests/cli-tests/file-handling/directory-mirror.sh.stdout.exact +0 -0
  498. data/vendor/zstd/tests/cli-tests/file-stat/compress-file-to-dir-without-write-perm.sh +12 -0
  499. data/vendor/zstd/tests/cli-tests/file-stat/compress-file-to-dir-without-write-perm.sh.stderr.exact +30 -0
  500. data/vendor/zstd/tests/cli-tests/file-stat/compress-file-to-file.sh +9 -0
  501. data/vendor/zstd/tests/cli-tests/file-stat/compress-file-to-file.sh.stderr.glob +46 -0
  502. data/vendor/zstd/tests/cli-tests/file-stat/compress-file-to-stdout.sh +8 -0
  503. data/vendor/zstd/tests/cli-tests/file-stat/compress-file-to-stdout.sh.stderr.exact +24 -0
  504. data/vendor/zstd/tests/cli-tests/file-stat/compress-stdin-to-file.sh +8 -0
  505. data/vendor/zstd/tests/cli-tests/file-stat/compress-stdin-to-file.sh.stderr.glob +28 -0
  506. data/vendor/zstd/tests/cli-tests/file-stat/compress-stdin-to-stdout.sh +8 -0
  507. data/vendor/zstd/tests/cli-tests/file-stat/compress-stdin-to-stdout.sh.stderr.exact +18 -0
  508. data/vendor/zstd/tests/cli-tests/file-stat/decompress-file-to-file.sh +8 -0
  509. data/vendor/zstd/tests/cli-tests/file-stat/decompress-file-to-file.sh.stderr.glob +42 -0
  510. data/vendor/zstd/tests/cli-tests/file-stat/decompress-file-to-stdout.sh +7 -0
  511. data/vendor/zstd/tests/cli-tests/file-stat/decompress-file-to-stdout.sh.stderr.exact +18 -0
  512. data/vendor/zstd/tests/cli-tests/file-stat/decompress-stdin-to-file.sh +7 -0
  513. data/vendor/zstd/tests/cli-tests/file-stat/decompress-stdin-to-file.sh.stderr.glob +24 -0
  514. data/vendor/zstd/tests/cli-tests/file-stat/decompress-stdin-to-stdout.sh +7 -0
  515. data/vendor/zstd/tests/cli-tests/file-stat/decompress-stdin-to-stdout.sh.stderr.exact +14 -0
  516. data/vendor/zstd/tests/cli-tests/progress/no-progress.sh +46 -0
  517. data/vendor/zstd/tests/cli-tests/progress/no-progress.sh.stderr.glob +96 -0
  518. data/vendor/zstd/tests/cli-tests/progress/progress.sh +41 -0
  519. data/vendor/zstd/tests/cli-tests/progress/progress.sh.stderr.glob +62 -0
  520. data/vendor/zstd/tests/cli-tests/run.py +732 -0
  521. data/vendor/zstd/tests/cli-tests/zstd-symlinks/setup +6 -0
  522. data/vendor/zstd/tests/cli-tests/zstd-symlinks/zstdcat.sh +12 -0
  523. data/vendor/zstd/tests/cli-tests/zstd-symlinks/zstdcat.sh.stdout.exact +8 -0
  524. data/vendor/zstd/tests/datagencli.c +149 -0
  525. data/vendor/zstd/tests/decodecorpus.c +1998 -0
  526. data/vendor/zstd/tests/dict-files/zero-weight-dict +0 -0
  527. data/vendor/zstd/tests/external_matchfinder.c +140 -0
  528. data/vendor/zstd/tests/external_matchfinder.h +39 -0
  529. data/vendor/zstd/tests/fullbench.c +1210 -0
  530. data/vendor/zstd/tests/fuzz/Makefile +278 -0
  531. data/vendor/zstd/tests/fuzz/README.md +161 -0
  532. data/vendor/zstd/tests/fuzz/block_decompress.c +53 -0
  533. data/vendor/zstd/tests/fuzz/block_round_trip.c +103 -0
  534. data/vendor/zstd/tests/fuzz/decompress_cross_format.c +130 -0
  535. data/vendor/zstd/tests/fuzz/decompress_dstSize_tooSmall.c +74 -0
  536. data/vendor/zstd/tests/fuzz/dictionary_decompress.c +77 -0
  537. data/vendor/zstd/tests/fuzz/dictionary_loader.c +106 -0
  538. data/vendor/zstd/tests/fuzz/dictionary_round_trip.c +155 -0
  539. data/vendor/zstd/tests/fuzz/dictionary_stream_round_trip.c +209 -0
  540. data/vendor/zstd/tests/fuzz/fse_read_ncount.c +100 -0
  541. data/vendor/zstd/tests/fuzz/fuzz.h +57 -0
  542. data/vendor/zstd/tests/fuzz/fuzz.py +910 -0
  543. data/vendor/zstd/tests/fuzz/fuzz_data_producer.c +95 -0
  544. data/vendor/zstd/tests/fuzz/fuzz_data_producer.h +66 -0
  545. data/vendor/zstd/tests/fuzz/fuzz_helpers.c +47 -0
  546. data/vendor/zstd/tests/fuzz/fuzz_helpers.h +82 -0
  547. data/vendor/zstd/tests/fuzz/fuzz_third_party_seq_prod.h +116 -0
  548. data/vendor/zstd/tests/fuzz/generate_sequences.c +88 -0
  549. data/vendor/zstd/tests/fuzz/huf_decompress.c +68 -0
  550. data/vendor/zstd/tests/fuzz/huf_round_trip.c +137 -0
  551. data/vendor/zstd/tests/fuzz/raw_dictionary_round_trip.c +119 -0
  552. data/vendor/zstd/tests/fuzz/regression_driver.c +90 -0
  553. data/vendor/zstd/tests/fuzz/seekable_roundtrip.c +88 -0
  554. data/vendor/zstd/tests/fuzz/seq_prod_fuzz_example/Makefile +16 -0
  555. data/vendor/zstd/tests/fuzz/seq_prod_fuzz_example/README.md +12 -0
  556. data/vendor/zstd/tests/fuzz/seq_prod_fuzz_example/example_seq_prod.c +52 -0
  557. data/vendor/zstd/tests/fuzz/sequence_compression_api.c +452 -0
  558. data/vendor/zstd/tests/fuzz/simple_compress.c +60 -0
  559. data/vendor/zstd/tests/fuzz/simple_decompress.c +59 -0
  560. data/vendor/zstd/tests/fuzz/simple_round_trip.c +182 -0
  561. data/vendor/zstd/tests/fuzz/stream_decompress.c +119 -0
  562. data/vendor/zstd/tests/fuzz/stream_round_trip.c +218 -0
  563. data/vendor/zstd/tests/fuzz/zstd_frame_info.c +43 -0
  564. data/vendor/zstd/tests/fuzz/zstd_helpers.c +208 -0
  565. data/vendor/zstd/tests/fuzz/zstd_helpers.h +56 -0
  566. data/vendor/zstd/tests/fuzzer.c +5482 -0
  567. data/vendor/zstd/tests/golden-compression/PR-3517-block-splitter-corruption-test +1 -0
  568. data/vendor/zstd/tests/golden-compression/http +1 -0
  569. data/vendor/zstd/tests/golden-compression/huffman-compressed-larger +0 -0
  570. data/vendor/zstd/tests/golden-compression/large-literal-and-match-lengths +0 -0
  571. data/vendor/zstd/tests/golden-decompression/block-128k.zst +0 -0
  572. data/vendor/zstd/tests/golden-decompression/empty-block.zst +0 -0
  573. data/vendor/zstd/tests/golden-decompression/rle-first-block.zst +0 -0
  574. data/vendor/zstd/tests/golden-decompression/zeroSeq_2B.zst +0 -0
  575. data/vendor/zstd/tests/golden-decompression-errors/off0.bin.zst +0 -0
  576. data/vendor/zstd/tests/golden-decompression-errors/truncated_huff_state.zst +0 -0
  577. data/vendor/zstd/tests/golden-decompression-errors/zeroSeq_extraneous.zst +0 -0
  578. data/vendor/zstd/tests/golden-dictionaries/http-dict-missing-symbols +0 -0
  579. data/vendor/zstd/tests/gzip/Makefile +45 -0
  580. data/vendor/zstd/tests/gzip/gzip-env.sh +46 -0
  581. data/vendor/zstd/tests/gzip/helin-segv.sh +31 -0
  582. data/vendor/zstd/tests/gzip/help-version.sh +270 -0
  583. data/vendor/zstd/tests/gzip/hufts-segv.gz +0 -0
  584. data/vendor/zstd/tests/gzip/hufts.sh +34 -0
  585. data/vendor/zstd/tests/gzip/init.cfg +5 -0
  586. data/vendor/zstd/tests/gzip/init.sh +616 -0
  587. data/vendor/zstd/tests/gzip/keep.sh +51 -0
  588. data/vendor/zstd/tests/gzip/list.sh +31 -0
  589. data/vendor/zstd/tests/gzip/memcpy-abuse.sh +34 -0
  590. data/vendor/zstd/tests/gzip/mixed.sh +68 -0
  591. data/vendor/zstd/tests/gzip/null-suffix-clobber.sh +35 -0
  592. data/vendor/zstd/tests/gzip/stdin.sh +31 -0
  593. data/vendor/zstd/tests/gzip/test-driver.sh +150 -0
  594. data/vendor/zstd/tests/gzip/trailing-nul.sh +37 -0
  595. data/vendor/zstd/tests/gzip/unpack-invalid.sh +36 -0
  596. data/vendor/zstd/tests/gzip/z-suffix.sh +30 -0
  597. data/vendor/zstd/tests/gzip/zdiff.sh +48 -0
  598. data/vendor/zstd/tests/gzip/zgrep-context.sh +47 -0
  599. data/vendor/zstd/tests/gzip/zgrep-f.sh +43 -0
  600. data/vendor/zstd/tests/gzip/zgrep-signal.sh +64 -0
  601. data/vendor/zstd/tests/gzip/znew-k.sh +40 -0
  602. data/vendor/zstd/tests/invalidDictionaries.c +61 -0
  603. data/vendor/zstd/tests/largeDictionary.c +131 -0
  604. data/vendor/zstd/tests/legacy.c +262 -0
  605. data/vendor/zstd/tests/libzstd_builds.sh +104 -0
  606. data/vendor/zstd/tests/longmatch.c +123 -0
  607. data/vendor/zstd/tests/loremOut.c +50 -0
  608. data/vendor/zstd/tests/loremOut.h +15 -0
  609. data/vendor/zstd/tests/paramgrill.c +2965 -0
  610. data/vendor/zstd/tests/playTests.sh +1926 -0
  611. data/vendor/zstd/tests/poolTests.c +271 -0
  612. data/vendor/zstd/tests/rateLimiter.py +41 -0
  613. data/vendor/zstd/tests/regression/Makefile +60 -0
  614. data/vendor/zstd/tests/regression/README.md +28 -0
  615. data/vendor/zstd/tests/regression/config.c +404 -0
  616. data/vendor/zstd/tests/regression/config.h +91 -0
  617. data/vendor/zstd/tests/regression/data.c +631 -0
  618. data/vendor/zstd/tests/regression/data.h +121 -0
  619. data/vendor/zstd/tests/regression/levels.h +59 -0
  620. data/vendor/zstd/tests/regression/method.c +701 -0
  621. data/vendor/zstd/tests/regression/method.h +65 -0
  622. data/vendor/zstd/tests/regression/result.c +30 -0
  623. data/vendor/zstd/tests/regression/result.h +103 -0
  624. data/vendor/zstd/tests/regression/results.csv +1480 -0
  625. data/vendor/zstd/tests/regression/test.c +362 -0
  626. data/vendor/zstd/tests/roundTripCrash.c +241 -0
  627. data/vendor/zstd/tests/seqgen.c +260 -0
  628. data/vendor/zstd/tests/seqgen.h +58 -0
  629. data/vendor/zstd/tests/test-license.py +156 -0
  630. data/vendor/zstd/tests/test-variants.sh +115 -0
  631. data/vendor/zstd/tests/test-zstd-versions.py +308 -0
  632. data/vendor/zstd/tests/test_process_substitution.bash +92 -0
  633. data/vendor/zstd/tests/zstreamtest.c +3467 -0
  634. data/vendor/zstd/zlibWrapper/BUCK +22 -0
  635. data/vendor/zstd/zlibWrapper/Makefile +120 -0
  636. data/vendor/zstd/zlibWrapper/README.md +163 -0
  637. data/vendor/zstd/zlibWrapper/examples/example.c +598 -0
  638. data/vendor/zstd/zlibWrapper/examples/example_original.c +599 -0
  639. data/vendor/zstd/zlibWrapper/examples/fitblk.c +254 -0
  640. data/vendor/zstd/zlibWrapper/examples/fitblk_original.c +233 -0
  641. data/vendor/zstd/zlibWrapper/examples/minigzip.c +605 -0
  642. data/vendor/zstd/zlibWrapper/examples/zwrapbench.c +1018 -0
  643. data/vendor/zstd/zlibWrapper/gzclose.c +26 -0
  644. data/vendor/zstd/zlibWrapper/gzcompatibility.h +68 -0
  645. data/vendor/zstd/zlibWrapper/gzguts.h +229 -0
  646. data/vendor/zstd/zlibWrapper/gzlib.c +587 -0
  647. data/vendor/zstd/zlibWrapper/gzread.c +637 -0
  648. data/vendor/zstd/zlibWrapper/gzwrite.c +632 -0
  649. data/vendor/zstd/zlibWrapper/zstd_zlibwrapper.c +1200 -0
  650. data/vendor/zstd/zlibWrapper/zstd_zlibwrapper.h +91 -0
  651. metadata +738 -0
@@ -0,0 +1,1926 @@
1
+ #!/bin/sh
2
+
3
+ set -e # exit immediately on error
4
+ set -x # print commands before execution (debug)
5
+
6
+ unset ZSTD_CLEVEL
7
+ unset ZSTD_NBTHREADS
8
+
9
+
10
+ die() {
11
+ println "$@" 1>&2
12
+ exit 1
13
+ }
14
+
15
+ datagen() {
16
+ "$DATAGEN_BIN" "$@"
17
+ }
18
+
19
+ alias zstd='$EXE_PREFIX $ZSTD_BIN'
20
+
21
+ sudoZstd() {
22
+ if [ -z "$EXE_PREFIX" ]; then
23
+ sudo "$ZSTD_BIN" "$@"
24
+ else
25
+ sudo "$EXE_PREFIX" "$ZSTD_BIN" "$@"
26
+ fi
27
+ }
28
+
29
+ roundTripTest() {
30
+ if [ -n "$3" ]; then
31
+ cLevel="$3"
32
+ proba="$2"
33
+ else
34
+ cLevel="$2"
35
+ proba=""
36
+ fi
37
+ if [ -n "$4" ]; then
38
+ dLevel="$4"
39
+ else
40
+ dLevel="$cLevel"
41
+ fi
42
+
43
+ rm -f tmp1 tmp2
44
+ println "roundTripTest: datagen $1 $proba | zstd -v$cLevel | zstd -d$dLevel"
45
+ datagen $1 $proba | $MD5SUM > tmp1
46
+ datagen $1 $proba | zstd -T0 --ultra -v$cLevel | zstd -d$dLevel | $MD5SUM > tmp2
47
+ $DIFF -q tmp1 tmp2
48
+ }
49
+
50
+ fileRoundTripTest() {
51
+ if [ -n "$3" ]; then
52
+ local_c="$3"
53
+ local_p="$2"
54
+ else
55
+ local_c="$2"
56
+ local_p=""
57
+ fi
58
+ if [ -n "$4" ]; then
59
+ local_d="$4"
60
+ else
61
+ local_d="$local_c"
62
+ fi
63
+
64
+ rm -f tmp.zst tmp.md5.1 tmp.md5.2
65
+ println "fileRoundTripTest: datagen $1 $local_p > tmp && zstd -v$local_c -c tmp | zstd -d$local_d"
66
+ datagen $1 $local_p > tmp
67
+ < tmp $MD5SUM > tmp.md5.1
68
+ zstd -T0 --ultra -v$local_c -c tmp | zstd -d$local_d | $MD5SUM > tmp.md5.2
69
+ $DIFF -q tmp.md5.1 tmp.md5.2
70
+ }
71
+
72
+ truncateLastByte() {
73
+ dd bs=1 count=$(($(wc -c < "$1") - 1)) if="$1"
74
+ }
75
+
76
+ println() {
77
+ printf '%b\n' "${*}"
78
+ }
79
+
80
+ if [ -z "${size}" ]; then
81
+ size=
82
+ else
83
+ size=${size}
84
+ fi
85
+
86
+ SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
87
+ PRGDIR="$SCRIPT_DIR/../programs"
88
+ TESTDIR="$SCRIPT_DIR/../tests"
89
+ UNAME=${UNAME:-$(uname)}
90
+ GREP=${GREP:-grep}
91
+
92
+ case "$UNAME" in
93
+ SunOS) DIFF=${DIFF:-gdiff} ;;
94
+ *) DIFF=${DIFF:-diff} ;;
95
+ esac
96
+
97
+ detectedTerminal=false
98
+ if [ -t 0 ] && [ -t 1 ]
99
+ then
100
+ detectedTerminal=true
101
+ fi
102
+ isTerminal=${isTerminal:-$detectedTerminal}
103
+
104
+ isWindows=false
105
+ INTOVOID="/dev/null"
106
+ DEVDEVICE="/dev/zero"
107
+ case "$OS" in
108
+ Windows*)
109
+ isWindows=true
110
+ INTOVOID="NUL"
111
+ DEVDEVICE="NUL"
112
+ ;;
113
+ esac
114
+
115
+ case "$UNAME" in
116
+ Darwin) MD5SUM="md5 -r" ;;
117
+ NetBSD) MD5SUM="md5 -n" ;;
118
+ OpenBSD) MD5SUM="md5" ;;
119
+ *) MD5SUM="md5sum" ;;
120
+ esac
121
+
122
+ MTIME="stat -c %Y"
123
+ case "$UNAME" in
124
+ Darwin | FreeBSD | OpenBSD | NetBSD) MTIME="stat -f %m" ;;
125
+ esac
126
+
127
+ assertSameMTime() {
128
+ MT1=$($MTIME "$1")
129
+ MT2=$($MTIME "$2")
130
+ echo MTIME $MT1 $MT2
131
+ [ "$MT1" = "$MT2" ] || die "mtime on $1 doesn't match mtime on $2 ($MT1 != $MT2)"
132
+ }
133
+
134
+ GET_PERMS="stat -c %a"
135
+ case "$UNAME" in
136
+ Darwin | FreeBSD | OpenBSD | NetBSD) GET_PERMS="stat -f %Lp" ;;
137
+ esac
138
+
139
+ assertFilePermissions() {
140
+ STAT1=$($GET_PERMS "$1")
141
+ STAT2=$2
142
+ [ "$STAT1" = "$STAT2" ] || die "permissions on $1 don't match expected ($STAT1 != $STAT2)"
143
+ }
144
+
145
+ assertSamePermissions() {
146
+ STAT1=$($GET_PERMS "$1")
147
+ STAT2=$($GET_PERMS "$2")
148
+ [ "$STAT1" = "$STAT2" ] || die "permissions on $1 don't match those on $2 ($STAT1 != $STAT2)"
149
+ }
150
+
151
+
152
+ # check if ZSTD_BIN is defined. if not, use the default value
153
+ if [ -z "${ZSTD_BIN}" ]; then
154
+ println "\nZSTD_BIN is not set. Using the default value..."
155
+ ZSTD_BIN="$PRGDIR/zstd"
156
+ fi
157
+
158
+ # check if DATAGEN_BIN is defined. if not, use the default value
159
+ if [ -z "${DATAGEN_BIN}" ]; then
160
+ println "\nDATAGEN_BIN is not set. Using the default value..."
161
+ DATAGEN_BIN="$TESTDIR/datagen"
162
+ fi
163
+
164
+ # Why was this line here ? Generates a strange ZSTD_BIN when EXE_PREFIX is non empty
165
+ # ZSTD_BIN="$EXE_PREFIX$ZSTD_BIN"
166
+
167
+ # assertions
168
+ [ -n "$ZSTD_BIN" ] || die "zstd not found at $ZSTD_BIN! \n Please define ZSTD_BIN pointing to the zstd binary. You might also consider rebuilding zstd following the instructions in README.md"
169
+ [ -n "$DATAGEN_BIN" ] || die "datagen not found at $DATAGEN_BIN! \n Please define DATAGEN_BIN pointing to the datagen binary. You might also consider rebuilding zstd tests following the instructions in README.md. "
170
+ println "\nStarting playTests.sh isWindows=$isWindows EXE_PREFIX='$EXE_PREFIX' ZSTD_BIN='$ZSTD_BIN' DATAGEN_BIN='$DATAGEN_BIN'"
171
+
172
+ if echo hello | zstd -v -T2 2>&1 > $INTOVOID | $GREP -q 'multi-threading is disabled'
173
+ then
174
+ hasMT=""
175
+ else
176
+ hasMT="true"
177
+ fi
178
+
179
+
180
+ zstd -vvV
181
+
182
+ println "\n===> simple tests "
183
+
184
+ datagen > tmp
185
+ zstd -h
186
+ zstd -H
187
+ zstd -V
188
+ println "test : basic compression "
189
+ zstd -f tmp # trivial compression case, creates tmp.zst
190
+ zstd -f -z tmp
191
+ zstd -f -k tmp
192
+ zstd -f -C tmp
193
+ println "test : basic decompression"
194
+ zstd -df tmp.zst # trivial decompression case (overwrites tmp)
195
+ println "test : too large compression level => auto-fix"
196
+ zstd -99 -f tmp # too large compression level, automatic sized down
197
+ zstd -5000000000 -f tmp && die "too large numeric value : must fail"
198
+ println "test : --fast aka negative compression levels"
199
+ zstd --fast -f tmp # == -1
200
+ zstd --fast=3 -f tmp # == -3
201
+ zstd --fast=200000 -f tmp # too low compression level, automatic fixed
202
+ zstd --fast=5000000000 -f tmp && die "too large numeric value : must fail"
203
+ zstd -c --fast=0 tmp > $INTOVOID && die "--fast must not accept value 0"
204
+ println "test : too large numeric argument"
205
+ zstd --fast=9999999999 -f tmp && die "should have refused numeric value"
206
+ println "test : set compression level with environment variable ZSTD_CLEVEL"
207
+
208
+ ZSTD_CLEVEL=12 zstd -f tmp # positive compression level
209
+ ZSTD_CLEVEL=-12 zstd -f tmp # negative compression level
210
+ ZSTD_CLEVEL=+12 zstd -f tmp # valid: verbose '+' sign
211
+ ZSTD_CLEVEL='' zstd -f tmp # empty env var, warn and revert to default setting
212
+ ZSTD_CLEVEL=- zstd -f tmp # malformed env var, warn and revert to default setting
213
+ ZSTD_CLEVEL=a zstd -f tmp # malformed env var, warn and revert to default setting
214
+ ZSTD_CLEVEL=+a zstd -f tmp # malformed env var, warn and revert to default setting
215
+ ZSTD_CLEVEL=3a7 zstd -f tmp # malformed env var, warn and revert to default setting
216
+ ZSTD_CLEVEL=50000000000 zstd -f tmp # numeric value too large, warn and revert to default setting
217
+ println "test : override ZSTD_CLEVEL with command line option"
218
+ ZSTD_CLEVEL=12 zstd --fast=3 -f tmp # overridden by command line option
219
+
220
+ # temporary envvar changes in the above tests would actually persist in macos /bin/sh
221
+ unset ZSTD_CLEVEL
222
+
223
+
224
+ println "test : compress to stdout"
225
+ zstd tmp -c > tmpCompressed
226
+ zstd tmp --stdout > tmpCompressed # long command format
227
+
228
+ println "test : compress to named file (-o)"
229
+ rm -f tmpCompressed
230
+ zstd tmp -o tmpCompressed
231
+ test -f tmpCompressed # file must be created
232
+
233
+ println "test : force write, correct order"
234
+ zstd tmp -fo tmpCompressed
235
+
236
+ println "test : -c + -o : last one wins"
237
+ rm -f tmpOut
238
+ zstd tmp -c > tmpCompressed -o tmpOut
239
+ test -f tmpOut # file must be created
240
+ rm -f tmpCompressed
241
+ zstd tmp -o tmpOut -c > tmpCompressed
242
+ test -f tmpCompressed # file must be created
243
+
244
+ println "test : forgotten argument"
245
+ cp tmp tmp2
246
+ zstd tmp2 -fo && die "-o must be followed by filename "
247
+ println "test : implied stdout when input is stdin"
248
+ println bob | zstd | zstd -d
249
+ if [ "$isTerminal" = true ]; then
250
+ println "test : compressed data to terminal"
251
+ println bob | zstd && die "should have refused : compressed data to terminal"
252
+ println "test : compressed data from terminal (a hang here is a test fail, zstd is wrongly waiting on data from terminal)"
253
+ zstd -d > $INTOVOID && die "should have refused : compressed data from terminal"
254
+ fi
255
+ println "test : null-length file roundtrip"
256
+ println -n '' | zstd - --stdout | zstd -d --stdout
257
+ println "test : ensure small file doesn't add 3-bytes null block"
258
+ datagen -g1 > tmp1
259
+ zstd tmp1 -c | wc -c | $GREP "14"
260
+ zstd < tmp1 | wc -c | $GREP "14"
261
+ println "test : decompress file with wrong suffix (must fail)"
262
+ zstd -d tmpCompressed && die "wrong suffix error not detected!"
263
+ zstd -df tmp && die "should have refused : wrong extension"
264
+ println "test : decompress into stdout"
265
+ zstd -d tmpCompressed -c > tmpResult # decompression using stdout
266
+ zstd --decompress tmpCompressed -c > tmpResult
267
+ zstd --decompress tmpCompressed --stdout > tmpResult
268
+ println "test : decompress from stdin into stdout"
269
+ zstd -dc < tmp.zst > $INTOVOID # combine decompression, stdin & stdout
270
+ zstd -dc - < tmp.zst > $INTOVOID
271
+ zstd -d < tmp.zst > $INTOVOID # implicit stdout when stdin is used
272
+ zstd -d - < tmp.zst > $INTOVOID
273
+ println "test : impose memory limitation (must fail)"
274
+ datagen -g500K > tmplimit
275
+ zstd -f tmplimit
276
+ zstd -d -f tmplimit.zst -M2K -c > $INTOVOID && die "decompression needs more memory than allowed"
277
+ zstd -d -f tmplimit.zst --memlimit=2K -c > $INTOVOID && die "decompression needs more memory than allowed" # long command
278
+ zstd -d -f tmplimit.zst --memory=2K -c > $INTOVOID && die "decompression needs more memory than allowed" # long command
279
+ zstd -d -f tmplimit.zst --memlimit-decompress=2K -c > $INTOVOID && die "decompression needs more memory than allowed" # long command
280
+ rm -f tmplimit tmplimit.zst
281
+ println "test : overwrite protection"
282
+ zstd -q tmp && die "overwrite check failed!"
283
+ println "test : force overwrite"
284
+ zstd -q -f tmp
285
+ zstd -q --force tmp
286
+ println "test : overwrite readonly file"
287
+ rm -f tmpro tmpro.zst
288
+ println foo > tmpro.zst
289
+ println foo > tmpro
290
+ chmod 400 tmpro.zst
291
+ zstd -q tmpro && die "should have refused to overwrite read-only file"
292
+ zstd -q -f tmpro
293
+ println "test: --no-progress flag"
294
+ zstd tmpro -c --no-progress | zstd -d -f -o "$INTOVOID" --no-progress
295
+ zstd tmpro -cv --no-progress | zstd -dv -f -o "$INTOVOID" --no-progress
296
+ println "test: --progress flag"
297
+ zstd tmpro -c | zstd -d -f -o "$INTOVOID" --progress 2>&1 | $GREP '[A-Za-z0-9._ ]*: [0-9]* bytes'
298
+ zstd tmpro -c | zstd -d -f -q -o "$INTOVOID" --progress 2>&1 | $GREP '[A-Za-z0-9._ ]*: [0-9]* bytes'
299
+ zstd tmpro -c | zstd -d -f -v -o "$INTOVOID" 2>&1 | $GREP '[A-Za-z0-9._ ]*: [0-9]* bytes'
300
+ rm -f tmpro tmpro.zst
301
+ println "test: overwrite input file (must fail)"
302
+ zstd tmp -fo tmp && die "zstd compression overwrote the input file"
303
+ zstd tmp.zst -dfo tmp.zst && die "zstd decompression overwrote the input file"
304
+ println "test: detect that input file does not exist"
305
+ zstd nothere && die "zstd hasn't detected that input file does not exist"
306
+ println "test: --[no-]compress-literals"
307
+ zstd tmp -c --no-compress-literals -1 | zstd -t
308
+ zstd tmp -c --no-compress-literals --fast=1 | zstd -t
309
+ zstd tmp -c --no-compress-literals -19 | zstd -t
310
+ zstd tmp -c --compress-literals -1 | zstd -t
311
+ zstd tmp -c --compress-literals --fast=1 | zstd -t
312
+ zstd tmp -c --compress-literals -19 | zstd -t
313
+ zstd -b --fast=1 -i0e1 tmp --compress-literals
314
+ zstd -b --fast=1 -i0e1 tmp --no-compress-literals
315
+ println "test: --no-check for decompression"
316
+ zstd -f tmp -o tmp_corrupt.zst --check
317
+ zstd -f tmp -o tmp.zst --no-check
318
+ printf '\xDE\xAD\xBE\xEF' | dd of=tmp_corrupt.zst bs=1 seek=$(($(wc -c < "tmp_corrupt.zst") - 4)) count=4 conv=notrunc # corrupt checksum in tmp
319
+ zstd -d -f tmp_corrupt.zst --no-check
320
+ zstd -d -f tmp_corrupt.zst --check --no-check # final flag overrides
321
+ zstd -d -f tmp.zst --no-check
322
+
323
+ if [ "$isWindows" = false ] && [ "$UNAME" != "AIX" ]; then
324
+ if [ -n "$(which readelf)" ]; then
325
+ println "test: check if binary has executable stack (#2963)"
326
+ readelf -lW "$ZSTD_BIN" | $GREP 'GNU_STACK .* RW ' || die "zstd binary has executable stack!"
327
+ fi
328
+ fi
329
+
330
+ println "\n===> multiple_thread test "
331
+
332
+ datagen > tmp
333
+ println "test : single-thread "
334
+ zstd --fast --single-thread tmp -o tmpMT0
335
+ println "test : one worker thread (default)"
336
+ zstd --fast -T1 tmp -o tmpMT1
337
+ println "test : two worker threads "
338
+ zstd --fast -T2 tmp -o tmpMT2
339
+ println "test : 16-thread "
340
+ zstd --fast -T16 tmp -o tmpMT3
341
+ println "test : 127-thread "
342
+ zstd --fast -T127 tmp -o tmpMT4
343
+ println "test : 128-thread "
344
+ zstd --fast -T128 tmp -o tmpMT5
345
+ println "test : max allowed numeric value is 4294967295 "
346
+ zstd --fast -4294967295 tmp -o tmpMT6
347
+ println "test : numeric value overflows 32-bit unsigned int "
348
+ zstd --fast -4294967296 tmp -o tmptest9 && die "max allowed numeric value is 4294967295"
349
+
350
+ datagen > tmp
351
+ println "test : basic compression "
352
+ zstd -f tmp # trivial compression case, creates tmp.zst
353
+ println "test : basic decompression"
354
+ zstd -d -f -T1 tmp.zst
355
+ println "note : decompression does not support -T mode, but execution support"
356
+ rm -rf tmpMT*
357
+
358
+ println "\n===> --fast_argument test "
359
+ datagen > tmp
360
+ println "test : basic compression "
361
+ zstd -f tmp # trivial compression case, creates tmp.zst
362
+ println "test: --fast=1"
363
+ zstd --fast=1 -f tmp
364
+ println "test: --fast=99"
365
+ zstd --fast=99 -f tmp
366
+ println "test: Invalid value -- negative number"
367
+ zstd --fast=-1 -f tmp && die "error: Invalid value -- negative number"
368
+ println "test: Invalid value -- zero"
369
+ zstd --fast=0 -f tmp && die "error: Invalid value -- 0 number"
370
+ println "test: max allowed numeric argument of --fast is 4294967295"
371
+ zstd --fast=4294967295 -f tmp
372
+ println "test: numeric value overflows 32-bit unsigned int "
373
+ zstd --fast=4294967296 -f tmp && die "max allowed argument of --fast is 4294967295"
374
+
375
+ println "\n===> --exclude-compressed flag"
376
+ rm -rf precompressedFilterTestDir
377
+ mkdir -p precompressedFilterTestDir
378
+ datagen $size > precompressedFilterTestDir/input.5
379
+ datagen $size > precompressedFilterTestDir/input.6
380
+ zstd --exclude-compressed --long --rm -r precompressedFilterTestDir
381
+ datagen $size > precompressedFilterTestDir/input.7
382
+ datagen $size > precompressedFilterTestDir/input.8
383
+ zstd --exclude-compressed --long --rm -r precompressedFilterTestDir
384
+ test ! -f precompressedFilterTestDir/input.5.zst.zst
385
+ test ! -f precompressedFilterTestDir/input.6.zst.zst
386
+ file1timestamp=`$MTIME precompressedFilterTestDir/input.5.zst`
387
+ file2timestamp=`$MTIME precompressedFilterTestDir/input.7.zst`
388
+ if [ $file2timestamp -ge $file1timestamp ]; then
389
+ println "Test is successful. input.5.zst is precompressed and therefore not compressed/modified again."
390
+ else
391
+ println "Test is not successful"
392
+ fi
393
+ # File Extension check.
394
+ datagen $size > precompressedFilterTestDir/input.zstbar
395
+ zstd --exclude-compressed --long --rm -r precompressedFilterTestDir
396
+ # zstd should compress input.zstbar
397
+ test -f precompressedFilterTestDir/input.zstbar.zst
398
+ # Check without the --exclude-compressed flag
399
+ zstd --long --rm -r precompressedFilterTestDir
400
+ # Files should get compressed again without the --exclude-compressed flag.
401
+ test -f precompressedFilterTestDir/input.5.zst.zst
402
+ test -f precompressedFilterTestDir/input.6.zst.zst
403
+
404
+ # Test some other compressed file extensions
405
+ datagen $size > precompressedFilterTestDir/input.flac
406
+ datagen $size > precompressedFilterTestDir/input.mov
407
+ datagen $size > precompressedFilterTestDir/input.mp3
408
+ zstd --exclude-compressed --long --rm -r precompressedFilterTestDir
409
+ test ! -f precompressedFilterTestDir/input.flac.zst
410
+ test ! -f precompressedFilterTestDir/input.mov.zst
411
+ test ! -f precompressedFilterTestDir/input.mp3.zst
412
+ zstd --long --rm -r precompressedFilterTestDir
413
+ test -f precompressedFilterTestDir/input.flac.zst
414
+ test -f precompressedFilterTestDir/input.mov.zst
415
+ test -f precompressedFilterTestDir/input.mp3.zst
416
+ rm -rf precompressedFilterTestDir
417
+ println "Test completed"
418
+
419
+
420
+
421
+ println "\n===> warning prompts should not occur if stdin is an input"
422
+ println "y" > tmpPrompt
423
+ println "hello world" >> tmpPrompt
424
+ zstd tmpPrompt -f
425
+ zstd < tmpPrompt -o tmpPrompt.zst && die "should have aborted immediately and failed to overwrite"
426
+ zstd < tmpPrompt -o tmpPrompt.zst -f # should successfully overwrite with -f
427
+ zstd -q -d -f tmpPrompt.zst -o tmpPromptRegenerated
428
+ $DIFF tmpPromptRegenerated tmpPrompt # the first 'y' character should not be swallowed
429
+
430
+ echo 'yes' | zstd tmpPrompt -v -o tmpPrompt.zst # accept piped "y" input to force overwrite when using files
431
+ echo 'yes' | zstd < tmpPrompt -v -o tmpPrompt.zst && die "should have aborted immediately and failed to overwrite"
432
+ zstd tmpPrompt - < tmpPrompt -o tmpPromp.zst --rm && die "should have aborted immediately and failed to remove"
433
+
434
+ println "Test completed"
435
+
436
+
437
+ println "\n===> recursive mode test "
438
+ # combination of -r with empty list of input file
439
+ zstd -c -r < tmp > tmp.zst
440
+
441
+ # combination of -r with empty folder
442
+ mkdir -p tmpEmptyDir
443
+ zstd -r tmpEmptyDir
444
+ rm -rf tmpEmptyDir
445
+
446
+
447
+ println "\n===> file removal"
448
+ zstd -f --rm tmp
449
+ test ! -f tmp # tmp should no longer be present
450
+ zstd -f -d --rm tmp.zst
451
+ test ! -f tmp.zst # tmp.zst should no longer be present
452
+ println "test: --rm is disabled when output is stdout"
453
+ test -f tmp
454
+ zstd --rm tmp -c > $INTOVOID
455
+ test -f tmp # tmp shall still be there
456
+ zstd --rm tmp --stdout > $INTOVOID
457
+ test -f tmp # tmp shall still be there
458
+ zstd -f --rm tmp -c > $INTOVOID
459
+ test -f tmp # tmp shall still be there
460
+ zstd -f tmp -c > $INTOVOID --rm
461
+ test -f tmp # tmp shall still be there
462
+ println "test: --rm is disabled when multiple inputs are concatenated into a single output"
463
+ cp tmp tmp2
464
+ zstd --rm tmp tmp2 -c > $INTOVOID
465
+ test -f tmp
466
+ test -f tmp2
467
+ rm -f tmp3.zst
468
+ echo 'y' | zstd -v tmp tmp2 -o tmp3.zst --rm # prompt for confirmation
469
+ test -f tmp
470
+ test -f tmp2
471
+ zstd -f tmp tmp2 -o tmp3.zst --rm # just warns, no prompt
472
+ test -f tmp
473
+ test -f tmp2
474
+ zstd -q tmp tmp2 -o tmp3.zst --rm && die "should refuse to concatenate"
475
+ println "test: --rm is active with -o when single input"
476
+ rm -f tmp2.zst
477
+ zstd --rm tmp2 -o tmp2.zst
478
+ test -f tmp2.zst
479
+ test ! -f tmp2
480
+ println "test: -c followed by -o => -o wins, so --rm remains active" # (#3719)
481
+ rm tmp2.zst
482
+ cp tmp tmp2
483
+ zstd --rm tmp2 -c > $INTOVOID -o tmp2.zst
484
+ test ! -f tmp2
485
+ println "test: -o followed by -c => -c wins, so --rm is disabled" # (#3719)
486
+ rm tmp3.zst
487
+ cp tmp tmp2
488
+ zstd -v --rm tmp2 -o tmp2.zst -c > tmp3.zst
489
+ test -f tmp2
490
+ test -f tmp3.zst
491
+ println "test : should quietly not remove non-regular file"
492
+ println hello > tmp
493
+ zstd tmp -f -o "$DEVDEVICE" 2>tmplog > "$INTOVOID"
494
+ $GREP "Refusing to remove non-regular file" tmplog && die
495
+ rm -f tmplog
496
+ zstd tmp -f -o "$INTOVOID" 2>&1 | $GREP "Refusing to remove non-regular file" && die
497
+ println "test : --rm on stdin"
498
+ println a | zstd --rm > $INTOVOID # --rm should remain silent
499
+ rm -f tmp
500
+ zstd -f tmp && die "tmp not present : should have failed"
501
+ test ! -f tmp.zst # tmp.zst should not be created
502
+ println "test : -d -f do not delete destination when source is not present"
503
+ touch tmp # create destination file
504
+ zstd -d -f tmp.zst && die "attempt to decompress a non existing file"
505
+ test -f tmp # destination file should still be present
506
+ println "test : -f do not delete destination when source is not present"
507
+ rm -f tmp # erase source file
508
+ touch tmp.zst # create destination file
509
+ zstd -f tmp && die "attempt to compress a non existing file"
510
+ test -f tmp.zst # destination file should still be present
511
+ rm -rf tmp* # may also erase tmp* directory from previous failed run
512
+
513
+
514
+ println "\n===> decompression only tests "
515
+ # the following test verifies that the decoder is compatible with RLE as first block
516
+ # older versions of zstd cli are not able to decode such corner case.
517
+ # As a consequence, the zstd cli do not generate them, to maintain compatibility with older versions.
518
+ dd bs=1048576 count=1 if=/dev/zero of=tmp
519
+ zstd -d -o tmp1 "$TESTDIR/golden-decompression/rle-first-block.zst"
520
+ $DIFF -s tmp1 tmp
521
+
522
+ touch tmp_empty
523
+ zstd -d -o tmp2 "$TESTDIR/golden-decompression/empty-block.zst"
524
+ $DIFF -s tmp2 tmp_empty
525
+
526
+ zstd -t "$TESTDIR/golden-decompression/zeroSeq_2B.zst"
527
+
528
+ zstd -t "$TESTDIR/golden-decompression-errors/zeroSeq_extraneous.zst" && die "invalid Sequences section should have been detected"
529
+
530
+ rm -f tmp*
531
+
532
+ println "\n===> compress multiple files"
533
+ println hello > tmp1
534
+ println world > tmp2
535
+ zstd tmp1 tmp2 -o "$INTOVOID" -f
536
+ zstd tmp1 tmp2 -c | zstd -t
537
+ echo 'y' | zstd -v tmp1 tmp2 -o tmp.zst
538
+ test ! -f tmp1.zst
539
+ test ! -f tmp2.zst
540
+ zstd tmp1 tmp2
541
+ zstd -t tmp1.zst tmp2.zst
542
+ zstd -dc tmp1.zst tmp2.zst
543
+ zstd tmp1.zst tmp2.zst -o "$INTOVOID" -f
544
+ echo 'y' | zstd -v -d tmp1.zst tmp2.zst -o tmp
545
+ touch tmpexists
546
+ zstd tmp1 tmp2 -f -o tmpexists
547
+ zstd tmp1 tmp2 -q -o tmpexists && die "should have refused to overwrite"
548
+ println gooder > tmp_rm1
549
+ println boi > tmp_rm2
550
+ println worldly > tmp_rm3
551
+ echo 'y' | zstd -v tmp_rm1 tmp_rm2 -v -o tmp_rm3.zst
552
+ test -f tmp_rm1
553
+ test -f tmp_rm2
554
+ cp tmp_rm3.zst tmp_rm4.zst
555
+ echo 'Y' | zstd -v -d tmp_rm3.zst tmp_rm4.zst -v -o tmp_rm_out --rm
556
+ test -f tmp_rm3.zst
557
+ test -f tmp_rm4.zst
558
+ println gooder > tmpexists1
559
+ zstd tmpexists1 tmpexists -c --rm -f > $INTOVOID
560
+ # Bug: PR #972
561
+ if [ "$?" -eq 139 ]; then
562
+ die "should not have segfaulted"
563
+ fi
564
+ test -f tmpexists1
565
+ test -f tmpexists
566
+ println "\n===> multiple files and shell completion "
567
+ datagen -s1 > tmp1 2> $INTOVOID
568
+ datagen -s2 -g100K > tmp2 2> $INTOVOID
569
+ datagen -s3 -g1M > tmp3 2> $INTOVOID
570
+ println "compress tmp* : "
571
+ zstd -f tmp*
572
+ test -f tmp1.zst
573
+ test -f tmp2.zst
574
+ test -f tmp3.zst
575
+ rm -f tmp1 tmp2 tmp3
576
+ println "decompress tmp* : "
577
+ zstd -df ./*.zst
578
+ test -f tmp1
579
+ test -f tmp2
580
+ test -f tmp3
581
+ println "compress tmp* into stdout > tmpall : "
582
+ zstd -c tmp1 tmp2 tmp3 > tmpall
583
+ test -f tmpall # should check size of tmpall (should be tmp1.zst + tmp2.zst + tmp3.zst)
584
+ println "decompress tmpall* into stdout > tmpdec : "
585
+ cp tmpall tmpall2
586
+ zstd -dc tmpall* > tmpdec
587
+ test -f tmpdec # should check size of tmpdec (should be 2*(tmp1 + tmp2 + tmp3))
588
+ println "compress multiple files including a missing one (notHere) : "
589
+ zstd -f tmp1 notHere tmp2 && die "missing file not detected!"
590
+ rm -f tmp*
591
+
592
+
593
+ if [ "$isWindows" = false ] ; then
594
+ println "\n===> zstd fifo named pipe test "
595
+ echo "Hello World!" > tmp_original
596
+ mkfifo tmp_named_pipe
597
+ # note : fifo test doesn't work in combination with `dd` or `cat`
598
+ echo "Hello World!" > tmp_named_pipe &
599
+ zstd tmp_named_pipe -o tmp_compressed
600
+ zstd -d -o tmp_decompressed tmp_compressed
601
+ $DIFF -s tmp_original tmp_decompressed
602
+ rm -rf tmp*
603
+ fi
604
+
605
+ println "\n===> zstd created file permissions tests"
606
+ if [ "$isWindows" = false ] ; then
607
+ rm -f tmp1 tmp2 tmp1.zst tmp2.zst tmp1.out tmp2.out # todo: remove
608
+
609
+ ORIGINAL_UMASK=$(umask)
610
+ umask 0000
611
+
612
+ datagen > tmp1
613
+ datagen > tmp2
614
+ assertFilePermissions tmp1 666
615
+ assertFilePermissions tmp2 666
616
+
617
+ println "test : copy 666 permissions in file -> file compression "
618
+ zstd -f tmp1 -o tmp1.zst
619
+ assertSamePermissions tmp1 tmp1.zst
620
+ println "test : copy 666 permissions in file -> file decompression "
621
+ zstd -f -d tmp1.zst -o tmp1.out
622
+ assertSamePermissions tmp1.zst tmp1.out
623
+
624
+ rm -f tmp1.zst tmp1.out
625
+
626
+ println "test : copy 400 permissions in file -> file compression (write to a read-only file) "
627
+ chmod 0400 tmp1
628
+ assertFilePermissions tmp1 400
629
+ zstd -f tmp1 -o tmp1.zst
630
+ assertSamePermissions tmp1 tmp1.zst
631
+ println "test : copy 400 permissions in file -> file decompression (write to a read-only file) "
632
+ zstd -f -d tmp1.zst -o tmp1
633
+ assertSamePermissions tmp1.zst tmp1
634
+
635
+ rm -f tmp1.zst tmp1.out
636
+
637
+ println "test : check created permissions from stdin input in compression "
638
+ zstd -f -o tmp1.zst < tmp1
639
+ assertFilePermissions tmp1.zst 666
640
+ println "test : check created permissions from stdin input in decompression "
641
+ zstd -f -d -o tmp1.out < tmp1.zst
642
+ assertFilePermissions tmp1.out 666
643
+
644
+ rm -f tmp1.zst tmp1.out
645
+
646
+ println "test : check created permissions from multiple inputs in compression "
647
+ zstd -f tmp1 tmp2 -o tmp1.zst
648
+ assertFilePermissions tmp1.zst 666
649
+ println "test : check created permissions from multiple inputs in decompression "
650
+ cp tmp1.zst tmp2.zst
651
+ zstd -f -d tmp1.zst tmp2.zst -o tmp1.out
652
+ assertFilePermissions tmp1.out 666
653
+
654
+ rm -f tmp1.zst tmp2.zst tmp1.out tmp2.out
655
+
656
+ println "test : check permissions on pre-existing output file in compression "
657
+ chmod 0600 tmp1
658
+ touch tmp1.zst
659
+ chmod 0400 tmp1.zst
660
+ zstd -f tmp1 -o tmp1.zst
661
+ assertFilePermissions tmp1.zst 600
662
+ println "test : check permissions on pre-existing output file in decompression "
663
+ chmod 0400 tmp1.zst
664
+ touch tmp1.out
665
+ chmod 0200 tmp1.out
666
+ zstd -f -d tmp1.zst -o tmp1.out
667
+ assertFilePermissions tmp1.out 400
668
+
669
+ umask 0666
670
+ chmod 0666 tmp1 tmp2
671
+
672
+ rm -f tmp1.zst tmp1.out
673
+
674
+ println "test : respect umask when compressing from stdin input "
675
+ zstd -f -o tmp1.zst < tmp1
676
+ assertFilePermissions tmp1.zst 0
677
+ println "test : respect umask when decompressing from stdin input "
678
+ chmod 0666 tmp1.zst
679
+ zstd -f -d -o tmp1.out < tmp1.zst
680
+ assertFilePermissions tmp1.out 0
681
+
682
+ rm -f tmp1 tmp2 tmp1.zst tmp2.zst tmp1.out tmp2.out
683
+ umask $ORIGINAL_UMASK
684
+ fi
685
+
686
+ if [ -n "$DEVNULLRIGHTS" ] ; then
687
+ # these tests requires sudo rights, which is uncommon.
688
+ # they are only triggered if DEVNULLRIGHTS macro is defined.
689
+ println "\n===> checking /dev/null permissions are unaltered "
690
+ datagen > tmp
691
+ sudoZstd tmp -o $INTOVOID # sudo rights could modify /dev/null permissions
692
+ sudoZstd tmp -c > $INTOVOID
693
+ zstd tmp -f -o tmp.zst
694
+ sudoZstd -d tmp.zst -c > $INTOVOID
695
+ sudoZstd -d tmp.zst -o $INTOVOID
696
+ ls -las $INTOVOID | $GREP "rw-rw-rw-"
697
+ fi
698
+
699
+ if [ -n "$READFROMBLOCKDEVICE" ] ; then
700
+ # This creates a temporary block device, which is only possible on unix-y
701
+ # systems, is somewhat invasive, and requires sudo. For these reasons, you
702
+ # have to specifically ask for this test.
703
+ println "\n===> checking that zstd can read from a block device"
704
+ datagen -g65536 > tmp.img
705
+ sudo losetup -fP tmp.img
706
+ LOOP_DEV=$(losetup -a | $GREP 'tmp\.img' | cut -f1 -d:)
707
+ [ -z "$LOOP_DEV" ] && die "failed to get loopback device"
708
+ sudoZstd $LOOP_DEV -c > tmp.img.zst && die "should fail without -f"
709
+ sudoZstd -f $LOOP_DEV -c > tmp.img.zst
710
+ zstd -d tmp.img.zst -o tmp.img.copy
711
+ sudo losetup -d $LOOP_DEV
712
+ $DIFF -s tmp.img tmp.img.copy || die "round trip failed"
713
+ rm -f tmp.img tmp.img.zst tmp.img.copy
714
+ fi
715
+
716
+ println "\n===> zstd created file timestamp tests"
717
+ datagen > tmp
718
+ touch -m -t 200001010000.00 tmp
719
+ println "test : copy mtime in file -> file compression "
720
+ zstd -f tmp -o tmp.zst
721
+ assertSameMTime tmp tmp.zst
722
+ println "test : copy mtime in file -> file decompression "
723
+ zstd -f -d tmp.zst -o tmp.out
724
+ assertSameMTime tmp.zst tmp.out
725
+ rm -f tmp
726
+
727
+ println "\n===> compress multiple files into an output directory, --output-dir-flat"
728
+ println henlo > tmp1
729
+ mkdir tmpInputTestDir
730
+ mkdir tmpInputTestDir/we
731
+ mkdir tmpInputTestDir/we/must
732
+ mkdir tmpInputTestDir/we/must/go
733
+ mkdir tmpInputTestDir/we/must/go/deeper
734
+ println cool > tmpInputTestDir/we/must/go/deeper/tmp2
735
+ mkdir tmpOutDir
736
+ zstd tmp1 tmpInputTestDir/we/must/go/deeper/tmp2 --output-dir-flat tmpOutDir
737
+ test -f tmpOutDir/tmp1.zst
738
+ test -f tmpOutDir/tmp2.zst
739
+ println "test : decompress multiple files into an output directory, --output-dir-flat"
740
+ mkdir tmpOutDirDecomp
741
+ zstd tmpOutDir -r -d --output-dir-flat tmpOutDirDecomp
742
+ test -f tmpOutDirDecomp/tmp2
743
+ test -f tmpOutDirDecomp/tmp1
744
+ rm -f tmpOutDirDecomp/*
745
+ zstd tmpOutDir -r -d --output-dir-flat=tmpOutDirDecomp
746
+ test -f tmpOutDirDecomp/tmp2
747
+ test -f tmpOutDirDecomp/tmp1
748
+ rm -rf tmp*
749
+
750
+ if [ "$isWindows" = false ] ; then
751
+ println "\n===> compress multiple files into an output directory and mirror input folder, --output-dir-mirror"
752
+ println "test --output-dir-mirror" > tmp1
753
+ mkdir -p tmpInputTestDir/we/.../..must/go/deeper..
754
+ println cool > tmpInputTestDir/we/.../..must/go/deeper../tmp2
755
+ zstd tmp1 -r tmpInputTestDir --output-dir-mirror tmpOutDir
756
+ test -f tmpOutDir/tmp1.zst
757
+ test -f tmpOutDir/tmpInputTestDir/we/.../..must/go/deeper../tmp2.zst
758
+
759
+ println "test: compress input dir will be ignored if it has '..'"
760
+ zstd -r tmpInputTestDir/we/.../..must/../..mustgo/deeper.. --output-dir-mirror non-exist && die "input cannot contain '..'"
761
+ zstd -r tmpInputTestDir/we/.../..must/deeper../.. --output-dir-mirror non-exist && die "input cannot contain '..'"
762
+ zstd -r ../tests/tmpInputTestDir/we/.../..must/deeper.. --output-dir-mirror non-exist && die "input cannot contain '..'"
763
+ test ! -d non-exist
764
+
765
+ println "test: compress input dir should succeed with benign uses of '..'"
766
+ zstd -r tmpInputTestDir/we/.../..must/go/deeper.. --output-dir-mirror tmpout
767
+ test -d tmpout
768
+
769
+ println "test : decompress multiple files into an output directory, --output-dir-mirror"
770
+ zstd tmpOutDir -r -d --output-dir-mirror tmpOutDirDecomp
771
+ test -f tmpOutDirDecomp/tmpOutDir/tmp1
772
+ test -f tmpOutDirDecomp/tmpOutDir/tmpInputTestDir/we/.../..must/go/deeper../tmp2
773
+
774
+ println "test: decompress input dir will be ignored if it has '..'"
775
+ zstd -r tmpOutDir/tmpInputTestDir/we/.../..must/../..must --output-dir-mirror non-exist && die "input cannot contain '..'"
776
+ test ! -d non-exist
777
+
778
+ rm -rf tmp*
779
+ fi
780
+
781
+
782
+ println "test : compress multiple files reading them from a file, --filelist=FILE"
783
+ println "Hello world!, file1" > tmp1
784
+ println "Hello world!, file2" > tmp2
785
+ println tmp1 > tmp_fileList
786
+ println tmp2 >> tmp_fileList
787
+ zstd -f --filelist=tmp_fileList
788
+ test -f tmp2.zst
789
+ test -f tmp1.zst
790
+
791
+ println "test : alternate syntax: --filelist FILE"
792
+ zstd -f --filelist tmp_fileList
793
+ test -f tmp2.zst
794
+ test -f tmp1.zst
795
+
796
+ println "test : reading file list from a symlink, --filelist=FILE"
797
+ rm -f *.zst
798
+ ln -s tmp_fileList tmp_symLink
799
+ zstd -f --filelist=tmp_symLink
800
+ test -f tmp2.zst
801
+ test -f tmp1.zst
802
+
803
+ println "test : compress multiple files reading them from multiple files, --filelist=FILE"
804
+ rm -f *.zst
805
+ println "Hello world!, file3" > tmp3
806
+ println "Hello world!, file4" > tmp4
807
+ println tmp3 > tmp_fileList2
808
+ println tmp4 >> tmp_fileList2
809
+ zstd -f --filelist=tmp_fileList --filelist=tmp_fileList2
810
+ test -f tmp1.zst
811
+ test -f tmp2.zst
812
+ test -f tmp3.zst
813
+ test -f tmp4.zst
814
+
815
+ println "test : decompress multiple files reading them from a file, --filelist=FILE"
816
+ rm -f tmp1 tmp2
817
+ println tmp1.zst > tmpZst
818
+ println tmp2.zst >> tmpZst
819
+ zstd -d -f --filelist=tmpZst
820
+ test -f tmp1
821
+ test -f tmp2
822
+
823
+ println "test : decompress multiple files reading them from multiple files, --filelist=FILE"
824
+ rm -f tmp1 tmp2 tmp3 tmp4
825
+ println tmp3.zst > tmpZst2
826
+ println tmp4.zst >> tmpZst2
827
+ zstd -d -f --filelist=tmpZst --filelist=tmpZst2
828
+ test -f tmp1
829
+ test -f tmp2
830
+ test -f tmp3
831
+ test -f tmp4
832
+
833
+ println "test : survive the list of files with too long filenames (--filelist=FILE)"
834
+ datagen -g5M > tmp_badList
835
+ zstd -qq -f --filelist=tmp_badList && die "should have failed : file name length is too long" # printing very long text garbage on console will cause CI failure
836
+
837
+ println "test : survive a list of files which is text garbage (--filelist=FILE)"
838
+ datagen > tmp_badList
839
+ zstd -qq -f --filelist=tmp_badList && die "should have failed : list is text garbage" # printing very long text garbage on console will cause CI failure
840
+
841
+ println "test : survive a list of files which is binary garbage (--filelist=FILE)"
842
+ datagen -P0 -g1M > tmp_badList
843
+ zstd -qq -f --filelist=tmp_badList && die "should have failed : list is binary garbage" # let's avoid printing binary garbage on console
844
+
845
+ println "test : try to overflow internal list of files (--filelist=FILE)"
846
+ touch tmp1 tmp2 tmp3 tmp4 tmp5 tmp6
847
+ ls tmp* > tmpList
848
+ zstd -f tmp1 --filelist=tmpList --filelist=tmpList tmp2 tmp3 # can trigger an overflow of internal file list
849
+ rm -rf tmp*
850
+
851
+
852
+ println "\n===> --[no-]content-size tests"
853
+
854
+ datagen > tmp_contentsize
855
+ zstd -f tmp_contentsize
856
+ zstd -lv tmp_contentsize.zst | $GREP "Decompressed Size:"
857
+ zstd -f --no-content-size tmp_contentsize
858
+ zstd -lv tmp_contentsize.zst | $GREP "Decompressed Size:" && die
859
+ zstd -f --content-size tmp_contentsize
860
+ zstd -lv tmp_contentsize.zst | $GREP "Decompressed Size:"
861
+ zstd -f --content-size --no-content-size tmp_contentsize
862
+ zstd -lv tmp_contentsize.zst | $GREP "Decompressed Size:" && die
863
+ rm -rf tmp*
864
+
865
+ println "test : show-default-cparams regular"
866
+ datagen > tmp
867
+ zstd --show-default-cparams -f tmp
868
+ zstd --show-default-cparams -d tmp.zst && die "error: can't use --show-default-cparams in decompression mode"
869
+ rm -rf tmp*
870
+
871
+ println "test : show-default-cparams recursive"
872
+ mkdir tmp_files
873
+ datagen -g15000 > tmp_files/tmp1
874
+ datagen -g129000 > tmp_files/tmp2
875
+ datagen -g257000 > tmp_files/tmp3
876
+ zstd --show-default-cparams -f -r tmp_files
877
+ rm -rf tmp*
878
+
879
+ println "test : show compression parameters in verbose mode"
880
+ datagen > tmp
881
+ zstd -vv tmp 2>&1 | \
882
+ $GREP -q -- "--zstd=wlog=[0-9]*,clog=[0-9]*,hlog=[0-9]*,slog=[0-9]*,mml=[0-9]*,tlen=[0-9]*,strat=[0-9]*"
883
+ rm -rf tmp*
884
+
885
+ println "\n===> Advanced compression parameters "
886
+ println "Hello world!" | zstd --zstd=windowLog=21, - -o tmp.zst && die "wrong parameters not detected!"
887
+ println "Hello world!" | zstd --zstd=windowLo=21 - -o tmp.zst && die "wrong parameters not detected!"
888
+ println "Hello world!" | zstd --zstd=windowLog=21,slog - -o tmp.zst && die "wrong parameters not detected!"
889
+ println "Hello world!" | zstd --zstd=strategy=10 - -o tmp.zst && die "parameter out of bound not detected!" # > btultra2 : does not exist
890
+ test ! -f tmp.zst # tmp.zst should not be created
891
+ roundTripTest -g512K
892
+ roundTripTest -g512K " --zstd=mml=3,tlen=48,strat=6"
893
+ roundTripTest -g512K " --zstd=strat=6,wlog=23,clog=23,hlog=22,slog=6"
894
+ roundTripTest -g512K " --zstd=windowLog=23,chainLog=23,hashLog=22,searchLog=6,minMatch=3,targetLength=48,strategy=6"
895
+ roundTripTest -g512K " --single-thread --long --zstd=ldmHashLog=20,ldmMinMatch=64,ldmBucketSizeLog=1,ldmHashRateLog=7"
896
+ roundTripTest -g512K " --single-thread --long --zstd=lhlog=20,lmml=64,lblog=1,lhrlog=7"
897
+ roundTripTest -g64K "19 --zstd=strat=9" # btultra2
898
+
899
+
900
+ println "\n===> Pass-Through mode "
901
+ println "Hello world 1!" | zstd -df
902
+ println "Hello world 2!" | zstd -dcf
903
+ println "Hello world 3!" > tmp1
904
+ zstd -dcf tmp1
905
+ println "" | zstd -df > tmp1
906
+ println "" > tmp2
907
+ $DIFF -q tmp1 tmp2
908
+ println "1" | zstd -df > tmp1
909
+ println "1" > tmp2
910
+ $DIFF -q tmp1 tmp2
911
+ println "12" | zstd -df > tmp1
912
+ println "12" > tmp2
913
+ $DIFF -q tmp1 tmp2
914
+ rm -rf tmp*
915
+
916
+
917
+ println "\n===> frame concatenation "
918
+ println "hello " > hello.tmp
919
+ println "world!" > world.tmp
920
+ cat hello.tmp world.tmp > helloworld.tmp
921
+ zstd -c hello.tmp > hello.zst
922
+ zstd -c world.tmp > world.zst
923
+ zstd -c hello.tmp world.tmp > helloworld.zst
924
+ zstd -dc helloworld.zst > result.tmp
925
+ $DIFF helloworld.tmp result.tmp
926
+ cat hello.zst world.zst > helloworld.zst
927
+ zstd -dc helloworld.zst > result.tmp
928
+ cat result.tmp
929
+ $DIFF helloworld.tmp result.tmp
930
+ println "frame concatenation without checksum"
931
+ zstd -c hello.tmp > hello.zst --no-check
932
+ zstd -c world.tmp > world.zst --no-check
933
+ cat hello.zst world.zst > helloworld.zstd
934
+ zstd -dc helloworld.zst > result.tmp
935
+ $DIFF helloworld.tmp result.tmp
936
+ println "testing zstdcat symlink"
937
+ ln -sf "$ZSTD_BIN" zstdcat
938
+ $EXE_PREFIX ./zstdcat helloworld.zst > result.tmp
939
+ $DIFF helloworld.tmp result.tmp
940
+ ln -s helloworld.zst helloworld.link.zst
941
+ $EXE_PREFIX ./zstdcat helloworld.link.zst > result.tmp
942
+ $DIFF helloworld.tmp result.tmp
943
+ rm -f zstdcat
944
+ rm -f result.tmp
945
+ println "testing zcat symlink"
946
+ ln -sf "$ZSTD_BIN" zcat
947
+ $EXE_PREFIX ./zcat helloworld.zst > result.tmp
948
+ $DIFF helloworld.tmp result.tmp
949
+ $EXE_PREFIX ./zcat helloworld.link.zst > result.tmp
950
+ $DIFF helloworld.tmp result.tmp
951
+ rm -f zcat
952
+ rm -f ./*.tmp ./*.zstd
953
+ println "frame concatenation tests completed"
954
+
955
+
956
+ if [ "$isWindows" = false ] && [ "$UNAME" != 'SunOS' ] && [ "$UNAME" != "OpenBSD" ] && [ "$UNAME" != "AIX" ]; then
957
+ println "\n**** flush write error test **** "
958
+
959
+ println "println foo | zstd > /dev/full"
960
+ println foo | zstd > /dev/full && die "write error not detected!"
961
+ println "println foo | zstd | zstd -d > /dev/full"
962
+ println foo | zstd | zstd -d > /dev/full && die "write error not detected!"
963
+
964
+ fi
965
+
966
+
967
+ if [ "$isWindows" = false ] && [ "$UNAME" != 'SunOS' ] ; then
968
+
969
+ println "\n===> symbolic link test "
970
+
971
+ rm -f hello.tmp world.tmp world2.tmp hello.tmp.zst world.tmp.zst
972
+ println "hello world" > hello.tmp
973
+ ln -s hello.tmp world.tmp
974
+ ln -s hello.tmp world2.tmp
975
+ zstd world.tmp hello.tmp || true
976
+ test -f hello.tmp.zst # regular file should have been compressed!
977
+ test ! -f world.tmp.zst # symbolic link should not have been compressed!
978
+ zstd world.tmp || true
979
+ test ! -f world.tmp.zst # symbolic link should not have been compressed!
980
+ zstd world.tmp world2.tmp || true
981
+ test ! -f world.tmp.zst # symbolic link should not have been compressed!
982
+ test ! -f world2.tmp.zst # symbolic link should not have been compressed!
983
+ zstd world.tmp hello.tmp -f
984
+ test -f world.tmp.zst # symbolic link should have been compressed with --force
985
+ rm -f hello.tmp world.tmp world2.tmp hello.tmp.zst world.tmp.zst
986
+
987
+ fi
988
+
989
+
990
+ println "\n===> test sparse file support "
991
+
992
+ datagen -g5M -P100 > tmpSparse
993
+ zstd tmpSparse -c | zstd -dv -o tmpSparseRegen
994
+ $DIFF -s tmpSparse tmpSparseRegen
995
+ zstd tmpSparse -c | zstd -dv --sparse -c > tmpOutSparse
996
+ $DIFF -s tmpSparse tmpOutSparse
997
+ zstd tmpSparse -c | zstd -dv --no-sparse -c > tmpOutNoSparse
998
+ $DIFF -s tmpSparse tmpOutNoSparse
999
+ ls -ls tmpSparse* # look at file size and block size on disk
1000
+ datagen -s1 -g1200007 -P100 | zstd | zstd -dv --sparse -c > tmpSparseOdd # Odd size file (to not finish on an exact nb of blocks)
1001
+ datagen -s1 -g1200007 -P100 | $DIFF -s - tmpSparseOdd
1002
+ ls -ls tmpSparseOdd # look at file size and block size on disk
1003
+ println "\n Sparse Compatibility with Console :"
1004
+ println "Hello World 1 !" | zstd | zstd -d -c
1005
+ println "Hello World 2 !" | zstd | zstd -d | cat
1006
+ println "\n Sparse Compatibility with Append :"
1007
+ datagen -P100 -g1M > tmpSparse1M
1008
+ cat tmpSparse1M tmpSparse1M > tmpSparse2M
1009
+ zstd -v -f tmpSparse1M -o tmpSparseCompressed
1010
+ zstd -d -v -f tmpSparseCompressed -o tmpSparseRegenerated
1011
+ zstd -d -v -f tmpSparseCompressed -c >> tmpSparseRegenerated
1012
+ ls -ls tmpSparse* # look at file size and block size on disk
1013
+ $DIFF tmpSparse2M tmpSparseRegenerated
1014
+ rm -f tmpSparse*
1015
+
1016
+
1017
+ println "\n===> stream-size mode"
1018
+
1019
+ datagen -g11000 > tmp
1020
+ println "test : basic file compression vs sized streaming compression"
1021
+ file_size=$(zstd -14 -f tmp -o tmp.zst && wc -c < tmp.zst)
1022
+ stream_size=$(cat tmp | zstd -14 --stream-size=11000 | wc -c)
1023
+ if [ "$stream_size" -gt "$file_size" ]; then
1024
+ die "hinted compression larger than expected"
1025
+ fi
1026
+ println "test : sized streaming compression and decompression"
1027
+ cat tmp | zstd -14 -f tmp -o tmp.zst --stream-size=11000
1028
+ zstd -df tmp.zst -o tmp_decompress
1029
+ cmp tmp tmp_decompress || die "difference between original and decompressed file"
1030
+ println "test : incorrect stream size"
1031
+ cat tmp | zstd -14 -f -o tmp.zst --stream-size=11001 && die "should fail with incorrect stream size"
1032
+
1033
+ println "\n===> zstd zero weight dict test "
1034
+ rm -f tmp*
1035
+ cp "$TESTDIR/dict-files/zero-weight-dict" tmp_input
1036
+ zstd -D "$TESTDIR/dict-files/zero-weight-dict" tmp_input
1037
+ zstd -D "$TESTDIR/dict-files/zero-weight-dict" -d tmp_input.zst -o tmp_decomp
1038
+ $DIFF tmp_decomp tmp_input
1039
+ rm -rf tmp*
1040
+
1041
+ println "\n===> zstd (valid) zero weight dict test "
1042
+ rm -f tmp*
1043
+ # 0 has a non-zero weight in the dictionary
1044
+ echo "0000000000000000000000000" > tmp_input
1045
+ zstd -D "$TESTDIR/dict-files/zero-weight-dict" tmp_input
1046
+ zstd -D "$TESTDIR/dict-files/zero-weight-dict" -d tmp_input.zst -o tmp_decomp
1047
+ $DIFF tmp_decomp tmp_input
1048
+ rm -rf tmp*
1049
+
1050
+ println "\n===> size-hint mode"
1051
+
1052
+ datagen -g11000 > tmp
1053
+ datagen -g11000 > tmp2
1054
+ datagen > tmpDict
1055
+ println "test : basic file compression vs hinted streaming compression"
1056
+ file_size=$(zstd -14 -f tmp -o tmp.zst && wc -c < tmp.zst)
1057
+ stream_size=$(cat tmp | zstd -14 --size-hint=11000 | wc -c)
1058
+ if [ "$stream_size" -ge "$file_size" ]; then
1059
+ die "hinted compression larger than expected"
1060
+ fi
1061
+ println "test : hinted streaming compression and decompression"
1062
+ cat tmp | zstd -14 -f -o tmp.zst --size-hint=11000
1063
+ zstd -df tmp.zst -o tmp_decompress
1064
+ cmp tmp tmp_decompress || die "difference between original and decompressed file"
1065
+ println "test : hinted streaming compression with dictionary"
1066
+ cat tmp | zstd -14 -f -D tmpDict --size-hint=11000 | zstd -t -D tmpDict
1067
+ println "test : multiple file compression with hints and dictionary"
1068
+ zstd -14 -f -D tmpDict --size-hint=11000 tmp tmp2
1069
+ zstd -14 -f -o tmp1_.zst -D tmpDict --size-hint=11000 tmp
1070
+ zstd -14 -f -o tmp2_.zst -D tmpDict --size-hint=11000 tmp2
1071
+ cmp tmp.zst tmp1_.zst || die "first file's output differs"
1072
+ cmp tmp2.zst tmp2_.zst || die "second file's output differs"
1073
+ println "test : incorrect hinted stream sizes"
1074
+ cat tmp | zstd -14 -f --size-hint=11050 | zstd -t # slightly too high
1075
+ cat tmp | zstd -14 -f --size-hint=10950 | zstd -t # slightly too low
1076
+ cat tmp | zstd -14 -f --size-hint=22000 | zstd -t # considerably too high
1077
+ cat tmp | zstd -14 -f --size-hint=5500 | zstd -t # considerably too low
1078
+ println "test : allows and interprets K,KB,KiB,M,MB and MiB suffix"
1079
+ cat tmp | zstd -14 -f --size-hint=11K | zstd -t
1080
+ cat tmp | zstd -14 -f --size-hint=11KB | zstd -t
1081
+ cat tmp | zstd -14 -f --size-hint=11KiB | zstd -t
1082
+ cat tmp | zstd -14 -f --size-hint=1M | zstd -t
1083
+ cat tmp | zstd -14 -f --size-hint=1MB | zstd -t
1084
+ cat tmp | zstd -14 -f --size-hint=1MiB | zstd -t
1085
+
1086
+
1087
+ println "\n===> dictionary tests "
1088
+ println "- Test high/low compressibility corpus training"
1089
+ datagen -g12M -P90 > tmpCorpusHighCompress
1090
+ datagen -g12M -P5 > tmpCorpusLowCompress
1091
+ zstd --train --split=2K tmpCorpusHighCompress -o tmpDictHighCompress
1092
+ zstd --train --split=2K tmpCorpusLowCompress -o tmpDictLowCompress
1093
+ rm -f tmpCorpusHighCompress tmpCorpusLowCompress tmpDictHighCompress tmpDictLowCompress
1094
+ println "- Test with raw dict (content only) "
1095
+ datagen > tmpDict
1096
+ datagen -g1M | $MD5SUM > tmp1
1097
+ datagen -g1M | zstd -D tmpDict | zstd -D tmpDict -dvq | $MD5SUM > tmp2
1098
+ $DIFF -q tmp1 tmp2
1099
+ println "- Create first dictionary "
1100
+ TESTFILE="$PRGDIR"/zstdcli.c
1101
+ zstd --train "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict
1102
+ cp "$TESTFILE" tmp
1103
+ println "- Test dictionary compression with tmpDict as an input file and dictionary"
1104
+ zstd -f tmpDict -D tmpDict && die "compression error not detected!"
1105
+ println "- Dictionary compression roundtrip"
1106
+ zstd -f tmp -D tmpDict
1107
+ zstd -d tmp.zst -D tmpDict -fo result
1108
+ $DIFF "$TESTFILE" result
1109
+ println "- Dictionary compression with hlog < clog"
1110
+ zstd -6f tmp -D tmpDict --zstd=clog=25,hlog=23
1111
+ println "- Dictionary compression with btlazy2 strategy"
1112
+ zstd -f tmp -D tmpDict --zstd=strategy=6
1113
+ zstd -d tmp.zst -D tmpDict -fo result
1114
+ $DIFF "$TESTFILE" result
1115
+ if [ -e /proc/self/fd/0 ]; then
1116
+ println "- Test rejecting irregular dictionary file"
1117
+ cat tmpDict | zstd -f tmp -D /proc/self/fd/0 && die "Piped dictionary should fail!"
1118
+ cat tmpDict | zstd -d tmp.zst -D /proc/self/fd/0 -f && die "Piped dictionary should fail!"
1119
+ fi
1120
+ if [ -n "$hasMT" ]
1121
+ then
1122
+ println "- Test dictionary compression with multithreading "
1123
+ datagen -g5M | zstd -T2 -D tmpDict | zstd -t -D tmpDict # fails with v1.3.2
1124
+ fi
1125
+ println "- Create second (different) dictionary "
1126
+ zstd --train "$TESTDIR"/*.c "$PRGDIR"/*.c "$PRGDIR"/*.h -o tmpDictC
1127
+ zstd -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
1128
+ println "- Create dictionary with short dictID"
1129
+ zstd --train "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpDict1
1130
+ cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
1131
+ println "- Create dictionary with wrong dictID parameter order (must fail)"
1132
+ zstd --train "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID -o 1 tmpDict1 && die "wrong order : --dictID must be followed by argument "
1133
+ println "- Create dictionary with size limit"
1134
+ zstd --train "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict2 --maxdict=4K -v
1135
+ println "- Create dictionary with small size limit"
1136
+ zstd --train "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict3 --maxdict=1K -v
1137
+ println "- Create dictionary with wrong parameter order (must fail)"
1138
+ zstd --train "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict3 --maxdict -v 4K && die "wrong order : --maxdict must be followed by argument "
1139
+ println "- Compress without dictID"
1140
+ zstd -f tmp -D tmpDict1 --no-dictID
1141
+ zstd -d tmp.zst -D tmpDict -fo result
1142
+ $DIFF "$TESTFILE" result
1143
+ println "- Compress multiple files with dictionary"
1144
+ rm -rf dirTestDict
1145
+ mkdir dirTestDict
1146
+ cp "$TESTDIR"/*.c dirTestDict
1147
+ cp "$PRGDIR"/*.c dirTestDict
1148
+ cp "$PRGDIR"/*.h dirTestDict
1149
+ $MD5SUM dirTestDict/* > tmph1
1150
+ zstd -f --rm dirTestDict/* -D tmpDictC
1151
+ zstd -d --rm dirTestDict/*.zst -D tmpDictC # note : use internal checksum by default
1152
+ case "$UNAME" in
1153
+ Darwin) println "md5sum -c not supported on OS-X : test skipped" ;; # not compatible with OS-X's md5
1154
+ *) $MD5SUM -c tmph1 ;;
1155
+ esac
1156
+ rm -rf dirTestDict
1157
+ println "- dictionary builder on bogus input"
1158
+ println "Hello World" > tmp
1159
+ zstd --train-legacy -q tmp && die "Dictionary training should fail : not enough input source"
1160
+ datagen -P0 -g10M > tmp
1161
+ zstd --train-legacy -q tmp && die "Dictionary training should fail : source is pure noise"
1162
+ println "- Test -o before --train"
1163
+ rm -f tmpDict dictionary
1164
+ zstd -o tmpDict --train "$TESTDIR"/*.c "$PRGDIR"/*.c
1165
+ test -f tmpDict
1166
+ zstd --train "$TESTDIR"/*.c "$PRGDIR"/*.c
1167
+ test -f dictionary
1168
+ if [ -n "$hasMT" ]
1169
+ then
1170
+ println "- Create dictionary with multithreading enabled"
1171
+ zstd --train -T0 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict
1172
+ fi
1173
+ rm -f tmp* dictionary
1174
+
1175
+ println "- Test --memory for dictionary compression"
1176
+ datagen -g12M -P90 > tmpCorpusHighCompress
1177
+ zstd --train --split=2K tmpCorpusHighCompress -o tmpDictHighCompress --memory=10K && die "Dictionary training should fail : --memory too low (10K)"
1178
+ zstd --train --split=2K tmpCorpusHighCompress -o tmpDictHighCompress --memory=5MB 2> zstTrainWithMemLimitStdErr
1179
+ cat zstTrainWithMemLimitStdErr | $GREP "setting manual memory limit for dictionary training data at 5 MB"
1180
+ cat zstTrainWithMemLimitStdErr | $GREP "Training samples set too large (12 MB); training on 5 MB only..."
1181
+ rm zstTrainWithMemLimitStdErr
1182
+
1183
+ println "\n===> fastCover dictionary builder : advanced options "
1184
+ TESTFILE="$PRGDIR"/zstdcli.c
1185
+ datagen > tmpDict
1186
+ println "- Create first dictionary"
1187
+ zstd --train-fastcover=k=46,d=8,f=15,split=80 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict
1188
+ cp "$TESTFILE" tmp
1189
+ zstd -f tmp -D tmpDict
1190
+ zstd -d tmp.zst -D tmpDict -fo result
1191
+ $DIFF "$TESTFILE" result
1192
+ println "- Create second (different) dictionary"
1193
+ zstd --train-fastcover=k=56,d=8 "$TESTDIR"/*.c "$PRGDIR"/*.c "$PRGDIR"/*.h -o tmpDictC
1194
+ zstd -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
1195
+ zstd --train-fastcover=k=56,d=8 && die "Create dictionary without input file"
1196
+ println "- Create dictionary with short dictID"
1197
+ zstd --train-fastcover=k=46,d=8,f=15,split=80 "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpDict1
1198
+ cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
1199
+ println "- Create dictionaries with shrink-dict flag enabled"
1200
+ zstd --train-fastcover=steps=1,shrink "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpShrinkDict
1201
+ zstd --train-fastcover=steps=1,shrink=1 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpShrinkDict1
1202
+ zstd --train-fastcover=steps=1,shrink=5 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpShrinkDict2
1203
+ zstd --train-fastcover=shrink=5,steps=1 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpShrinkDict3
1204
+ println "- Create dictionary with size limit"
1205
+ zstd --train-fastcover=steps=1 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict2 --maxdict=4K
1206
+ println "- Create dictionary using all samples for both training and testing"
1207
+ zstd --train-fastcover=k=56,d=8,split=100 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
1208
+ println "- Create dictionary using f=16"
1209
+ zstd --train-fastcover=k=56,d=8,f=16 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
1210
+ zstd --train-fastcover=k=56,d=8,accel=15 -r "$TESTDIR"/*.c "$PRGDIR"/*.c && die "Created dictionary using accel=15"
1211
+ println "- Create dictionary using accel=2"
1212
+ zstd --train-fastcover=k=56,d=8,accel=2 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
1213
+ println "- Create dictionary using accel=10"
1214
+ zstd --train-fastcover=k=56,d=8,accel=10 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
1215
+ println "- Create dictionary with multithreading"
1216
+ zstd --train-fastcover -T4 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
1217
+ println "- Test -o before --train-fastcover"
1218
+ rm -f tmpDict dictionary
1219
+ zstd -o tmpDict --train-fastcover=k=56,d=8 "$TESTDIR"/*.c "$PRGDIR"/*.c
1220
+ test -f tmpDict
1221
+ zstd --train-fastcover=k=56,d=8 "$TESTDIR"/*.c "$PRGDIR"/*.c
1222
+ test -f dictionary
1223
+ rm -f tmp* dictionary
1224
+
1225
+
1226
+ println "\n===> legacy dictionary builder "
1227
+
1228
+ TESTFILE="$PRGDIR"/zstdcli.c
1229
+ datagen > tmpDict
1230
+ println "- Create first dictionary"
1231
+ zstd --train-legacy=selectivity=8 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict
1232
+ cp "$TESTFILE" tmp
1233
+ zstd -f tmp -D tmpDict
1234
+ zstd -d tmp.zst -D tmpDict -fo result
1235
+ $DIFF "$TESTFILE" result
1236
+ zstd --train-legacy=s=8 && die "Create dictionary without input files (should error)"
1237
+ println "- Create second (different) dictionary"
1238
+ zstd --train-legacy=s=5 "$TESTDIR"/*.c "$PRGDIR"/*.c "$PRGDIR"/*.h -o tmpDictC
1239
+ zstd -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
1240
+ println "- Create dictionary with short dictID"
1241
+ zstd --train-legacy -s5 "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpDict1
1242
+ cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
1243
+ println "- Create dictionary with size limit"
1244
+ zstd --train-legacy -s9 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict2 --maxdict=4K
1245
+ println "- Test -o before --train-legacy"
1246
+ rm -f tmpDict dictionary
1247
+ zstd -o tmpDict --train-legacy "$TESTDIR"/*.c "$PRGDIR"/*.c
1248
+ test -f tmpDict
1249
+ zstd --train-legacy "$TESTDIR"/*.c "$PRGDIR"/*.c
1250
+ test -f dictionary
1251
+ rm -f tmp* dictionary
1252
+
1253
+
1254
+ println "\n===> integrity tests "
1255
+
1256
+ println "test one file (tmp1.zst) "
1257
+ datagen > tmp1
1258
+ zstd tmp1
1259
+ zstd -t tmp1.zst
1260
+ zstd --test tmp1.zst
1261
+ println "test multiple files (*.zst) "
1262
+ zstd -t ./*.zst
1263
+ println "test bad files (*) "
1264
+ zstd -t ./* && die "bad files not detected !"
1265
+ zstd -t tmp1 && die "bad file not detected !"
1266
+ cp tmp1 tmp2.zst
1267
+ zstd -t tmp2.zst && die "bad file not detected !"
1268
+ datagen -g0 > tmp3
1269
+ zstd -t tmp3 && die "bad file not detected !" # detects 0-sized files as bad
1270
+ println "test --rm and --test combined "
1271
+ zstd -t --rm tmp1.zst
1272
+ test -f tmp1.zst # check file is still present
1273
+ cp tmp1.zst tmp2.zst
1274
+ zstd -t tmp1.zst tmp2.zst --rm
1275
+ test -f tmp1.zst # check file is still present
1276
+ test -f tmp2.zst # check file is still present
1277
+ split -b16384 tmp1.zst tmpSplit.
1278
+ zstd -t tmpSplit.* && die "bad file not detected !"
1279
+ datagen | zstd -c | zstd -t
1280
+
1281
+
1282
+ println "\n===> golden files tests "
1283
+
1284
+ zstd -t -r "$TESTDIR/golden-decompression"
1285
+ zstd -c -r "$TESTDIR/golden-compression" | zstd -t
1286
+ zstd -D "$TESTDIR/golden-dictionaries/http-dict-missing-symbols" "$TESTDIR/golden-compression/http" -c | zstd -D "$TESTDIR/golden-dictionaries/http-dict-missing-symbols" -t
1287
+
1288
+
1289
+ println "\n===> benchmark mode tests "
1290
+
1291
+ println "bench one file"
1292
+ datagen > tmp1
1293
+ zstd -bi0 tmp1
1294
+ println "bench multiple levels"
1295
+ zstd -i0b0e3 tmp1
1296
+ println "bench negative level"
1297
+ zstd -bi0 --fast tmp1
1298
+ println "with recursive and quiet modes"
1299
+ zstd -rqi0b1e2 tmp1
1300
+ println "benchmark decompression only"
1301
+ zstd -f tmp1
1302
+ zstd -b -d -i0 tmp1.zst
1303
+ println "benchmark can fail - decompression on invalid data"
1304
+ zstd -b -d -i0 tmp1 && die "invalid .zst data => benchmark should have failed"
1305
+
1306
+ GZIPMODE=1
1307
+ zstd --format=gzip -V || GZIPMODE=0
1308
+ if [ $GZIPMODE -eq 1 ]; then
1309
+ println "benchmark mode is only compatible with zstd"
1310
+ zstd --format=gzip -b tmp1 && die "-b should be incompatible with gzip format!"
1311
+ fi
1312
+
1313
+ println "\n===> zstd compatibility tests "
1314
+
1315
+ datagen > tmp
1316
+ rm -f tmp.zst
1317
+ zstd --format=zstd -f tmp
1318
+ test -f tmp.zst
1319
+
1320
+
1321
+ println "\n===> gzip compatibility tests "
1322
+
1323
+ GZIPMODE=1
1324
+ zstd --format=gzip -V || GZIPMODE=0
1325
+ if [ $GZIPMODE -eq 1 ]; then
1326
+ println "gzip support detected"
1327
+ GZIPEXE=1
1328
+ gzip -V || GZIPEXE=0
1329
+ if [ $GZIPEXE -eq 1 ]; then
1330
+ datagen > tmp
1331
+ zstd --format=gzip -f tmp
1332
+ gzip -t -v tmp.gz
1333
+ gzip -f tmp
1334
+ zstd -d -f -v tmp.gz
1335
+ rm -f tmp*
1336
+ else
1337
+ println "gzip binary not detected"
1338
+ fi
1339
+ else
1340
+ println "gzip mode not supported"
1341
+ fi
1342
+
1343
+
1344
+ println "\n===> gzip frame tests "
1345
+
1346
+ if [ $GZIPMODE -eq 1 ]; then
1347
+ datagen > tmp
1348
+ zstd -f --format=gzip tmp
1349
+ zstd -f tmp
1350
+ cat tmp.gz tmp.zst tmp.gz tmp.zst | zstd -d -f -o tmp
1351
+ truncateLastByte tmp.gz | zstd -t > $INTOVOID && die "incomplete frame not detected !"
1352
+ rm -f tmp*
1353
+ else
1354
+ println "gzip mode not supported"
1355
+ fi
1356
+
1357
+ if [ $GZIPMODE -eq 1 ]; then
1358
+ datagen > tmp
1359
+ rm -f tmp.zst
1360
+ zstd --format=gzip --format=zstd -f tmp
1361
+ test -f tmp.zst
1362
+ fi
1363
+
1364
+ println "\n===> xz compatibility tests "
1365
+
1366
+ LZMAMODE=1
1367
+ zstd --format=xz -V || LZMAMODE=0
1368
+ if [ $LZMAMODE -eq 1 ]; then
1369
+ println "xz support detected"
1370
+ XZEXE=1
1371
+ xz -Q -V && lzma -Q -V || XZEXE=0
1372
+ if [ $XZEXE -eq 1 ]; then
1373
+ println "Testing zstd xz and lzma support"
1374
+ datagen > tmp
1375
+ zstd --format=lzma -f tmp
1376
+ zstd --format=xz -f tmp
1377
+ xz -Q -t -v tmp.xz
1378
+ xz -Q -t -v tmp.lzma
1379
+ xz -Q -f -k tmp
1380
+ lzma -Q -f -k --lzma1 tmp
1381
+ zstd -d -f -v tmp.xz
1382
+ zstd -d -f -v tmp.lzma
1383
+ rm -f tmp*
1384
+ println "Creating symlinks"
1385
+ ln -s "$ZSTD_BIN" ./xz
1386
+ ln -s "$ZSTD_BIN" ./unxz
1387
+ ln -s "$ZSTD_BIN" ./lzma
1388
+ ln -s "$ZSTD_BIN" ./unlzma
1389
+ println "Testing xz and lzma symlinks"
1390
+ datagen > tmp
1391
+ ./xz tmp
1392
+ xz -Q -d tmp.xz
1393
+ ./lzma tmp
1394
+ lzma -Q -d tmp.lzma
1395
+ println "Testing unxz and unlzma symlinks"
1396
+ xz -Q tmp
1397
+ ./xz -d tmp.xz
1398
+ lzma -Q tmp
1399
+ ./lzma -d tmp.lzma
1400
+ rm -f xz unxz lzma unlzma
1401
+ rm -f tmp*
1402
+ else
1403
+ println "xz binary not detected"
1404
+ fi
1405
+ else
1406
+ println "xz mode not supported"
1407
+ fi
1408
+
1409
+
1410
+ println "\n===> xz frame tests "
1411
+
1412
+ if [ $LZMAMODE -eq 1 ]; then
1413
+ datagen > tmp
1414
+ zstd -f --format=xz tmp
1415
+ zstd -f --format=lzma tmp
1416
+ zstd -f tmp
1417
+ cat tmp.xz tmp.lzma tmp.zst tmp.lzma tmp.xz tmp.zst | zstd -d -f -o tmp
1418
+ truncateLastByte tmp.xz | zstd -t > $INTOVOID && die "incomplete frame not detected !"
1419
+ truncateLastByte tmp.lzma | zstd -t > $INTOVOID && die "incomplete frame not detected !"
1420
+ rm -f tmp*
1421
+ else
1422
+ println "xz mode not supported"
1423
+ fi
1424
+
1425
+ println "\n===> lz4 compatibility tests "
1426
+
1427
+ LZ4MODE=1
1428
+ zstd --format=lz4 -V || LZ4MODE=0
1429
+ if [ $LZ4MODE -eq 1 ]; then
1430
+ println "lz4 support detected"
1431
+ LZ4EXE=1
1432
+ lz4 -V || LZ4EXE=0
1433
+ if [ $LZ4EXE -eq 1 ]; then
1434
+ datagen > tmp
1435
+ zstd --format=lz4 -f tmp
1436
+ lz4 -t -v tmp.lz4
1437
+ lz4 -f -m tmp # ensure result is sent into tmp.lz4, not stdout
1438
+ zstd -d -f -v tmp.lz4
1439
+ rm -f tmp*
1440
+ else
1441
+ println "lz4 binary not detected"
1442
+ fi
1443
+ else
1444
+ println "lz4 mode not supported"
1445
+ fi
1446
+
1447
+
1448
+ if [ $LZ4MODE -eq 1 ]; then
1449
+ println "\n===> lz4 frame tests "
1450
+ datagen > tmp
1451
+ zstd -f --format=lz4 tmp
1452
+ zstd -f tmp
1453
+ cat tmp.lz4 tmp.zst tmp.lz4 tmp.zst | zstd -d -f -o tmp
1454
+ truncateLastByte tmp.lz4 | zstd -t > $INTOVOID && die "incomplete frame not detected !"
1455
+ rm -f tmp*
1456
+ else
1457
+ println "\nlz4 mode not supported"
1458
+ fi
1459
+
1460
+
1461
+ println "\n===> suffix list test"
1462
+
1463
+ ! zstd -d tmp.abc 2> tmplg
1464
+
1465
+ if [ $GZIPMODE -ne 1 ]; then
1466
+ $GREP ".gz" tmplg > $INTOVOID && die "Unsupported suffix listed"
1467
+ fi
1468
+
1469
+ if [ $LZMAMODE -ne 1 ]; then
1470
+ $GREP ".lzma" tmplg > $INTOVOID && die "Unsupported suffix listed"
1471
+ $GREP ".xz" tmplg > $INTOVOID && die "Unsupported suffix listed"
1472
+ fi
1473
+
1474
+ if [ $LZ4MODE -ne 1 ]; then
1475
+ $GREP ".lz4" tmplg > $INTOVOID && die "Unsupported suffix listed"
1476
+ fi
1477
+
1478
+ touch tmp1
1479
+ zstd tmp1 -o tmp1.zstd
1480
+ zstd -d -f tmp1.zstd # support .zstd suffix even though it's not the default suffix
1481
+
1482
+ println "\n===> tar extension tests "
1483
+
1484
+ rm -f tmp tmp.tar tmp.tzst tmp.tgz tmp.txz tmp.tlz4 tmp1.zstd
1485
+
1486
+ datagen > tmp
1487
+ tar -cf tmp.tar tmp
1488
+ zstd tmp.tar -o tmp.tzst
1489
+ rm -f tmp.tar
1490
+ zstd -d tmp.tzst
1491
+ [ -e tmp.tar ] || die ".tzst failed to decompress to .tar!"
1492
+ rm -f tmp.tar tmp.tzst
1493
+
1494
+ if [ $GZIPMODE -eq 1 ]; then
1495
+ tar -f - -c tmp | gzip > tmp.tgz
1496
+ zstd -d tmp.tgz
1497
+ [ -e tmp.tar ] || die ".tgz failed to decompress to .tar!"
1498
+ rm -f tmp.tar tmp.tgz
1499
+ fi
1500
+
1501
+ if [ $LZMAMODE -eq 1 ]; then
1502
+ tar -f - -c tmp | zstd --format=xz > tmp.txz
1503
+ zstd -d tmp.txz
1504
+ [ -e tmp.tar ] || die ".txz failed to decompress to .tar!"
1505
+ rm -f tmp.tar tmp.txz
1506
+ fi
1507
+
1508
+ if [ $LZ4MODE -eq 1 ]; then
1509
+ tar -f - -c tmp | zstd --format=lz4 > tmp.tlz4
1510
+ zstd -d tmp.tlz4
1511
+ [ -e tmp.tar ] || die ".tlz4 failed to decompress to .tar!"
1512
+ rm -f tmp.tar tmp.tlz4
1513
+ fi
1514
+
1515
+ touch tmp.t tmp.tz tmp.tzs
1516
+ ! zstd -d tmp.t
1517
+ ! zstd -d tmp.tz
1518
+ ! zstd -d tmp.tzs
1519
+
1520
+
1521
+ println "\n===> zstd round-trip tests "
1522
+
1523
+ roundTripTest
1524
+ roundTripTest -g15K # TableID==3
1525
+ roundTripTest -g127K # TableID==2
1526
+ roundTripTest -g255K # TableID==1
1527
+ roundTripTest -g522K # TableID==0
1528
+ roundTripTest -g519K 6 # greedy, hash chain
1529
+ roundTripTest -g517K 16 # btlazy2
1530
+ roundTripTest -g516K 19 # btopt
1531
+
1532
+ fileRoundTripTest -g500K
1533
+
1534
+ println "\n===> zstd long distance matching round-trip tests "
1535
+ roundTripTest -g0 "2 --single-thread --long"
1536
+ roundTripTest -g1000K "1 --single-thread --long"
1537
+ roundTripTest -g517K "6 --single-thread --long"
1538
+ roundTripTest -g516K "16 --single-thread --long"
1539
+ roundTripTest -g518K "19 --single-thread --long"
1540
+ roundTripTest -g2M "22 --single-thread --ultra --long"
1541
+ fileRoundTripTest -g5M "3 --single-thread --long"
1542
+
1543
+
1544
+ roundTripTest -g96K "5 --single-thread"
1545
+ if [ -n "$hasMT" ]
1546
+ then
1547
+ println "\n===> zstdmt round-trip tests "
1548
+ roundTripTest -g4M "1 -T0"
1549
+ roundTripTest -g4M "1 -T0 --auto-threads=physical"
1550
+ roundTripTest -g4M "1 -T0 --auto-threads=logical"
1551
+ roundTripTest -g8M "3 -T2"
1552
+ roundTripTest -g8000K "2 --threads=2"
1553
+ fileRoundTripTest -g4M "19 -T2 --split=1M"
1554
+
1555
+ println "\n===> zstdmt long distance matching round-trip tests "
1556
+ roundTripTest -g8M "3 --long=24 -T2"
1557
+
1558
+ println "\n===> zstdmt environment variable tests "
1559
+ echo "multifoo" >> mt_tmp
1560
+ ZSTD_NBTHREADS=-3 zstd -f mt_tmp # negative value, warn and revert to default setting
1561
+ ZSTD_NBTHREADS='' zstd -f mt_tmp # empty env var, warn and revert to default setting
1562
+ ZSTD_NBTHREADS=- zstd -f mt_tmp # malformed env var, warn and revert to default setting
1563
+ ZSTD_NBTHREADS=a zstd -f mt_tmp # malformed env var, warn and revert to default setting
1564
+ ZSTD_NBTHREADS=+a zstd -f mt_tmp # malformed env var, warn and revert to default setting
1565
+ ZSTD_NBTHREADS=3a7 zstd -f mt_tmp # malformed env var, warn and revert to default setting
1566
+ ZSTD_NBTHREADS=50000000000 zstd -f mt_tmp # numeric value too large, warn and revert to default setting=
1567
+ ZSTD_NBTHREADS=2 zstd -f mt_tmp # correct usage
1568
+ ZSTD_NBTHREADS=1 zstd -f mt_tmp # correct usage: single worker
1569
+ ZSTD_NBTHREADS=4 zstd -f mt_tmp -vv 2>&1 | $GREP "4 worker threads" # check message
1570
+ ZSTD_NBTHREADS=0 zstd -f mt_tmp -vv 2>&1 | $GREP "core(s) detected" # check core count autodetection is triggered
1571
+ # temporary envvar changes in the above tests would actually persist in macos /bin/sh
1572
+ unset ZSTD_NBTHREADS
1573
+ rm -f mt_tmp*
1574
+
1575
+ println "\n===> ovLog tests "
1576
+ datagen -g2MB > tmp
1577
+ refSize=$(zstd tmp -6 -c --zstd=wlog=18 | wc -c)
1578
+ ov9Size=$(zstd tmp -6 -c --zstd=wlog=18,ovlog=9 | wc -c)
1579
+ ov1Size=$(zstd tmp -6 -c --zstd=wlog=18,ovlog=1 | wc -c)
1580
+ if [ "$refSize" -eq "$ov9Size" ]; then
1581
+ echo ov9Size should be different from refSize
1582
+ exit 1
1583
+ fi
1584
+ if [ "$refSize" -eq "$ov1Size" ]; then
1585
+ echo ov1Size should be different from refSize
1586
+ exit 1
1587
+ fi
1588
+ if [ "$ov9Size" -ge "$ov1Size" ]; then
1589
+ echo ov9Size="$ov9Size" should be smaller than ov1Size="$ov1Size"
1590
+ exit 1
1591
+ fi
1592
+
1593
+ else
1594
+ println "\n===> no multithreading, skipping zstdmt tests "
1595
+ fi
1596
+
1597
+ rm -f tmp*
1598
+
1599
+ println "\n===> zstd --list/-l single frame tests "
1600
+ datagen > tmp1
1601
+ datagen > tmp2
1602
+ datagen > tmp3
1603
+ zstd tmp*
1604
+ zstd -l ./*.zst
1605
+ zstd -lv ./*.zst | $GREP "Decompressed Size:" # check that decompressed size is present in header
1606
+ zstd --list ./*.zst
1607
+ zstd --list -v ./*.zst
1608
+
1609
+ println "\n===> zstd --list/-l multiple frame tests "
1610
+ cat tmp1.zst tmp2.zst > tmp12.zst
1611
+ cat tmp12.zst tmp3.zst > tmp123.zst
1612
+ zstd -l ./*.zst
1613
+ zstd -lv ./*.zst
1614
+
1615
+ println "\n===> zstd --list/-l error detection tests "
1616
+ zstd -l tmp1 tmp1.zst && die "-l must fail on non-zstd file"
1617
+ zstd --list tmp* && die "-l must fail on non-zstd file"
1618
+ zstd -lv tmp1* && die "-l must fail on non-zstd file"
1619
+ zstd --list -v tmp2 tmp12.zst && die "-l must fail on non-zstd file"
1620
+
1621
+ println "test : detect truncated compressed file "
1622
+ TEST_DATA_FILE=truncatable-input.txt
1623
+ FULL_COMPRESSED_FILE=${TEST_DATA_FILE}.zst
1624
+ TRUNCATED_COMPRESSED_FILE=truncated-input.txt.zst
1625
+ datagen -g50000 > $TEST_DATA_FILE
1626
+ zstd -f $TEST_DATA_FILE -o $FULL_COMPRESSED_FILE
1627
+ dd bs=1 count=100 if=$FULL_COMPRESSED_FILE of=$TRUNCATED_COMPRESSED_FILE
1628
+ zstd --list $TRUNCATED_COMPRESSED_FILE && die "-l must fail on truncated file"
1629
+
1630
+ rm -f $TEST_DATA_FILE
1631
+ rm -f $FULL_COMPRESSED_FILE
1632
+ rm -f $TRUNCATED_COMPRESSED_FILE
1633
+
1634
+ println "\n===> zstd --list/-l errors when presented with stdin / no files"
1635
+ zstd -l && die "-l must fail on empty list of files"
1636
+ zstd -l - && die "-l does not work on stdin"
1637
+ zstd -l < tmp1.zst && die "-l does not work on stdin"
1638
+ zstd -l - < tmp1.zst && die "-l does not work on stdin"
1639
+ zstd -l - tmp1.zst && die "-l does not work on stdin"
1640
+ zstd -l - tmp1.zst < tmp1.zst && die "-l does not work on stdin"
1641
+ zstd -l tmp1.zst < tmp2.zst # this will check tmp1.zst, but not tmp2.zst, which is not an error : zstd simply doesn't read stdin in this case. It must not error just because stdin is not a tty
1642
+
1643
+ println "\n===> zstd --list/-l test with null files "
1644
+ datagen -g0 > tmp5
1645
+ zstd tmp5
1646
+ zstd -l tmp5.zst
1647
+ zstd -l tmp5* && die "-l must fail on non-zstd file"
1648
+ zstd -lv tmp5.zst | $GREP "Decompressed Size: 0 B (0 B)" # check that 0 size is present in header
1649
+ zstd -lv tmp5* && die "-l must fail on non-zstd file"
1650
+
1651
+ println "\n===> zstd --list/-l test with no content size field "
1652
+ datagen -g513K | zstd > tmp6.zst
1653
+ zstd -l tmp6.zst
1654
+ zstd -lv tmp6.zst | $GREP "Decompressed Size:" && die "Field :Decompressed Size: should not be available in this compressed file"
1655
+
1656
+ println "\n===> zstd --list/-l test with no checksum "
1657
+ zstd -f --no-check tmp1
1658
+ zstd -l tmp1.zst
1659
+ zstd -lv tmp1.zst
1660
+
1661
+ println "\n===> zstd trace tests "
1662
+ zstd -f --trace tmp.trace tmp1
1663
+ zstd -f --trace tmp.trace tmp1 tmp2 tmp3
1664
+ zstd -f --trace tmp.trace tmp1 tmp2 tmp3 -o /dev/null
1665
+ zstd -f --trace tmp.trace tmp1 tmp2 tmp3 --single-thread
1666
+ zstd -f --trace tmp.trace -D tmp1 tmp2 tmp3 -o /dev/null
1667
+ zstd -f --trace tmp.trace -D tmp1 tmp2 tmp3 -o /dev/null --single-thread
1668
+ zstd --trace tmp.trace -t tmp1.zst
1669
+ zstd --trace tmp.trace -t tmp1.zst tmp2.zst
1670
+ zstd -f --trace tmp.trace -d tmp1.zst
1671
+ zstd -f --trace tmp.trace -d tmp1.zst tmp2.zst tmp3.zst
1672
+ zstd -D tmp1 tmp2 -c | zstd --trace tmp.trace -t -D tmp1
1673
+ zstd -b1e10i0 --trace tmp.trace tmp1
1674
+ zstd -b1e10i0 --trace tmp.trace tmp1 tmp2 tmp3
1675
+
1676
+ rm -f tmp*
1677
+
1678
+
1679
+ println "\n===> zstd long distance matching tests "
1680
+ roundTripTest -g0 " --single-thread --long"
1681
+ roundTripTest -g9M "2 --single-thread --long"
1682
+ # Test parameter parsing
1683
+ roundTripTest -g1M -P50 "1 --single-thread --long=29" " --memory=512MB"
1684
+ roundTripTest -g1M -P50 "1 --single-thread --long=29 --zstd=wlog=28" " --memory=256MB"
1685
+ roundTripTest -g1M -P50 "1 --single-thread --long=29" " --long=28 --memory=512MB"
1686
+ roundTripTest -g1M -P50 "1 --single-thread --long=29" " --zstd=wlog=28 --memory=512MB"
1687
+
1688
+
1689
+ if [ "$ZSTD_LIB_EXCLUDE_COMPRESSORS_DFAST_AND_UP" -ne "1" ]; then
1690
+ println "\n===> zstd long distance matching with optimal parser compressed size tests "
1691
+ optCSize16=$(datagen -g511K | zstd -16 -c | wc -c)
1692
+ longCSize16=$(datagen -g511K | zstd -16 --long -c | wc -c)
1693
+ optCSize19=$(datagen -g2M | zstd -19 -c | wc -c)
1694
+ longCSize19=$(datagen -g2M | zstd -19 --long -c | wc -c)
1695
+ optCSize19wlog23=$(datagen -g2M | zstd -19 -c --zstd=wlog=23 | wc -c)
1696
+ longCSize19wlog23=$(datagen -g2M | zstd -19 -c --long=23 | wc -c)
1697
+ if [ "$longCSize16" -gt "$optCSize16" ]; then
1698
+ echo using --long on compression level 16 should not cause compressed size regression
1699
+ exit 1
1700
+ elif [ "$longCSize19" -gt "$optCSize19" ]; then
1701
+ echo using --long on compression level 19 should not cause compressed size regression
1702
+ exit 1
1703
+ elif [ "$longCSize19wlog23" -gt "$optCSize19wlog23" ]; then
1704
+ echo using --long on compression level 19 with wLog=23 should not cause compressed size regression
1705
+ exit 1
1706
+ fi
1707
+ fi
1708
+
1709
+ println "\n===> zstd asyncio tests "
1710
+
1711
+ addFrame() {
1712
+ datagen -g2M -s$2 >> tmp_uncompressed
1713
+ datagen -g2M -s$2 | zstd -1 --format=$1 >> tmp_compressed.zst
1714
+ }
1715
+
1716
+ addTwoFrames() {
1717
+ addFrame $1 1
1718
+ addFrame $1 2
1719
+ }
1720
+
1721
+ testAsyncIO() {
1722
+ roundTripTest -g2M "3 --asyncio --format=$1"
1723
+ roundTripTest -g2M "3 --no-asyncio --format=$1"
1724
+ }
1725
+
1726
+ rm -f tmp_compressed tmp_uncompressed
1727
+ testAsyncIO zstd
1728
+ addTwoFrames zstd
1729
+ if [ $GZIPMODE -eq 1 ]; then
1730
+ testAsyncIO gzip
1731
+ addTwoFrames gzip
1732
+ fi
1733
+ if [ $LZMAMODE -eq 1 ]; then
1734
+ testAsyncIO lzma
1735
+ addTwoFrames lzma
1736
+ fi
1737
+ if [ $LZ4MODE -eq 1 ]; then
1738
+ testAsyncIO lz4
1739
+ addTwoFrames lz4
1740
+ fi
1741
+ cat tmp_uncompressed | $MD5SUM > tmp2
1742
+ zstd -d tmp_compressed.zst --asyncio -c | $MD5SUM > tmp1
1743
+ $DIFF -q tmp1 tmp2
1744
+ rm tmp1
1745
+ zstd -d tmp_compressed.zst --no-asyncio -c | $MD5SUM > tmp1
1746
+ $DIFF -q tmp1 tmp2
1747
+
1748
+ if [ "$1" != "--test-large-data" ]; then
1749
+ println "Skipping large data tests"
1750
+ exit 0
1751
+ fi
1752
+
1753
+
1754
+ #############################################################################
1755
+
1756
+
1757
+ if [ -n "$hasMT" ]
1758
+ then
1759
+ println "\n===> adaptive mode "
1760
+ roundTripTest -g270000000 " --adapt"
1761
+ roundTripTest -g27000000 " --adapt=min=1,max=4"
1762
+ roundTripTest -g27000000 " --adapt=min=-2,max=-1"
1763
+ println "===> test: --adapt must fail on incoherent bounds "
1764
+ datagen > tmp
1765
+ zstd --adapt= tmp && die "invalid compression parameter"
1766
+ zstd -f -vv --adapt=min=10,max=9 tmp && die "--adapt must fail on incoherent bounds"
1767
+
1768
+ println "\n===> rsyncable mode "
1769
+ roundTripTest -g10M " --rsyncable"
1770
+ roundTripTest -g10M " --rsyncable --split=100K"
1771
+ println "===> test: --rsyncable must fail with --single-thread"
1772
+ zstd -f -vv --rsyncable --single-thread tmp && die "--rsyncable must fail with --single-thread"
1773
+ fi
1774
+
1775
+ println "\n===> patch-from=origin tests"
1776
+ datagen -g1000 -P50 > tmp_dict
1777
+ datagen -g1000 -P10 > tmp_patch
1778
+ zstd --patch-from=tmp_dict tmp_patch -o tmp_patch_diff
1779
+ zstd -d --patch-from=tmp_dict tmp_patch_diff -o tmp_patch_recon
1780
+ $DIFF -s tmp_patch_recon tmp_patch
1781
+ zstd -f --patch-apply=tmp_dict tmp_patch_diff -o tmp_patch_recon
1782
+ $DIFF -s tmp_patch_recon tmp_patch
1783
+
1784
+ println "\n===> alternate syntax: patch-from origin"
1785
+ zstd -f --patch-from tmp_dict tmp_patch -o tmp_patch_diff
1786
+ zstd -df --patch-from tmp_dict tmp_patch_diff -o tmp_patch_recon
1787
+ $DIFF -s tmp_patch_recon tmp_patch
1788
+ zstd -f --patch-apply tmp_dict tmp_patch_diff -o tmp_patch_recon
1789
+ $DIFF -s tmp_patch_recon tmp_patch
1790
+ rm -rf tmp_*
1791
+
1792
+ println "\n===> patch-from recursive tests"
1793
+ mkdir tmp_dir
1794
+ datagen > tmp_dir/tmp1
1795
+ datagen > tmp_dir/tmp2
1796
+ datagen > tmp_dict
1797
+ zstd --patch-from=tmp_dict -r tmp_dir && die
1798
+ rm -rf tmp*
1799
+
1800
+ println "\n===> patch-from long mode trigger larger file test"
1801
+ if [ "$ZSTD_LIB_EXCLUDE_COMPRESSORS_DFAST_AND_UP" -eq "1" ]; then
1802
+ # if binary tree strategies are excluded, the threshold is different
1803
+ datagen -g10000000 > tmp_dict
1804
+ datagen -g10000000 > tmp_patch
1805
+ else
1806
+ datagen -g5000000 > tmp_dict
1807
+ datagen -g5000000 > tmp_patch
1808
+ fi
1809
+ zstd -15 --patch-from=tmp_dict tmp_patch 2>&1 | $GREP "long mode automatically triggered"
1810
+ rm -rf tmp*
1811
+
1812
+ println "\n===> patch-from very large dictionary and file test"
1813
+ datagen -g550000000 -P0 > tmp_dict
1814
+ datagen -g100000000 -P1 > tmp_patch
1815
+ zstd --long=30 -1f --patch-from tmp_dict tmp_patch
1816
+ zstd --long=30 -df --patch-from tmp_dict tmp_patch.zst -o tmp_patch_recon
1817
+ $DIFF -s tmp_patch_recon tmp_patch
1818
+ rm -rf tmp*
1819
+
1820
+ println "\n===> patch-from --stream-size test"
1821
+ datagen -g1000 -P50 > tmp_dict
1822
+ datagen -g1000 -P10 > tmp_patch
1823
+ cat tmp_patch | zstd -f --patch-from=tmp_dict -c -o tmp_patch_diff && die
1824
+ cat tmp_patch | zstd -f --patch-from=tmp_dict --stream-size=1000 -c -o tmp_patch_diff
1825
+ rm -rf tmp*
1826
+
1827
+ println "\n===> large files tests "
1828
+
1829
+ roundTripTest -g270000000 1
1830
+ roundTripTest -g250000000 2
1831
+ roundTripTest -g230000000 3
1832
+
1833
+ roundTripTest -g140000000 -P60 4
1834
+ roundTripTest -g130000000 -P62 5
1835
+ roundTripTest -g120000000 -P65 6
1836
+
1837
+ roundTripTest -g70000000 -P70 7
1838
+ roundTripTest -g60000000 -P71 8
1839
+ roundTripTest -g50000000 -P73 9
1840
+
1841
+ roundTripTest -g35000000 -P75 10
1842
+ roundTripTest -g30000000 -P76 11
1843
+ roundTripTest -g25000000 -P78 12
1844
+
1845
+ roundTripTest -g18000013 -P80 13
1846
+ roundTripTest -g18000014 -P80 14
1847
+ roundTripTest -g18000015 -P81 15
1848
+ roundTripTest -g18000016 -P84 16
1849
+ roundTripTest -g18000017 -P88 17
1850
+ roundTripTest -g18000018 -P94 18
1851
+ roundTripTest -g18000019 -P96 19
1852
+
1853
+ roundTripTest -g8M "19 --long"
1854
+
1855
+ roundTripTest -g5000000000 -P99 "1 --zstd=wlog=25"
1856
+ roundTripTest -g3700000000 -P0 "1 --zstd=strategy=6,wlog=25" # ensure btlazy2 can survive an overflow rescale
1857
+
1858
+ fileRoundTripTest -g4193M -P99 1
1859
+
1860
+
1861
+ println "\n===> zstd long, long distance matching round-trip tests "
1862
+ roundTripTest -g270000000 "1 --single-thread --long"
1863
+ roundTripTest -g130000000 -P60 "5 --single-thread --long"
1864
+ roundTripTest -g35000000 -P70 "8 --single-thread --long"
1865
+ roundTripTest -g18000001 -P80 "18 --single-thread --long"
1866
+ # Test large window logs
1867
+ roundTripTest -g700M -P50 "1 --single-thread --long=29"
1868
+ roundTripTest -g600M -P50 "1 --single-thread --long --zstd=wlog=29,clog=28"
1869
+
1870
+
1871
+ if [ -n "$hasMT" ]
1872
+ then
1873
+ println "\n===> zstdmt long round-trip tests "
1874
+ roundTripTest -g80000000 -P99 "19 -T2" " "
1875
+ roundTripTest -g5000000000 -P99 "1 -T2" " "
1876
+ roundTripTest -g500000000 -P97 "1 -T999" " "
1877
+ fileRoundTripTest -g4103M -P98 " -T0" " "
1878
+ roundTripTest -g400000000 -P97 "1 --long=24 -T2" " "
1879
+ # Exposes the bug in https://github.com/facebook/zstd/pull/1678
1880
+ # This test fails on 4 different travis builds at the time of writing
1881
+ # because it needs to allocate 8 GB of memory.
1882
+ # roundTripTest -g10G -P99 "1 -T1 --long=31 --zstd=clog=27 --fast=1000"
1883
+ else
1884
+ println "\n**** no multithreading, skipping zstdmt tests **** "
1885
+ fi
1886
+
1887
+
1888
+ println "\n===> cover dictionary builder : advanced options "
1889
+
1890
+ TESTFILE="$PRGDIR"/zstdcli.c
1891
+ datagen > tmpDict
1892
+ println "- Create first dictionary"
1893
+ zstd -T0 --train-cover=k=46,d=8,split=80 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict
1894
+ cp "$TESTFILE" tmp
1895
+ zstd -f tmp -D tmpDict
1896
+ zstd -f tmp -D tmpDict --patch-from=tmpDict && die "error: can't use -D and --patch-from=#at the same time"
1897
+ zstd -d tmp.zst -D tmpDict -fo result
1898
+ $DIFF "$TESTFILE" result
1899
+ zstd -T0 --train-cover=k=56,d=8 && die "Create dictionary without input file (should error)"
1900
+ println "- Create second (different) dictionary"
1901
+ zstd -T0 --train-cover=k=56,d=8 "$TESTDIR"/*.c "$PRGDIR"/*.c "$PRGDIR"/*.h -o tmpDictC
1902
+ zstd -d tmp.zst -D tmpDictC -fo result && die "wrong dictionary not detected!"
1903
+ println "- Create dictionary using shrink-dict flag"
1904
+ zstd -T0 --train-cover=steps=256,shrink "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpShrinkDict
1905
+ zstd -T0 --train-cover=steps=256,shrink=1 "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpShrinkDict1
1906
+ zstd -T0 --train-cover=steps=256,shrink=5 "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpShrinkDict2
1907
+ zstd -T0 --train-cover=shrink=5,steps=256 "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpShrinkDict3
1908
+ println "- Create dictionary with short dictID"
1909
+ zstd -T0 --train-cover=k=46,d=8,split=80 "$TESTDIR"/*.c "$PRGDIR"/*.c --dictID=1 -o tmpDict1
1910
+ cmp tmpDict tmpDict1 && die "dictionaries should have different ID !"
1911
+ println "- Create dictionary with size limit"
1912
+ zstd -T0 --train-cover=steps=8 "$TESTDIR"/*.c "$PRGDIR"/*.c -o tmpDict2 --maxdict=4K
1913
+ println "- Compare size of dictionary from 90% training samples with 80% training samples"
1914
+ zstd -T0 --train-cover=split=90 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
1915
+ zstd -T0 --train-cover=split=80 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
1916
+ println "- Create dictionary using all samples for both training and testing"
1917
+ zstd -T0 --train-cover=split=100 -r "$TESTDIR"/*.c "$PRGDIR"/*.c
1918
+ println "- Test -o before --train-cover"
1919
+ rm -f tmpDict dictionary
1920
+ zstd -o tmpDict --train-cover "$TESTDIR"/*.c "$PRGDIR"/*.c
1921
+ test -f tmpDict
1922
+ zstd -T0 --train-cover "$TESTDIR"/*.c "$PRGDIR"/*.c
1923
+ test -f dictionary
1924
+ rm -f tmp* dictionary
1925
+
1926
+ rm -f tmp*