648db22b |
1 | # ############################################################################# |
2 | # Copyright (c) 2018-present Dima Krasner <dima@dimakrasner.com> |
3 | # lzutao <taolzu(at)gmail.com> |
4 | # All rights reserved. |
5 | # |
6 | # This source code is licensed under both the BSD-style license (found in the |
7 | # LICENSE file in the root directory of this source tree) and the GPLv2 (found |
8 | # in the COPYING file in the root directory of this source tree). |
9 | # ############################################################################# |
10 | |
11 | zstd_rootdir = '../../..' |
12 | |
13 | tests_supported_oses = [os_linux, 'gnu/kfreebsd', os_darwin, 'gnu', 'openbsd', |
14 | os_freebsd, 'netbsd', 'dragonfly', os_sun] |
15 | |
16 | # ============================================================================= |
17 | # Test flags |
18 | # ============================================================================= |
19 | |
20 | FUZZER_FLAGS = ['--no-big-tests'] |
21 | FUZZERTEST = '-T200s' |
22 | ZSTREAM_TESTTIME = '-T90s' |
23 | DECODECORPUS_TESTTIME = '-T30' |
24 | |
25 | # ============================================================================= |
26 | # Executables |
27 | # ============================================================================= |
28 | |
29 | test_includes = [ include_directories(join_paths(zstd_rootdir, 'programs')) ] |
30 | |
31 | testcommon_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'), |
f535537f |
32 | join_paths(zstd_rootdir, 'programs/lorem.c'), |
648db22b |
33 | join_paths(zstd_rootdir, 'programs/util.c'), |
34 | join_paths(zstd_rootdir, 'programs/timefn.c'), |
35 | join_paths(zstd_rootdir, 'programs/benchfn.c'), |
36 | join_paths(zstd_rootdir, 'programs/benchzstd.c')] |
37 | |
38 | testcommon = static_library('testcommon', |
39 | testcommon_sources, |
40 | # needed due to use of private symbol + -fvisibility=hidden |
41 | link_with: libzstd_static) |
42 | |
43 | testcommon_dep = declare_dependency(link_with: testcommon, |
44 | dependencies: libzstd_deps, |
45 | include_directories: libzstd_includes) |
46 | |
f535537f |
47 | datagen_sources = [join_paths(zstd_rootdir, 'tests/datagencli.c'), |
48 | join_paths(zstd_rootdir, 'tests/loremOut.c')] |
648db22b |
49 | datagen = executable('datagen', |
50 | datagen_sources, |
51 | c_args: [ '-DNDEBUG' ], |
52 | include_directories: test_includes, |
53 | dependencies: testcommon_dep, |
54 | install: false) |
55 | |
56 | fullbench_sources = [join_paths(zstd_rootdir, 'tests/fullbench.c')] |
57 | fullbench = executable('fullbench', |
58 | fullbench_sources, |
59 | include_directories: test_includes, |
60 | dependencies: testcommon_dep, |
61 | install: false) |
62 | |
63 | fuzzer_sources = [join_paths(zstd_rootdir, 'tests/fuzzer.c')] |
64 | fuzzer = executable('fuzzer', |
65 | fuzzer_sources, |
66 | include_directories: test_includes, |
67 | dependencies: [ testcommon_dep, thread_dep ], |
68 | install: false) |
69 | |
70 | zstreamtest_sources = [ |
71 | join_paths(zstd_rootdir, 'tests/seqgen.c'), |
72 | join_paths(zstd_rootdir, 'tests/zstreamtest.c'), |
73 | join_paths(zstd_rootdir, 'tests/external_matchfinder.c')] |
74 | zstreamtest = executable('zstreamtest', |
75 | zstreamtest_sources, |
76 | include_directories: test_includes, |
77 | dependencies: testcommon_dep, |
78 | install: false) |
79 | |
80 | paramgrill_sources = [join_paths(zstd_rootdir, 'tests/paramgrill.c')] |
81 | paramgrill = executable('paramgrill', |
82 | paramgrill_sources, |
83 | include_directories: test_includes, |
84 | dependencies: [ testcommon_dep, libm_dep ], |
85 | install: false) |
86 | |
87 | roundTripCrash_sources = [join_paths(zstd_rootdir, 'tests/roundTripCrash.c')] |
88 | roundTripCrash = executable('roundTripCrash', |
89 | roundTripCrash_sources, |
90 | dependencies: [ testcommon_dep ], |
91 | install: false) |
92 | |
93 | longmatch_sources = [join_paths(zstd_rootdir, 'tests/longmatch.c')] |
94 | longmatch = executable('longmatch', |
95 | longmatch_sources, |
96 | dependencies: [ libzstd_dep ], |
97 | install: false) |
98 | |
99 | invalidDictionaries_sources = [join_paths(zstd_rootdir, 'tests/invalidDictionaries.c')] |
100 | invalidDictionaries = executable('invalidDictionaries', |
101 | invalidDictionaries_sources, |
102 | dependencies: [ libzstd_dep ], |
103 | install: false) |
104 | |
105 | if 0 < legacy_level and legacy_level <= 4 |
106 | legacy_sources = [join_paths(zstd_rootdir, 'tests/legacy.c')] |
107 | legacy = executable('legacy', |
108 | legacy_sources, |
109 | # Use -Dlegacy_level build option to control it |
110 | #c_args: '-DZSTD_LEGACY_SUPPORT=4', |
111 | dependencies: [ libzstd_dep ], |
112 | install: false) |
113 | endif |
114 | |
115 | decodecorpus_sources = [join_paths(zstd_rootdir, 'tests/decodecorpus.c')] |
116 | decodecorpus = executable('decodecorpus', |
117 | decodecorpus_sources, |
118 | include_directories: test_includes, |
119 | dependencies: [ testcommon_dep, libm_dep ], |
120 | install: false) |
121 | |
122 | poolTests_sources = [join_paths(zstd_rootdir, 'tests/poolTests.c')] |
123 | poolTests = executable('poolTests', |
124 | poolTests_sources, |
125 | include_directories: test_includes, |
126 | dependencies: [ testcommon_dep, thread_dep ], |
127 | install: false) |
128 | |
129 | checkTag_sources = [join_paths(zstd_rootdir, 'tests/checkTag.c')] |
130 | checkTag = executable('checkTag', |
131 | checkTag_sources, |
132 | dependencies: [ libzstd_dep ], |
133 | install: false) |
134 | |
135 | # ============================================================================= |
136 | # Tests (Use "meson test --list" to list all tests) |
137 | # ============================================================================= |
138 | |
139 | if tests_supported_oses.contains(host_machine_os) |
140 | valgrind_prog = find_program('valgrind', ['/usr/bin/valgrind'], required: false) |
141 | valgrindTest_py = files('valgrindTest.py') |
142 | if valgrind_prog.found() |
143 | test('valgrindTest', |
144 | valgrindTest_py, |
145 | args: [valgrind_prog.path(), zstd, datagen, fuzzer, fullbench], |
146 | depends: [zstd, datagen, fuzzer, fullbench], |
147 | timeout: 600) # Timeout should work on HDD drive |
148 | endif |
149 | endif |
150 | |
151 | if host_machine_os != os_windows |
152 | playTests_sh = find_program(join_paths(zstd_rootdir, 'tests/playTests.sh'), required: true) |
153 | |
154 | # add slow tests only if the meson version is new enough to support |
155 | # test setups with default-excluded suites |
156 | if meson.version().version_compare('>=0.57.0') |
157 | matrix = {'fast': [], 'slow': ['--test-large-data']} |
158 | else |
159 | matrix = {'fast': []} |
160 | endif |
161 | |
162 | foreach suite, opt: matrix |
163 | test('test-zstd-'+suite, |
164 | playTests_sh, |
165 | args: opt, |
166 | env: ['ZSTD_BIN=' + zstd.full_path(), 'DATAGEN_BIN=./datagen'], |
167 | depends: [datagen, zstd], |
168 | suite: suite, |
169 | workdir: meson.current_build_dir(), |
170 | timeout: 2800) # Timeout should work on HDD drive |
171 | endforeach |
172 | endif |
173 | |
174 | test('test-fullbench-1', |
175 | fullbench, |
176 | args: ['-i1'], |
177 | depends: [datagen], |
178 | timeout: 60) |
179 | test('test-fullbench-2', |
180 | fullbench, |
181 | args: ['-i1', '-P0'], |
182 | depends: [datagen], |
183 | timeout: 60) |
184 | |
185 | if use_zlib |
186 | test('test-fuzzer', |
187 | fuzzer, |
188 | args: ['-v', FUZZERTEST] + FUZZER_FLAGS, |
189 | timeout: 480) |
190 | endif |
191 | |
192 | test('test-zstream-1', |
193 | zstreamtest, |
194 | args: ['-v', ZSTREAM_TESTTIME] + FUZZER_FLAGS, |
195 | timeout: 240) |
196 | test('test-zstream-3', |
197 | zstreamtest, |
198 | args: ['--newapi', '-t1', ZSTREAM_TESTTIME] + FUZZER_FLAGS, |
199 | timeout: 120) |
200 | test('test-longmatch', longmatch, timeout: 36) |
201 | test('test-invalidDictionaries', invalidDictionaries) # should be fast |
202 | if 0 < legacy_level and legacy_level <= 4 |
203 | test('test-legacy', legacy) # should be fast |
204 | endif |
205 | test('test-decodecorpus', |
206 | decodecorpus, |
207 | args: ['-t', DECODECORPUS_TESTTIME], |
208 | timeout: 60) |
209 | test('test-poolTests', poolTests) # should be fast |
210 | |
211 | if meson.version().version_compare('>=0.57.0') |
212 | add_test_setup('fast', |
213 | is_default: true, |
214 | exclude_suites: ['slow']) |
215 | add_test_setup('slow', |
216 | exclude_suites: ['fast']) |
217 | endif |