summaryrefslogtreecommitdiff
path: root/tests/meson.build
blob: 42c442e6fc4f8d1bc921d3f730823a3eca049d4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
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', '')

# [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], []],
  ['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_headless_lib.get_static_lib(),
         meson.project_source_root() / 'include' / 'term',
         term_headless_lib.get_shared_lib()],
  suite: 'unit',
)
test('term-header-test', bash,
  args: [files('header_test.sh'), meson.project_source_root()],
  suite: 'unit',
)
test('term-cross-test', bash,
  args: [files('cross_test.sh'), meson.project_source_root()],
  suite: 'portability',
  timeout: 600,
)

if get_option('kitty_tests')
  if host_machine.system() != 'linux' or get_option('b_sanitize') != 'none'
    error('Kitty tests require an unsanitized Linux build')
  endif
  kitty_bridge = shared_library('term', '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: 'kitty',
    is_parallel: false,
  )
endif