1 # #############################################################################
2 # Copyright (c) 2018-present Dima Krasner <dima@dimakrasner.com>
3 # lzutao <taolzu(at)gmail.com>
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 # #############################################################################
11 zstd_rootdir = '../../..'
13 tests_supported_oses = [os_linux, 'gnu/kfreebsd', os_darwin, 'gnu', 'openbsd',
14 os_freebsd, 'netbsd', 'dragonfly', os_sun]
16 # =============================================================================
18 # =============================================================================
20 FUZZER_FLAGS = ['--no-big-tests']
22 ZSTREAM_TESTTIME = '-T90s'
23 DECODECORPUS_TESTTIME = '-T30'
25 # =============================================================================
27 # =============================================================================
29 test_includes = [ include_directories(join_paths(zstd_rootdir, 'programs')) ]
31 testcommon_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'),
32 join_paths(zstd_rootdir, 'programs/util.c'),
33 join_paths(zstd_rootdir, 'programs/timefn.c'),
34 join_paths(zstd_rootdir, 'programs/benchfn.c'),
35 join_paths(zstd_rootdir, 'programs/benchzstd.c')]
37 testcommon = static_library('testcommon',
39 # needed due to use of private symbol + -fvisibility=hidden
40 link_with: libzstd_static)
42 testcommon_dep = declare_dependency(link_with: testcommon,
43 dependencies: libzstd_deps,
44 include_directories: libzstd_includes)
46 datagen_sources = [join_paths(zstd_rootdir, 'tests/datagencli.c')]
47 datagen = executable('datagen',
49 c_args: [ '-DNDEBUG' ],
50 include_directories: test_includes,
51 dependencies: testcommon_dep,
54 fullbench_sources = [join_paths(zstd_rootdir, 'tests/fullbench.c')]
55 fullbench = executable('fullbench',
57 include_directories: test_includes,
58 dependencies: testcommon_dep,
61 fuzzer_sources = [join_paths(zstd_rootdir, 'tests/fuzzer.c')]
62 fuzzer = executable('fuzzer',
64 include_directories: test_includes,
65 dependencies: [ testcommon_dep, thread_dep ],
68 zstreamtest_sources = [
69 join_paths(zstd_rootdir, 'tests/seqgen.c'),
70 join_paths(zstd_rootdir, 'tests/zstreamtest.c'),
71 join_paths(zstd_rootdir, 'tests/external_matchfinder.c')]
72 zstreamtest = executable('zstreamtest',
74 include_directories: test_includes,
75 dependencies: testcommon_dep,
78 paramgrill_sources = [join_paths(zstd_rootdir, 'tests/paramgrill.c')]
79 paramgrill = executable('paramgrill',
81 include_directories: test_includes,
82 dependencies: [ testcommon_dep, libm_dep ],
85 roundTripCrash_sources = [join_paths(zstd_rootdir, 'tests/roundTripCrash.c')]
86 roundTripCrash = executable('roundTripCrash',
87 roundTripCrash_sources,
88 dependencies: [ testcommon_dep ],
91 longmatch_sources = [join_paths(zstd_rootdir, 'tests/longmatch.c')]
92 longmatch = executable('longmatch',
94 dependencies: [ libzstd_dep ],
97 invalidDictionaries_sources = [join_paths(zstd_rootdir, 'tests/invalidDictionaries.c')]
98 invalidDictionaries = executable('invalidDictionaries',
99 invalidDictionaries_sources,
100 dependencies: [ libzstd_dep ],
103 if 0 < legacy_level and legacy_level <= 4
104 legacy_sources = [join_paths(zstd_rootdir, 'tests/legacy.c')]
105 legacy = executable('legacy',
107 # Use -Dlegacy_level build option to control it
108 #c_args: '-DZSTD_LEGACY_SUPPORT=4',
109 dependencies: [ libzstd_dep ],
113 decodecorpus_sources = [join_paths(zstd_rootdir, 'tests/decodecorpus.c')]
114 decodecorpus = executable('decodecorpus',
115 decodecorpus_sources,
116 include_directories: test_includes,
117 dependencies: [ testcommon_dep, libm_dep ],
120 poolTests_sources = [join_paths(zstd_rootdir, 'tests/poolTests.c')]
121 poolTests = executable('poolTests',
123 include_directories: test_includes,
124 dependencies: [ testcommon_dep, thread_dep ],
127 checkTag_sources = [join_paths(zstd_rootdir, 'tests/checkTag.c')]
128 checkTag = executable('checkTag',
130 dependencies: [ libzstd_dep ],
133 # =============================================================================
134 # Tests (Use "meson test --list" to list all tests)
135 # =============================================================================
137 if tests_supported_oses.contains(host_machine_os)
138 valgrind_prog = find_program('valgrind', ['/usr/bin/valgrind'], required: false)
139 valgrindTest_py = files('valgrindTest.py')
140 if valgrind_prog.found()
143 args: [valgrind_prog.path(), zstd, datagen, fuzzer, fullbench],
144 depends: [zstd, datagen, fuzzer, fullbench],
145 timeout: 600) # Timeout should work on HDD drive
149 if host_machine_os != os_windows
150 playTests_sh = find_program(join_paths(zstd_rootdir, 'tests/playTests.sh'), required: true)
152 # add slow tests only if the meson version is new enough to support
153 # test setups with default-excluded suites
154 if meson.version().version_compare('>=0.57.0')
155 matrix = {'fast': [], 'slow': ['--test-large-data']}
157 matrix = {'fast': []}
160 foreach suite, opt: matrix
161 test('test-zstd-'+suite,
164 env: ['ZSTD_BIN=' + zstd.full_path(), 'DATAGEN_BIN=./datagen'],
165 depends: [datagen, zstd],
167 workdir: meson.current_build_dir(),
168 timeout: 2800) # Timeout should work on HDD drive
172 test('test-fullbench-1',
177 test('test-fullbench-2',
179 args: ['-i1', '-P0'],
186 args: ['-v', FUZZERTEST] + FUZZER_FLAGS,
190 test('test-zstream-1',
192 args: ['-v', ZSTREAM_TESTTIME] + FUZZER_FLAGS,
194 test('test-zstream-3',
196 args: ['--newapi', '-t1', ZSTREAM_TESTTIME] + FUZZER_FLAGS,
198 test('test-longmatch', longmatch, timeout: 36)
199 test('test-invalidDictionaries', invalidDictionaries) # should be fast
200 if 0 < legacy_level and legacy_level <= 4
201 test('test-legacy', legacy) # should be fast
203 test('test-decodecorpus',
205 args: ['-t', DECODECORPUS_TESTTIME],
207 test('test-poolTests', poolTests) # should be fast
209 if meson.version().version_compare('>=0.57.0')
210 add_test_setup('fast',
212 exclude_suites: ['slow'])
213 add_test_setup('slow',
214 exclude_suites: ['fast'])