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 11zstd_rootdir = '../../..' 12 13tests_supported_oses = [os_linux, 'gnu/kfreebsd', os_darwin, 'gnu', 'openbsd', 14 os_freebsd, 'netbsd', 'dragonfly', os_sun] 15 16# ============================================================================= 17# Test flags 18# ============================================================================= 19 20FUZZER_FLAGS = ['--no-big-tests'] 21FUZZERTEST = '-T200s' 22ZSTREAM_TESTTIME = '-T90s' 23DECODECORPUS_TESTTIME = '-T30' 24ZSTDRTTEST = ['--test-large-data'] 25 26# ============================================================================= 27# Executables 28# ============================================================================= 29 30test_includes = [ include_directories(join_paths(zstd_rootdir, 'programs')) ] 31 32datagen_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'), 33 join_paths(zstd_rootdir, 'tests/datagencli.c')] 34datagen = executable('datagen', 35 datagen_sources, 36 c_args: [ '-DNDEBUG' ], 37 include_directories: test_includes, 38 dependencies: libzstd_dep, 39 install: false) 40 41fullbench_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'), 42 join_paths(zstd_rootdir, 'programs/util.c'), 43 join_paths(zstd_rootdir, 'programs/timefn.c'), 44 join_paths(zstd_rootdir, 'programs/benchfn.c'), 45 join_paths(zstd_rootdir, 'programs/benchzstd.c'), 46 join_paths(zstd_rootdir, 'tests/fullbench.c')] 47fullbench = executable('fullbench', 48 fullbench_sources, 49 include_directories: test_includes, 50 dependencies: libzstd_dep, 51 install: false) 52 53fuzzer_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'), 54 join_paths(zstd_rootdir, 'programs/util.c'), 55 join_paths(zstd_rootdir, 'programs/timefn.c'), 56 join_paths(zstd_rootdir, 'tests/fuzzer.c')] 57fuzzer = executable('fuzzer', 58 fuzzer_sources, 59 include_directories: test_includes, 60 dependencies: [ libzstd_dep, thread_dep ], 61 install: false) 62 63zstreamtest_sources = [join_paths(zstd_rootdir, 'programs/datagen.c'), 64 join_paths(zstd_rootdir, 'programs/util.c'), 65 join_paths(zstd_rootdir, 'programs/timefn.c'), 66 join_paths(zstd_rootdir, 'tests/seqgen.c'), 67 join_paths(zstd_rootdir, 'tests/zstreamtest.c')] 68zstreamtest = executable('zstreamtest', 69 zstreamtest_sources, 70 include_directories: test_includes, 71 dependencies: libzstd_dep, 72 install: false) 73 74paramgrill_sources = [join_paths(zstd_rootdir, 'programs/benchfn.c'), 75 join_paths(zstd_rootdir, 'programs/timefn.c'), 76 join_paths(zstd_rootdir, 'programs/benchzstd.c'), 77 join_paths(zstd_rootdir, 'programs/datagen.c'), 78 join_paths(zstd_rootdir, 'programs/util.c'), 79 join_paths(zstd_rootdir, 'tests/paramgrill.c')] 80paramgrill = executable('paramgrill', 81 paramgrill_sources, 82 include_directories: test_includes, 83 dependencies: [ libzstd_dep, libm_dep ], 84 install: false) 85 86roundTripCrash_sources = [join_paths(zstd_rootdir, 'tests/roundTripCrash.c')] 87roundTripCrash = executable('roundTripCrash', 88 roundTripCrash_sources, 89 dependencies: [ libzstd_dep ], 90 install: false) 91 92longmatch_sources = [join_paths(zstd_rootdir, 'tests/longmatch.c')] 93longmatch = executable('longmatch', 94 longmatch_sources, 95 dependencies: [ libzstd_dep ], 96 install: false) 97 98invalidDictionaries_sources = [join_paths(zstd_rootdir, 'tests/invalidDictionaries.c')] 99invalidDictionaries = executable('invalidDictionaries', 100 invalidDictionaries_sources, 101 dependencies: [ libzstd_dep ], 102 install: false) 103 104if 0 < legacy_level and legacy_level <= 4 105 legacy_sources = [join_paths(zstd_rootdir, 'tests/legacy.c')] 106 legacy = executable('legacy', 107 legacy_sources, 108 # Use -Dlegacy_level build option to control it 109 #c_args: '-DZSTD_LEGACY_SUPPORT=4', 110 dependencies: [ libzstd_dep ], 111 install: false) 112endif 113 114decodecorpus_sources = [join_paths(zstd_rootdir, 'programs/util.c'), 115 join_paths(zstd_rootdir, 'programs/timefn.c'), 116 join_paths(zstd_rootdir, 'tests/decodecorpus.c')] 117decodecorpus = executable('decodecorpus', 118 decodecorpus_sources, 119 include_directories: test_includes, 120 dependencies: [ libzstd_dep, libm_dep ], 121 install: false) 122 123poolTests_sources = [join_paths(zstd_rootdir, 'programs/util.c'), 124 join_paths(zstd_rootdir, 'programs/timefn.c'), 125 join_paths(zstd_rootdir, 'tests/poolTests.c'), 126 join_paths(zstd_rootdir, 'lib/common/pool.c'), 127 join_paths(zstd_rootdir, 'lib/common/threading.c'), 128 join_paths(zstd_rootdir, 'lib/common/zstd_common.c'), 129 join_paths(zstd_rootdir, 'lib/common/error_private.c')] 130poolTests = executable('poolTests', 131 poolTests_sources, 132 include_directories: test_includes, 133 dependencies: [ libzstd_dep, thread_dep ], 134 install: false) 135 136checkTag_sources = [join_paths(zstd_rootdir, 'tests/checkTag.c')] 137checkTag = executable('checkTag', 138 checkTag_sources, 139 dependencies: [ libzstd_dep ], 140 install: false) 141 142# ============================================================================= 143# Tests (Use "meson test --list" to list all tests) 144# ============================================================================= 145 146if tests_supported_oses.contains(host_machine_os) 147 valgrind_prog = find_program('valgrind', ['/usr/bin/valgrind'], required: true) 148 valgrindTest_py = files('valgrindTest.py') 149 test('valgrindTest', 150 valgrindTest_py, 151 args: [valgrind_prog.path(), zstd, datagen, fuzzer, fullbench], 152 depends: [zstd, datagen, fuzzer, fullbench], 153 timeout: 600) # Timeout should work on HDD drive 154endif 155 156if host_machine_os != os_windows 157 playTests_sh = find_program(join_paths(zstd_rootdir, 'tests/playTests.sh'), required: true) 158 test('test-zstd', 159 playTests_sh, 160 args: ZSTDRTTEST, 161 env: ['ZSTD_BIN=' + zstd.full_path(), 'DATAGEN_BIN=./datagen'], 162 depends: [datagen], 163 workdir: meson.current_build_dir(), 164 timeout: 2800) # Timeout should work on HDD drive 165endif 166 167test('test-fullbench-1', 168 fullbench, 169 args: ['-i1'], 170 depends: [datagen], 171 timeout: 60) 172test('test-fullbench-2', 173 fullbench, 174 args: ['-i1', '-P0'], 175 depends: [datagen], 176 timeout: 60) 177 178if use_zlib 179 test('test-fuzzer', 180 fuzzer, 181 args: ['-v', FUZZERTEST] + FUZZER_FLAGS, 182 timeout: 480) 183endif 184 185test('test-zstream-1', 186 zstreamtest, 187 args: ['-v', ZSTREAM_TESTTIME] + FUZZER_FLAGS, 188 timeout: 240) 189test('test-zstream-2', 190 zstreamtest, 191 args: ['-mt', '-t1', ZSTREAM_TESTTIME] + FUZZER_FLAGS, 192 timeout: 120) 193test('test-zstream-3', 194 zstreamtest, 195 args: ['--newapi', '-t1', ZSTREAM_TESTTIME] + FUZZER_FLAGS, 196 timeout: 120) 197test('test-longmatch', longmatch, timeout: 36) 198test('test-invalidDictionaries', invalidDictionaries) # should be fast 199if 0 < legacy_level and legacy_level <= 4 200 test('test-legacy', legacy) # should be fast 201endif 202test('test-decodecorpus', 203 decodecorpus, 204 args: ['-t', DECODECORPUS_TESTTIME], 205 timeout: 60) 206test('test-poolTests', poolTests) # should be fast 207