python = find_program('python3', native: true) shared_dep = declare_dependency(link_with: yasl_lib.get_shared_lib(), include_directories: include_directories('../include')) foreach kind : ['static', 'shared'] dep = kind == 'static' ? yasl_dep : shared_dep public_test = executable('yasl-' + kind + '-api-test', 'test_lifecycle.c', dependencies: dep) test(kind + '-api', public_test) endforeach if add_languages('cpp', native: false, required: false) cpp_api = executable('yasl-cpp-api-test', 'test_api.cpp', dependencies: shared_dep, cpp_args: ['-pedantic-errors'], override_options: ['cpp_std=c++11']) test('cpp-api', cpp_api) endif headers = files('../include/yasl/yasl.h', '../include/yasl/cpu.h', '../include/yasl/gl.h', '../include/yasl/metal.h', '../include/yasl/desktop.h') if has_vulkan headers += files('../include/yasl/vulkan.h') endif foreach backend : ['wayland', 'x11', 'cocoa'] enabled = {'wayland': has_wayland, 'x11': has_x11, 'cocoa': has_cocoa}[backend] if enabled headers += files('../include/yasl/native/' + backend + '.h') endif endforeach nm = find_program('nm') export_args = ['--platform=' + system] if get_option('b_sanitize').contains('address') export_args += ['--allow-export=__start_asan_globals', '--allow-export=__stop_asan_globals'] endif test('public-exports', python, args: [files('helpers/check_exports.py')] + export_args + [nm, yasl_lib.get_shared_lib(), headers]) foreach unit : ['contracts', 'utf8', 'timers', 'loop', 'selection', 'events', 'gl_options'] exe = executable('yasl-' + unit + '-test', 'common/test_' + unit + '.c', include_directories: inc, dependencies: yasl_dep) test(unit, exe) endforeach keyboard_sources = files('common/test_keyboard.c') if not has_wayland keyboard_sources += files('../src/platform/wayland/keymap.c') endif if not has_x11 keyboard_sources += files('../src/platform/x11/keymap.c') endif if not has_cocoa keyboard_sources += files('../src/platform/cocoa/keymap.c') endif keyboard = executable('yasl-keyboard-test', keyboard_sources, include_directories: inc, dependencies: yasl_dep) test('keyboard', keyboard) alloc = executable('yasl-input-alloc-test', ['common/test_input_alloc.c', '../src/common/input.c'], include_directories: inc, c_args: ['-Dmalloc=yasl_private_test_malloc']) test('input-allocation-failure', alloc) if system == 'linux' desktop = executable('yasl-desktop-test', 'common/test_desktop.c', include_directories: inc, dependencies: yasl_dep) dbus_run = find_program('dbus-run-session', required: false) if has_dbus and dbus_run.found() test('desktop', dbus_run, args: ['--', desktop]) else test('desktop', desktop) endif endif if has_wayland foreach unit : ['state', 'clipboard', 'keyboard', 'input', 'tablet', 'cursor', 'relative_pointer', 'app_input', 'popup_positioner'] exe = executable('yasl-' + unit + '-wayland-test', 'wayland/test_' + unit + '.c', include_directories: inc, dependencies: yasl_dep) test(unit + '-wayland', exe) endforeach endif if has_x11 foreach unit : ['state', 'tablet'] exe = executable('yasl-' + unit + '-x11-test', 'x11/test_' + unit + '.c', include_directories: inc, dependencies: yasl_dep) test(unit + '-x11', exe) endforeach if get_option('x11_tablet_tests') xorg = find_program('/usr/lib/Xorg', '/usr/lib/xorg/Xorg', 'Xorg') native_tablet = executable('yasl-tablet-x11-native-test', 'x11/test_tablet_native.c', include_directories: inc, dependencies: yasl_dep) test('tablet-x11-native', python, args: [files('helpers/run_x11_tablet.py'), xorg, native_tablet], timeout: 30) endif endif if get_option('integration_tests') integration = executable('yasl-surface-integration', 'common/test_surface_integration.c', include_directories: inc, dependencies: yasl_dep) gl_integration = executable('yasl-gl-integration', 'common/test_gl.c', dependencies: yasl_dep) vulkan_integration = '-' if has_vulkan vulkan_integration = executable('yasl-vulkan-integration', 'common/test_vulkan.c', dependencies: yasl_dep) endif if system == 'linux' weston = find_program('weston') xwayland = find_program('Xwayland') test('surface-backends', python, args: [files('helpers/run_surfaces.py'), weston, xwayland, integration, hello_example, tablet_example, gl_integration, vulkan_integration, notepad_example], timeout: 120) elif has_cocoa test('surface-cocoa', integration, args: ['cocoa'], timeout: 30) foreach unit : ['native', 'ownership', 'keyboard', 'tablet', 'cursor'] extension = unit == 'native' ? '.c' : '.m' exe = executable('yasl-' + unit + '-cocoa-test', 'cocoa/test_' + unit + extension, include_directories: inc, dependencies: yasl_dep) test(unit + '-cocoa', exe, timeout: 30) endforeach endif endif