| 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'), |
| 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')] |
| 36 | |
| 37 | testcommon = static_library('testcommon', |
| 38 | testcommon_sources, |
| 39 | # needed due to use of private symbol + -fvisibility=hidden |
| 40 | link_with: libzstd_static) |
| 41 | |
| 42 | testcommon_dep = declare_dependency(link_with: testcommon, |
| 43 | dependencies: libzstd_deps, |
| 44 | include_directories: libzstd_includes) |
| 45 | |
| 46 | datagen_sources = [join_paths(zstd_rootdir, 'tests/datagencli.c')] |
| 47 | datagen = executable('datagen', |
| 48 | datagen_sources, |
| 49 | c_args: [ '-DNDEBUG' ], |
| 50 | include_directories: test_includes, |
| 51 | dependencies: testcommon_dep, |
| 52 | install: false) |
| 53 | |
| 54 | fullbench_sources = [join_paths(zstd_rootdir, 'tests/fullbench.c')] |
| 55 | fullbench = executable('fullbench', |
| 56 | fullbench_sources, |
| 57 | include_directories: test_includes, |
| 58 | dependencies: testcommon_dep, |
| 59 | install: false) |
| 60 | |
| 61 | fuzzer_sources = [join_paths(zstd_rootdir, 'tests/fuzzer.c')] |
| 62 | fuzzer = executable('fuzzer', |
| 63 | fuzzer_sources, |
| 64 | include_directories: test_includes, |
| 65 | dependencies: [ testcommon_dep, thread_dep ], |
| 66 | install: false) |
| 67 | |
| 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', |
| 73 | zstreamtest_sources, |
| 74 | include_directories: test_includes, |
| 75 | dependencies: testcommon_dep, |
| 76 | install: false) |
| 77 | |
| 78 | paramgrill_sources = [join_paths(zstd_rootdir, 'tests/paramgrill.c')] |
| 79 | paramgrill = executable('paramgrill', |
| 80 | paramgrill_sources, |
| 81 | include_directories: test_includes, |
| 82 | dependencies: [ testcommon_dep, libm_dep ], |
| 83 | install: false) |
| 84 | |
| 85 | roundTripCrash_sources = [join_paths(zstd_rootdir, 'tests/roundTripCrash.c')] |
| 86 | roundTripCrash = executable('roundTripCrash', |
| 87 | roundTripCrash_sources, |
| 88 | dependencies: [ testcommon_dep ], |
| 89 | install: false) |
| 90 | |
| 91 | longmatch_sources = [join_paths(zstd_rootdir, 'tests/longmatch.c')] |
| 92 | longmatch = executable('longmatch', |
| 93 | longmatch_sources, |
| 94 | dependencies: [ libzstd_dep ], |
| 95 | install: false) |
| 96 | |
| 97 | invalidDictionaries_sources = [join_paths(zstd_rootdir, 'tests/invalidDictionaries.c')] |
| 98 | invalidDictionaries = executable('invalidDictionaries', |
| 99 | invalidDictionaries_sources, |
| 100 | dependencies: [ libzstd_dep ], |
| 101 | install: false) |
| 102 | |
| 103 | if 0 < legacy_level and legacy_level <= 4 |
| 104 | legacy_sources = [join_paths(zstd_rootdir, 'tests/legacy.c')] |
| 105 | legacy = executable('legacy', |
| 106 | legacy_sources, |
| 107 | # Use -Dlegacy_level build option to control it |
| 108 | #c_args: '-DZSTD_LEGACY_SUPPORT=4', |
| 109 | dependencies: [ libzstd_dep ], |
| 110 | install: false) |
| 111 | endif |
| 112 | |
| 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 ], |
| 118 | install: false) |
| 119 | |
| 120 | poolTests_sources = [join_paths(zstd_rootdir, 'tests/poolTests.c')] |
| 121 | poolTests = executable('poolTests', |
| 122 | poolTests_sources, |
| 123 | include_directories: test_includes, |
| 124 | dependencies: [ testcommon_dep, thread_dep ], |
| 125 | install: false) |
| 126 | |
| 127 | checkTag_sources = [join_paths(zstd_rootdir, 'tests/checkTag.c')] |
| 128 | checkTag = executable('checkTag', |
| 129 | checkTag_sources, |
| 130 | dependencies: [ libzstd_dep ], |
| 131 | install: false) |
| 132 | |
| 133 | # ============================================================================= |
| 134 | # Tests (Use "meson test --list" to list all tests) |
| 135 | # ============================================================================= |
| 136 | |
| 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() |
| 141 | test('valgrindTest', |
| 142 | valgrindTest_py, |
| 143 | args: [valgrind_prog.path(), zstd, datagen, fuzzer, fullbench], |
| 144 | depends: [zstd, datagen, fuzzer, fullbench], |
| 145 | timeout: 600) # Timeout should work on HDD drive |
| 146 | endif |
| 147 | endif |
| 148 | |
| 149 | if host_machine_os != os_windows |
| 150 | playTests_sh = find_program(join_paths(zstd_rootdir, 'tests/playTests.sh'), required: true) |
| 151 | |
| 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']} |
| 156 | else |
| 157 | matrix = {'fast': []} |
| 158 | endif |
| 159 | |
| 160 | foreach suite, opt: matrix |
| 161 | test('test-zstd-'+suite, |
| 162 | playTests_sh, |
| 163 | args: opt, |
| 164 | env: ['ZSTD_BIN=' + zstd.full_path(), 'DATAGEN_BIN=./datagen'], |
| 165 | depends: [datagen, zstd], |
| 166 | suite: suite, |
| 167 | workdir: meson.current_build_dir(), |
| 168 | timeout: 2800) # Timeout should work on HDD drive |
| 169 | endforeach |
| 170 | endif |
| 171 | |
| 172 | test('test-fullbench-1', |
| 173 | fullbench, |
| 174 | args: ['-i1'], |
| 175 | depends: [datagen], |
| 176 | timeout: 60) |
| 177 | test('test-fullbench-2', |
| 178 | fullbench, |
| 179 | args: ['-i1', '-P0'], |
| 180 | depends: [datagen], |
| 181 | timeout: 60) |
| 182 | |
| 183 | if use_zlib |
| 184 | test('test-fuzzer', |
| 185 | fuzzer, |
| 186 | args: ['-v', FUZZERTEST] + FUZZER_FLAGS, |
| 187 | timeout: 480) |
| 188 | endif |
| 189 | |
| 190 | test('test-zstream-1', |
| 191 | zstreamtest, |
| 192 | args: ['-v', ZSTREAM_TESTTIME] + FUZZER_FLAGS, |
| 193 | timeout: 240) |
| 194 | test('test-zstream-3', |
| 195 | zstreamtest, |
| 196 | args: ['--newapi', '-t1', ZSTREAM_TESTTIME] + FUZZER_FLAGS, |
| 197 | timeout: 120) |
| 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 |
| 202 | endif |
| 203 | test('test-decodecorpus', |
| 204 | decodecorpus, |
| 205 | args: ['-t', DECODECORPUS_TESTTIME], |
| 206 | timeout: 60) |
| 207 | test('test-poolTests', poolTests) # should be fast |
| 208 | |
| 209 | if meson.version().version_compare('>=0.57.0') |
| 210 | add_test_setup('fast', |
| 211 | is_default: true, |
| 212 | exclude_suites: ['slow']) |
| 213 | add_test_setup('slow', |
| 214 | exclude_suites: ['fast']) |
| 215 | endif |