summaryrefslogtreecommitdiff
path: root/tests/meson.build
blob: c6570d9d002f01382d07ef9f4d9ec0b3b4d292f2 (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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
test_exe = executable(
    'yasl-test',
    'test_lifecycle.c',
    include_directories: inc,
    link_with: yasl_lib.get_static_lib(),
    dependencies: deps,
)

add_test_setup('asan')
add_test_setup('tsan')
add_test_setup('msan')

test('basic', test_exe)

shared_dep = declare_dependency(
    link_with: yasl_lib.get_shared_lib(),
    include_directories: include_directories('../include'),
)

shared_api_test = executable(
    'yasl-shared-api-test',
    'test_lifecycle.c',
    dependencies: shared_dep,
)
test('shared-api', shared_api_test)

if add_languages('cpp', native: false, required: false)
    cpp = meson.get_compiler('cpp')
    cpp_api_test = executable(
        'yasl-cpp-api-test',
        'test_api.cpp',
        dependencies: shared_dep,
        cpp_args: cpp.get_supported_arguments('-pedantic-errors') + [
            '-DYASL_HAS_WAYLAND=' + (has_wayland ? '1' : '0'),
            '-DYASL_HAS_X11=' + (has_x11 ? '1' : '0'),
            '-DYASL_HAS_COCOA=' + (has_cocoa ? '1' : '0'),
        ],
        override_options: ['cpp_std=c++11'],
    )
    test('cpp-api', cpp_api_test)
endif

python = find_program('python3', native: true)
if system == 'linux' or system == 'darwin'
    nm = find_program('nm', native: false)
    export_args = ['--platform=' + system]
    if get_option('b_sanitize').contains('address')
        # Clang's ASan instrumentation exports these linker-generated markers.
        export_args += ['--allow-export=__start_asan_globals',
                        '--allow-export=__stop_asan_globals']
    endif
    exported_headers = files(
        '../include/yasl/yasl.h',
        '../include/yasl/timing.h',
        '../include/yasl/loop.h',
        '../include/yasl/native.h',
    )
    if has_wayland
        exported_headers += files('../include/yasl/native/wayland.h')
    endif
    if has_x11
        exported_headers += files('../include/yasl/native/x11.h')
    endif
    if has_cocoa
        exported_headers += files('../include/yasl/native/cocoa.h')
    endif
    test('public-exports', python,
        args: [files('helpers/check_exports.py')] + export_args +
              [nm, yasl_lib.get_shared_lib(), exported_headers],
    )
endif

contracts_test = executable(
    'yasl-contracts-test',
    'common/test_contracts.c',
    include_directories: inc,
    dependencies: yasl_dep,
)
test('contracts', contracts_test)

keyboard_test = executable('yasl-keyboard-test', 'common/test_keyboard.c',
    include_directories: inc, dependencies: yasl_dep,
)
test('keyboard', keyboard_test)

utf8_test = executable('yasl-utf8-test', 'common/test_utf8.c',
    include_directories: inc, dependencies: yasl_dep,
)
test('utf8', utf8_test)

timer_test = executable(
    'yasl-timer-test',
    'common/test_timers.c',
    include_directories: inc,
    dependencies: yasl_dep,
)
test('timers', timer_test)

input_alloc_test = executable(
    'yasl-input-alloc-test',
    ['common/test_input_alloc.c', '../src/common/input.c'],
    include_directories: inc,
    c_args: ['-Dmalloc=yasl_test_malloc'],
)
test('input-allocation-failure', input_alloc_test)

selection_test = executable(
    'yasl-selection-test',
    'common/test_selection.c',
    dependencies: yasl_dep,
)
test('selection', selection_test)

tablet_example_test = executable('yasl-tablet-example-test', 'common/test_tablet_example.c',
    dependencies: yasl_dep,
)
test('tablet-example', tablet_example_test)

if has_x11
    tablet_x11_test = executable('yasl-tablet-x11-test', 'x11/test_tablet.c',
        include_directories: inc, dependencies: yasl_dep,
    )
    test('tablet-x11', tablet_x11_test)
    if get_option('x11_tablet_tests')
        xorg = find_program('/usr/lib/Xorg', '/usr/lib/xorg/Xorg', 'Xorg')
        native_tablet_test = executable('yasl-tablet-x11-native-test', 'x11/test_tablet_native.c',
            dependencies: yasl_dep,
        )
        test('tablet-x11-native', python,
            args: [files('helpers/run_x11_tablet.py'), xorg, native_tablet_test], timeout: 30,
        )
    endif
elif get_option('x11_tablet_tests')
    error('Native X11 tablet tests require the X11 backend.')
endif

if has_wayland
    clipboard_wayland_test = executable('yasl-clipboard-wayland-test', 'wayland/test_clipboard.c',
        include_directories: inc, dependencies: yasl_dep,
    )
    test('clipboard-wayland', clipboard_wayland_test)
    keyboard_wayland_test = executable('yasl-keyboard-wayland-test', 'wayland/test_keyboard.c',
        include_directories: inc, dependencies: yasl_dep,
    )
    test('keyboard-wayland', keyboard_wayland_test)
    ime_test = executable('yasl-ime-test', 'wayland/test_input.c',
        include_directories: inc,
        dependencies: yasl_dep,
    )
    test('ime-ownership', ime_test)
    tablet_wayland_test = executable('yasl-tablet-wayland-test', 'wayland/test_tablet.c',
        include_directories: inc, dependencies: yasl_dep,
    )
    test('tablet-wayland', tablet_wayland_test)
    cursor_wayland_test = executable('yasl-cursor-wayland-test', 'wayland/test_cursor.c',
        include_directories: inc, dependencies: yasl_dep,
    )
    test('cursor-wayland', cursor_wayland_test)
endif

benchmark_exe = executable(
    'yasl-benchmark',
    'benchmark.c',
    include_directories: inc,
    dependencies: yasl_dep,
)
benchmark('performance', benchmark_exe)

if get_option('integration_tests')
    if has_cocoa
        test('hello-cocoa-window', hello_example,
            args: ['--smoke-test'], timeout: 20,
        )
        native_test = executable('yasl-native-test', 'cocoa/test_native.c',
            dependencies: shared_dep,
        )
        test('native', native_test, timeout: 20)
        ownership_test = executable('yasl-ownership-test', 'cocoa/test_ownership.m',
            dependencies: [shared_dep, deps],
        )
        test('native-ownership', ownership_test, timeout: 20)
        keyboard_cocoa_test = executable('yasl-keyboard-cocoa-test', 'cocoa/test_keyboard.m',
            dependencies: [shared_dep, deps],
        )
        test('keyboard-cocoa', keyboard_cocoa_test, timeout: 20)
        tablet_cocoa_test = executable('yasl-tablet-cocoa-test', 'cocoa/test_tablet.m',
            dependencies: [shared_dep, deps],
        )
        test('tablet-cocoa', tablet_cocoa_test, timeout: 20)
        cursor_cocoa_test = executable('yasl-cursor-cocoa-test', 'cocoa/test_cursor.m',
            dependencies: [shared_dep, deps],
        )
        test('cursor-cocoa', cursor_cocoa_test, timeout: 20)
        test('tablet-cocoa-window', tablet_example,
            args: ['--backend', 'cocoa', '--smoke-test'], timeout: 20,
        )
    else
        if not has_wayland or not has_x11
            error('Linux integration tests require Wayland and X11.')
        endif
        backend_test = executable(
            'yasl-backend-test',
            'common/test_backends.c',
            dependencies: [shared_dep, deps],
        )
        input_x11_test = executable('yasl-input-x11-test', 'x11/test_input.c',
            include_directories: inc, dependencies: yasl_dep,
        )
        weston = find_program('weston')
        xwayland = find_program('Xwayland')
        test('backends', python,
            args: [files('helpers/run_backends.py'), weston, xwayland,
                   backend_test, timer_test, tablet_example, hello_example, input_x11_test],
            timeout: 60,
        )
    endif
endif