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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
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]
wsap_vtcore_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'), [], []],
['api-args-test', files('api_args_test.c'), [], []],
]
test_helpers_inc = include_directories('helpers')
wsap_vtcore_test_exes = {}
foreach entry : wsap_vtcore_tests
exe = executable(entry[0], entry[1],
c_args: test_c_args,
include_directories: test_helpers_inc,
dependencies: [wsap_vtcore_internal_dep] + entry[2],
)
wsap_vtcore_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('WSAP_VTCORE_ISA', level)
foreach name : ['term-test', 'spec-test', 'model-test', 'view-test', 'term-input-test',
'hist-test', 'history-text-test']
test(name + '-' + level, wsap_vtcore_test_exes[name], env: level_env,
suite: ['unit', 'isa'], timeout: 180)
endforeach
endforeach
endif
# The amalgamation is the core as one wsap_vtcore.c, the way a host builds
# it. The tests that use only wsap_vtcore.h run again against it.
wsap_vtcore_amalgamation = custom_target(
'term-amalgamation',
output: ['wsap_vtcore.c', 'wsap_vtcore.h'],
depfile: 'term-amalgamation.d',
command: [python, files('../tools/amalgamate.py'),
meson.project_source_root(), '@OUTDIR@', '@DEPFILE@'],
)
wsap_vtcore_amalgamation_lib = static_library(
'term-amalgamation',
wsap_vtcore_amalgamation[0],
dependencies: [m_dep, thread_dep],
override_options: ['c_std=c11', 'warning_level=3', 'werror=true'],
build_by_default: false,
)
foreach entry : wsap_vtcore_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', 'api-args-test']
test(entry[0] + '-amalgamation',
executable(entry[0] + '-amalgamation', entry[1],
c_args: test_c_args,
include_directories: [wsap_vtcore_inc, test_helpers_inc],
link_with: wsap_vtcore_amalgamation_lib,
dependencies: [m_dep, thread_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'), wsap_vtcore_lib.get_static_lib(),
meson.project_source_root() / 'include' / 'wsap_vtcore',
wsap_vtcore_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: [wsap_vtcore_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 + ['-DWSAP_VTCORE_TEST_PROJECT_VERSION="@0@"'.format(meson.project_version())],
dependencies: [wsap_vtcore_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',
)
wsap_vtcore_kitty_tests = kitty_tests.allowed()
if wsap_vtcore_kitty_tests
kitty_bridge = shared_library('kitty_bridge', 'extern/kitty/screen_bridge.c',
dependencies: wsap_vtcore_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
|