thread_dep = dependency('threads') dl_dep = cc.find_library('dl', required: false) python = find_program('python3', native: true, version: '>=3.10') bash = find_program('bash', native: true) # The tests check their steps with assert, so NDEBUG must stay off. test_c_args = ['-UNDEBUG'] # The host terminal may preload a library into every child. Keep it out. test_env = environment() test_env.set('LD_PRELOAD', '') test_env.set('DYLD_INSERT_LIBRARIES', '') test_env.set('NM', find_program('nm', native: true).full_path()) # [name, sources, dependencies, suites] term_tests = [ ['unicode-test', files('unicode/unicode_test.c'), [], []], ['term-input-test', files('input_test.c'), [], []], ['term-test', files('term_test.c'), [thread_dep], ['isa']], ['write-fuzz-test', files('write_fuzz_test.c'), [], ['isa']], ['spec-test', files('spec_test.c'), [], []], ['model-test', files('model_test.c', 'model.c'), [], ['isa']], ['model-row-test', files('model_row_test.c', 'model.c'), [], []], ['gstore-test', files('gstore_test.c'), [], []], ['hist-test', files('hist_test.c'), [], []], ['history-text-test', files('history_text_test.c'), [thread_dep], []], ['snapshot-scroll-arena-test', files('snapshot_scroll_arena_test.c'), [], []], ['view-test', files('view_test.c'), [], []], ['resize-property-test', files('resize_property_test.c'), [], []], ['term-resize-failure-test', files('resize_failure_test.c'), [dl_dep], ['extlib']], ['dcs-test', files('dcs_test.c'), [], []], ['osc-test', files('osc_test.c'), [], []], ] test_helpers_inc = include_directories('helpers') term_test_exes = {} foreach entry : term_tests exe = executable(entry[0], entry[1], c_args: test_c_args, include_directories: test_helpers_inc, dependencies: [term_internal_dep] + entry[2], ) term_test_exes += {entry[0]: exe} test(entry[0], exe, args: entry[0] == 'write-fuzz-test' ? [get_option('write_fuzz_seeds').to_string()] : [], env: test_env, suite: ['unit'] + entry[3], timeout: 180, ) endforeach # Without -march, the core runs the best kernels the CPU supports. Run the # tests again on the lower levels, so each one is covered. if host_machine.cpu_family() == 'x86_64' and cc.get_argument_syntax() == 'gcc' and \ cc.get_define('__AVX2__', args: get_option('arch_flag') != '' ? [get_option('arch_flag')] : []) == '' foreach level : ['base', 'avx2'] level_env = test_env level_env.set('TERM_HEADLESS_ISA', level) foreach name : ['term-test', 'spec-test', 'model-test', 'view-test', 'term-input-test', 'hist-test', 'history-text-test'] test(name + '-' + level, term_test_exes[name], env: level_env, suite: ['unit', 'isa'], timeout: 180) endforeach endforeach endif # The amalgamation is the core as one term.c, the way a host builds it. The # tests that use only term.h run again against it. term_amalgamation = custom_target( 'term-amalgamation', output: ['term.c', 'term.h'], depfile: 'term-amalgamation.d', command: [python, files('../tools/amalgamate.py'), meson.project_source_root(), '@OUTDIR@', '@DEPFILE@'], ) term_amalgamation_lib = static_library( 'term-amalgamation', term_amalgamation[0], dependencies: [m_dep], override_options: ['c_std=c11', 'warning_level=3', 'werror=true'], build_by_default: false, ) foreach entry : term_tests if entry[0] in ['term-test', 'spec-test', 'view-test', 'dcs-test', 'osc-test', 'history-text-test', 'term-input-test', 'model-test', 'model-row-test', 'resize-property-test'] test(entry[0] + '-amalgamation', executable(entry[0] + '-amalgamation', entry[1], c_args: test_c_args, include_directories: [term_inc, test_helpers_inc], link_with: term_amalgamation_lib, dependencies: [m_dep] + entry[2], build_by_default: false), env: test_env, suite: ['unit', 'amalgamation'], timeout: 180) endif endforeach test('term-symbols-test', bash, args: [files('symbols_test.sh'), term_lib.get_static_lib(), meson.project_source_root() / 'include' / 'term', term_lib.get_shared_lib()], env: test_env, suite: 'unit', ) test('term-header-test', bash, args: [files('header_test.sh'), meson.project_source_root()], suite: 'unit', ) if cc.has_link_argument('-Wl,--wrap=realloc') and cc.has_link_argument('-Wl,--wrap=malloc') snapshot_failure_test = executable('snapshot-failure-test', 'snapshot_failure_test.c', c_args: test_c_args, link_args: ['-Wl,--wrap=realloc', '-Wl,--wrap=malloc'], dependencies: [term_internal_dep], ) test('snapshot-failure-test', snapshot_failure_test, env: test_env, suite: 'unit', ) endif # The project version comes in as a define, so the header macros cannot # drift from meson.build. version_test = executable('version-test', 'version_test.c', c_args: test_c_args + ['-DTERM_TEST_PROJECT_VERSION="@0@"'.format(meson.project_version())], dependencies: [term_internal_dep], ) test('version-test', version_test, env: test_env, suite: 'unit', ) test('term-cross-test', bash, args: [files('cross_test.sh'), meson.project_source_root()], suite: 'portability', timeout: 600, ) # The bridge is a shared library that Python loads, so a sanitized build # cannot run it. kitty_tests = get_option('kitty').require( host_machine.system() == 'linux' and get_option('b_sanitize') == 'none', error_message: 'The Kitty tests need an unsanitized Linux build', ) term_kitty_tests = kitty_tests.allowed() if term_kitty_tests kitty_bridge = shared_library('kitty_bridge', 'extern/kitty/screen_bridge.c', dependencies: term_internal_dep, ) kitty_env = environment() kitty_env.set('WSAP_KITTY_LIB', kitty_bridge.full_path()) test('kitty-test', python, args: files('extern/kitty/parser.py'), depends: kitty_bridge, env: kitty_env, suite: ['unit', 'kitty'], is_parallel: false, ) endif