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/lorem.c'),
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')]
38 testcommon = static_library('testcommon',
40 # needed due to use of private symbol + -fvisibility=hidden
41 link_with: libzstd_static)
43 testcommon_dep = declare_dependency(link_with: testcommon,
44 dependencies: libzstd_deps,
45 include_directories: libzstd_includes)
47 datagen_sources = [join_paths(zstd_rootdir, 'tests/datagencli.c'),
48 join_paths(zstd_rootdir, 'tests/loremOut.c')]
49 datagen = executable('datagen',
51 c_args: [ '-DNDEBUG' ],
52 include_directories: test_includes,
53 dependencies: testcommon_dep,
56 fullbench_sources = [join_paths(zstd_rootdir, 'tests/fullbench.c')]
57 fullbench = executable('fullbench',
59 include_directories: test_includes,
60 dependencies: testcommon_dep,
63 fuzzer_sources = [join_paths(zstd_rootdir, 'tests/fuzzer.c')]
64 fuzzer = executable('fuzzer',
66 include_directories: test_includes,
67 dependencies: [ testcommon_dep, thread_dep ],
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',
76 include_directories: test_includes,
77 dependencies: testcommon_dep,
80 paramgrill_sources = [join_paths(zstd_rootdir, 'tests/paramgrill.c')]
81 paramgrill = executable('paramgrill',
83 include_directories: test_includes,
84 dependencies: [ testcommon_dep, libm_dep ],
87 roundTripCrash_sources = [join_paths(zstd_rootdir, 'tests/roundTripCrash.c')]
88 roundTripCrash = executable('roundTripCrash',
89 roundTripCrash_sources,
90 dependencies: [ testcommon_dep ],
93 longmatch_sources = [join_paths(zstd_rootdir, 'tests/longmatch.c')]
94 longmatch = executable('longmatch',
96 dependencies: [ libzstd_dep ],
99 invalidDictionaries_sources = [join_paths(zstd_rootdir, 'tests/invalidDictionaries.c')]
100 invalidDictionaries = executable('invalidDictionaries',
101 invalidDictionaries_sources,
102 dependencies: [ libzstd_dep ],
105 if 0 < legacy_level and legacy_level <= 4
106 legacy_sources = [join_paths(zstd_rootdir, 'tests/legacy.c')]
107 legacy = executable('legacy',
109 # Use -Dlegacy_level build option to control it
110 #c_args: '-DZSTD_LEGACY_SUPPORT=4',
111 dependencies: [ libzstd_dep ],
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 ],
122 poolTests_sources = [join_paths(zstd_rootdir, 'tests/poolTests.c')]
123 poolTests = executable('poolTests',
125 include_directories: test_includes,
126 dependencies: [ testcommon_dep, thread_dep ],
129 checkTag_sources = [join_paths(zstd_rootdir, 'tests/checkTag.c')]
130 checkTag = executable('checkTag',
132 dependencies: [ libzstd_dep ],
135 # =============================================================================
136 # Tests (Use "meson test --list" to list all tests)
137 # =============================================================================
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()
145 args: [valgrind_prog.path(), zstd, datagen, fuzzer, fullbench],
146 depends: [zstd, datagen, fuzzer, fullbench],
147 timeout: 600) # Timeout should work on HDD drive
151 if host_machine_os != os_windows
152 playTests_sh = find_program(join_paths(zstd_rootdir, 'tests/playTests.sh'), required: true)
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']}
159 matrix = {'fast': []}
162 foreach suite, opt: matrix
163 test('test-zstd-'+suite,
166 env: ['ZSTD_BIN=' + zstd.full_path(), 'DATAGEN_BIN=./datagen'],
167 depends: [datagen, zstd],
169 workdir: meson.current_build_dir(),
170 timeout: 2800) # Timeout should work on HDD drive
174 test('test-fullbench-1',
179 test('test-fullbench-2',
181 args: ['-i1', '-P0'],
188 args: ['-v', FUZZERTEST] + FUZZER_FLAGS,
192 test('test-zstream-1',
194 args: ['-v', ZSTREAM_TESTTIME] + FUZZER_FLAGS,
196 test('test-zstream-3',
198 args: ['--newapi', '-t1', ZSTREAM_TESTTIME] + FUZZER_FLAGS,
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
205 test('test-decodecorpus',
207 args: ['-t', DECODECORPUS_TESTTIME],
209 test('test-poolTests', poolTests) # should be fast
211 if meson.version().version_compare('>=0.57.0')
212 add_test_setup('fast',
214 exclude_suites: ['slow'])
215 add_test_setup('slow',
216 exclude_suites: ['fast'])