tests: Decrease boiler plate needed for adding more tests
Structure tests in a list of dictionaries, instead of requiring each test to have its own executable(...) and test(...) statement. The intention of this is to make it easier to add more test cases. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2262>
This commit is contained in:
parent
afca974405
commit
5588f2a21c
@ -27,12 +27,9 @@ endif
|
|||||||
|
|
||||||
virtme_run = find_program('virtme-run.sh')
|
virtme_run = find_program('virtme-run.sh')
|
||||||
|
|
||||||
foreach test: privileged_tests
|
foreach test_case: privileged_tests
|
||||||
test_name = test[0]
|
test('kvm-' + test_case['name'], virtme_run,
|
||||||
test_executable = test[1]
|
suite: ['core', 'mutter/kvm', 'mutter/kvm/' + test_case['suite']],
|
||||||
|
|
||||||
test('kvm-' + test_name, virtme_run,
|
|
||||||
suite: ['core', 'mutter/native/kvm'],
|
|
||||||
depends: [
|
depends: [
|
||||||
kernel_image_target,
|
kernel_image_target,
|
||||||
],
|
],
|
||||||
@ -41,7 +38,7 @@ foreach test: privileged_tests
|
|||||||
kernel_image_path,
|
kernel_image_path,
|
||||||
meta_dbus_runner.full_path(),
|
meta_dbus_runner.full_path(),
|
||||||
'--kvm',
|
'--kvm',
|
||||||
test_executable.full_path(),
|
test_case['executable'].full_path(),
|
||||||
meson.current_build_dir(),
|
meson.current_build_dir(),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
@ -130,8 +130,29 @@ if have_installed_tests
|
|||||||
)
|
)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
unit_tests = executable('mutter-test-unit-tests',
|
wayland_test_utils = [
|
||||||
sources: [
|
'meta-wayland-test-driver.c',
|
||||||
|
'meta-wayland-test-driver.h',
|
||||||
|
'meta-wayland-test-utils.c',
|
||||||
|
'meta-wayland-test-utils.h',
|
||||||
|
test_driver_server_header,
|
||||||
|
test_driver_protocol_code,
|
||||||
|
]
|
||||||
|
|
||||||
|
# The test_cases is a list of dictionaries each one representing one test case.
|
||||||
|
# It consists of the following keys:
|
||||||
|
# - 'name' - the test name
|
||||||
|
# - 'suite' - the test suite
|
||||||
|
# - 'sources' - a list of source code files
|
||||||
|
|
||||||
|
test_cases = []
|
||||||
|
privileged_test_cases = []
|
||||||
|
|
||||||
|
test_cases += [
|
||||||
|
{
|
||||||
|
'name': 'unit',
|
||||||
|
'suite': 'unit',
|
||||||
|
'sources': [
|
||||||
'unit-tests.c',
|
'unit-tests.c',
|
||||||
'boxes-tests.c',
|
'boxes-tests.c',
|
||||||
'boxes-tests.h',
|
'boxes-tests.h',
|
||||||
@ -143,106 +164,30 @@ unit_tests = executable('mutter-test-unit-tests',
|
|||||||
'monitor-transform-tests.h',
|
'monitor-transform-tests.h',
|
||||||
'orientation-manager-unit-tests.c',
|
'orientation-manager-unit-tests.c',
|
||||||
],
|
],
|
||||||
include_directories: tests_includes,
|
},
|
||||||
c_args: tests_c_args,
|
{
|
||||||
dependencies: libmutter_test_dep,
|
'name': 'monitor-unit',
|
||||||
install: have_installed_tests,
|
'suite': 'backend',
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
'sources': [ 'monitor-unit-tests.c', ],
|
||||||
)
|
},
|
||||||
|
{
|
||||||
monitor_unit_tests = executable('mutter-monitor-unit-tests',
|
'name': 'headless-start',
|
||||||
sources: [
|
'suite': 'backend',
|
||||||
'monitor-unit-tests.c',
|
'sources': [ 'headless-start-test.c', ],
|
||||||
],
|
},
|
||||||
include_directories: tests_includes,
|
{
|
||||||
c_args: tests_c_args,
|
'name': 'stage-views',
|
||||||
dependencies: libmutter_test_dep,
|
'suite': 'compositor',
|
||||||
install: have_installed_tests,
|
'sources': [ 'stage-view-tests.c', ],
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
},
|
||||||
)
|
{
|
||||||
|
'name': 'anonymous-file',
|
||||||
headless_start_test = executable('mutter-headless-start-test',
|
'suite': 'unit',
|
||||||
sources: [
|
'sources': [ 'anonymous-file.c', ],
|
||||||
'headless-start-test.c',
|
},
|
||||||
],
|
]
|
||||||
include_directories: tests_includes,
|
|
||||||
c_args: tests_c_args,
|
|
||||||
dependencies: libmutter_test_dep,
|
|
||||||
install: have_installed_tests,
|
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
|
||||||
)
|
|
||||||
|
|
||||||
stage_view_tests = executable('mutter-stage-view-tests',
|
|
||||||
sources: [
|
|
||||||
'stage-view-tests.c',
|
|
||||||
],
|
|
||||||
include_directories: tests_includes,
|
|
||||||
c_args: tests_c_args,
|
|
||||||
dependencies: libmutter_test_dep,
|
|
||||||
install: have_installed_tests,
|
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
|
||||||
)
|
|
||||||
|
|
||||||
anonymous_file_test = executable('anonymous-file-tests',
|
|
||||||
sources: [
|
|
||||||
'anonymous-file.c',
|
|
||||||
],
|
|
||||||
include_directories: tests_includes,
|
|
||||||
c_args: tests_c_args,
|
|
||||||
dependencies: [tests_deps],
|
|
||||||
install: have_installed_tests,
|
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
|
||||||
)
|
|
||||||
|
|
||||||
if have_native_tests
|
if have_native_tests
|
||||||
native_kms_utils_tests = executable('mutter-native-kms-utils-tests',
|
|
||||||
sources: [
|
|
||||||
'kms-utils-unit-tests.c',
|
|
||||||
],
|
|
||||||
include_directories: tests_includepath,
|
|
||||||
c_args: tests_c_args,
|
|
||||||
dependencies: [tests_deps],
|
|
||||||
install: have_installed_tests,
|
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
|
||||||
)
|
|
||||||
|
|
||||||
native_headless_tests = executable('mutter-native-headless-tests',
|
|
||||||
sources: [
|
|
||||||
'native-headless.c',
|
|
||||||
'native-screen-cast.c',
|
|
||||||
'native-screen-cast.h',
|
|
||||||
'native-virtual-monitor.c',
|
|
||||||
'native-virtual-monitor.h',
|
|
||||||
],
|
|
||||||
include_directories: tests_includes,
|
|
||||||
c_args: tests_c_args,
|
|
||||||
dependencies: libmutter_test_dep,
|
|
||||||
install: have_installed_tests,
|
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
|
||||||
)
|
|
||||||
|
|
||||||
pointer_constraints_tests = executable('mutter-native-pointer-constraints',
|
|
||||||
sources: [
|
|
||||||
'native-pointer-constraints.c',
|
|
||||||
],
|
|
||||||
include_directories: tests_includes,
|
|
||||||
c_args: tests_c_args,
|
|
||||||
dependencies: libmutter_test_dep,
|
|
||||||
install: have_installed_tests,
|
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
|
||||||
)
|
|
||||||
|
|
||||||
ref_test_sanity = executable('mutter-ref-test-sanity',
|
|
||||||
sources: [
|
|
||||||
'ref-test-sanity.c',
|
|
||||||
],
|
|
||||||
include_directories: tests_includes,
|
|
||||||
c_args: tests_c_args,
|
|
||||||
dependencies: libmutter_test_dep,
|
|
||||||
install: have_installed_tests,
|
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
|
||||||
)
|
|
||||||
|
|
||||||
screen_cast_client = executable('mutter-screen-cast-client',
|
screen_cast_client = executable('mutter-screen-cast-client',
|
||||||
sources: [
|
sources: [
|
||||||
'screen-cast-client.c',
|
'screen-cast-client.c',
|
||||||
@ -258,52 +203,83 @@ if have_native_tests
|
|||||||
install_dir: mutter_installed_tests_libexecdir,
|
install_dir: mutter_installed_tests_libexecdir,
|
||||||
)
|
)
|
||||||
|
|
||||||
native_persistent_virtual_monitor = executable(
|
# Native backend tests
|
||||||
'mutter-persistent-virtual-monitor',
|
test_cases += [
|
||||||
sources: [
|
{
|
||||||
'native-persistent-virtual-monitor.c',
|
'name': 'kms-utils',
|
||||||
|
'suite': 'backends/native',
|
||||||
|
'sources': [ 'kms-utils-unit-tests.c', ],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'native-unit',
|
||||||
|
'suite': 'backends/native',
|
||||||
|
'sources': [
|
||||||
|
'native-headless.c',
|
||||||
|
'native-screen-cast.c',
|
||||||
|
'native-screen-cast.h',
|
||||||
|
'native-virtual-monitor.c',
|
||||||
|
'native-virtual-monitor.h',
|
||||||
],
|
],
|
||||||
include_directories: tests_includes,
|
},
|
||||||
c_args: tests_c_args,
|
{
|
||||||
dependencies: libmutter_test_dep,
|
'name': 'pointer-constraints',
|
||||||
install: have_installed_tests,
|
'suite': 'backends/native',
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
'sources': [ 'native-pointer-constraints.c' ],
|
||||||
)
|
},
|
||||||
|
{
|
||||||
|
'name': 'ref-test-sanity',
|
||||||
|
'suite': 'backends/native',
|
||||||
|
'sources': [ 'ref-test-sanity.c' ],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'persistent-virtual-monitor',
|
||||||
|
'suite': 'backends/native',
|
||||||
|
'sources': [ 'native-persistent-virtual-monitor.c' ],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
wayland_tests = executable('mutter-wayland-tests',
|
# Privileged tests
|
||||||
sources: [
|
privileged_test_cases += [
|
||||||
'meta-wayland-test-driver.c',
|
{
|
||||||
'meta-wayland-test-driver.h',
|
'name': 'kms-render',
|
||||||
'meta-wayland-test-utils.c',
|
'suite': 'backends/native/kms',
|
||||||
'meta-wayland-test-utils.h',
|
'sources': [ 'native-kms-render.c' ],
|
||||||
'wayland-unit-tests.c',
|
},
|
||||||
test_driver_server_header,
|
{
|
||||||
test_driver_protocol_code,
|
'name': 'kms-device',
|
||||||
],
|
'suite': 'backends/native/kms',
|
||||||
include_directories: tests_includes,
|
'sources': [
|
||||||
c_args: tests_c_args,
|
|
||||||
dependencies: libmutter_test_dep,
|
|
||||||
install: have_installed_tests,
|
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
|
||||||
)
|
|
||||||
|
|
||||||
native_kms_render_tests = executable('mutter-native-kms-render',
|
|
||||||
sources: [
|
|
||||||
'native-kms-render.c',
|
|
||||||
],
|
|
||||||
include_directories: tests_includes,
|
|
||||||
c_args: tests_c_args,
|
|
||||||
dependencies: libmutter_test_dep,
|
|
||||||
install: have_installed_tests,
|
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
|
||||||
)
|
|
||||||
|
|
||||||
native_kms_device_tests = executable('mutter-native-kms-device',
|
|
||||||
sources: [
|
|
||||||
'meta-kms-test-utils.c',
|
'meta-kms-test-utils.c',
|
||||||
'meta-kms-test-utils.h',
|
'meta-kms-test-utils.h',
|
||||||
'native-kms-device.c',
|
'native-kms-device.c',
|
||||||
],
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'kms-update',
|
||||||
|
'suite': 'backends/native/kms',
|
||||||
|
'sources': [
|
||||||
|
'meta-kms-test-utils.c',
|
||||||
|
'meta-kms-test-utils.h',
|
||||||
|
'native-kms-updates.c',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
# Wayland tests
|
||||||
|
test_cases += [
|
||||||
|
{
|
||||||
|
'name': 'wayland-unit',
|
||||||
|
'suite': 'wayland',
|
||||||
|
'sources': [
|
||||||
|
'wayland-unit-tests.c',
|
||||||
|
wayland_test_utils,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
foreach test_case: test_cases
|
||||||
|
test_executable = executable('mutter-' + test_case['name'],
|
||||||
|
sources: test_case['sources'],
|
||||||
include_directories: tests_includes,
|
include_directories: tests_includes,
|
||||||
c_args: tests_c_args,
|
c_args: tests_c_args,
|
||||||
dependencies: libmutter_test_dep,
|
dependencies: libmutter_test_dep,
|
||||||
@ -311,18 +287,13 @@ if have_native_tests
|
|||||||
install_dir: mutter_installed_tests_libexecdir,
|
install_dir: mutter_installed_tests_libexecdir,
|
||||||
)
|
)
|
||||||
|
|
||||||
native_kms_update_tests = executable('mutter-native-kms-update-tests',
|
test(test_case['name'], test_executable,
|
||||||
sources: [
|
suite: ['core', 'mutter/' + test_case['suite']],
|
||||||
'meta-kms-test-utils.c',
|
env: test_env,
|
||||||
'meta-kms-test-utils.h',
|
is_parallel: false,
|
||||||
'native-kms-updates.c',
|
timeout: 60,
|
||||||
],
|
|
||||||
include_directories: tests_includes,
|
|
||||||
c_args: tests_c_args,
|
|
||||||
dependencies: libmutter_test_dep,
|
|
||||||
install: have_installed_tests,
|
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
|
||||||
)
|
)
|
||||||
|
endforeach
|
||||||
endif
|
endif
|
||||||
|
|
||||||
stacking_tests = [
|
stacking_tests = [
|
||||||
@ -367,103 +338,34 @@ foreach stacking_test: stacking_tests
|
|||||||
)
|
)
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
test('normal', unit_tests,
|
|
||||||
suite: ['core', 'mutter/unit'],
|
|
||||||
env: test_env,
|
|
||||||
is_parallel: false,
|
|
||||||
timeout: 60,
|
|
||||||
)
|
|
||||||
|
|
||||||
test('monitors', monitor_unit_tests,
|
|
||||||
suite: ['core', 'mutter/unit'],
|
|
||||||
env: test_env,
|
|
||||||
is_parallel: false,
|
|
||||||
timeout: 60,
|
|
||||||
)
|
|
||||||
|
|
||||||
test('headless-start', headless_start_test,
|
|
||||||
suite: ['core', 'mutter/unit'],
|
|
||||||
env: test_env,
|
|
||||||
is_parallel: false,
|
|
||||||
timeout: 60,
|
|
||||||
)
|
|
||||||
|
|
||||||
test('stage-view', stage_view_tests,
|
|
||||||
suite: ['core', 'mutter/unit'],
|
|
||||||
env: test_env,
|
|
||||||
is_parallel: false,
|
|
||||||
timeout: 60,
|
|
||||||
)
|
|
||||||
|
|
||||||
test('anonymous-file', anonymous_file_test,
|
|
||||||
suite: ['core', 'mutter/unit'],
|
|
||||||
env: test_env,
|
|
||||||
is_parallel: false,
|
|
||||||
timeout: 60,
|
|
||||||
)
|
|
||||||
|
|
||||||
if have_native_tests
|
|
||||||
test('native-kms-utils', native_kms_utils_tests,
|
|
||||||
suite: ['core', 'mutter/native/kms'],
|
|
||||||
env: test_env,
|
|
||||||
is_parallel: false,
|
|
||||||
timeout: 60,
|
|
||||||
)
|
|
||||||
|
|
||||||
test('native-headless', native_headless_tests,
|
|
||||||
suite: ['core', 'mutter/native/headless'],
|
|
||||||
env: test_env,
|
|
||||||
is_parallel: false,
|
|
||||||
timeout: 60,
|
|
||||||
)
|
|
||||||
|
|
||||||
test('native-pointer-constraints', pointer_constraints_tests,
|
|
||||||
suite: ['core', 'mutter/native/input'],
|
|
||||||
env: test_env,
|
|
||||||
is_parallel: false,
|
|
||||||
timeout: 60,
|
|
||||||
)
|
|
||||||
|
|
||||||
test('ref-test-sanity', ref_test_sanity,
|
|
||||||
suite: ['core', 'mutter/ref-test/sanity'],
|
|
||||||
env: test_env,
|
|
||||||
is_parallel: false,
|
|
||||||
timeout: 60,
|
|
||||||
)
|
|
||||||
|
|
||||||
test('native-persistent-virtual-monitor', native_persistent_virtual_monitor,
|
|
||||||
suite: ['core', 'mutter/native/persistent-virtual-monitor'],
|
|
||||||
env: test_env,
|
|
||||||
is_parallel: false,
|
|
||||||
timeout: 60,
|
|
||||||
)
|
|
||||||
|
|
||||||
test('wayland', wayland_tests,
|
|
||||||
suite: ['core', 'mutter/unit'],
|
|
||||||
env: test_env,
|
|
||||||
is_parallel: false,
|
|
||||||
timeout: 60,
|
|
||||||
)
|
|
||||||
endif
|
|
||||||
|
|
||||||
if have_kvm_tests or have_tty_tests
|
if have_kvm_tests or have_tty_tests
|
||||||
privileged_tests = [
|
privileged_tests = []
|
||||||
[ 'kms-render', native_kms_render_tests ],
|
foreach test_case: privileged_test_cases
|
||||||
[ 'kms-device', native_kms_device_tests ],
|
test_executable = executable('mutter-' + test_case['name'],
|
||||||
[ 'kms-update', native_kms_update_tests ],
|
sources: test_case['sources'],
|
||||||
|
include_directories: tests_includes,
|
||||||
|
c_args: tests_c_args,
|
||||||
|
dependencies: libmutter_test_dep,
|
||||||
|
install: have_installed_tests,
|
||||||
|
install_dir: mutter_installed_tests_libexecdir,
|
||||||
|
)
|
||||||
|
privileged_tests += [
|
||||||
|
{
|
||||||
|
'name': test_case['name'],
|
||||||
|
'suite': test_case['suite'],
|
||||||
|
'executable': test_executable,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
endforeach
|
||||||
|
|
||||||
if have_kvm_tests
|
if have_kvm_tests
|
||||||
subdir('kvm')
|
subdir('kvm')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if have_tty_tests
|
if have_tty_tests
|
||||||
foreach test: privileged_tests
|
foreach test_case: privileged_tests
|
||||||
test_name = test[0]
|
test('tty-' + test_case['name'], test_case['executable'],
|
||||||
test_executable = test[1]
|
suite: ['core', 'mutter/tty', 'mutter/tty/' + test_case['suite']],
|
||||||
|
|
||||||
test('native-' + test_name, test_executable,
|
|
||||||
suite: ['core', 'mutter/native/tty'],
|
|
||||||
env: test_env,
|
env: test_env,
|
||||||
is_parallel: false,
|
is_parallel: false,
|
||||||
timeout: 60,
|
timeout: 60,
|
||||||
|
Loading…
Reference in New Issue
Block a user