meson.build 6.5 KB

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