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,119 +130,64 @@ if have_installed_tests
|
|||||||
)
|
)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
unit_tests = executable('mutter-test-unit-tests',
|
wayland_test_utils = [
|
||||||
sources: [
|
'meta-wayland-test-driver.c',
|
||||||
'unit-tests.c',
|
'meta-wayland-test-driver.h',
|
||||||
'boxes-tests.c',
|
'meta-wayland-test-utils.c',
|
||||||
'boxes-tests.h',
|
'meta-wayland-test-utils.h',
|
||||||
'monitor-config-migration-unit-tests.c',
|
test_driver_server_header,
|
||||||
'monitor-config-migration-unit-tests.h',
|
test_driver_protocol_code,
|
||||||
'monitor-store-unit-tests.c',
|
]
|
||||||
'monitor-store-unit-tests.h',
|
|
||||||
'monitor-transform-tests.c',
|
|
||||||
'monitor-transform-tests.h',
|
|
||||||
'orientation-manager-unit-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,
|
|
||||||
)
|
|
||||||
|
|
||||||
monitor_unit_tests = executable('mutter-monitor-unit-tests',
|
# The test_cases is a list of dictionaries each one representing one test case.
|
||||||
sources: [
|
# It consists of the following keys:
|
||||||
'monitor-unit-tests.c',
|
# - 'name' - the test name
|
||||||
],
|
# - 'suite' - the test suite
|
||||||
include_directories: tests_includes,
|
# - 'sources' - a list of source code files
|
||||||
c_args: tests_c_args,
|
|
||||||
dependencies: libmutter_test_dep,
|
|
||||||
install: have_installed_tests,
|
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
|
||||||
)
|
|
||||||
|
|
||||||
headless_start_test = executable('mutter-headless-start-test',
|
test_cases = []
|
||||||
sources: [
|
privileged_test_cases = []
|
||||||
'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',
|
test_cases += [
|
||||||
sources: [
|
{
|
||||||
'stage-view-tests.c',
|
'name': 'unit',
|
||||||
],
|
'suite': 'unit',
|
||||||
include_directories: tests_includes,
|
'sources': [
|
||||||
c_args: tests_c_args,
|
'unit-tests.c',
|
||||||
dependencies: libmutter_test_dep,
|
'boxes-tests.c',
|
||||||
install: have_installed_tests,
|
'boxes-tests.h',
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
'monitor-config-migration-unit-tests.c',
|
||||||
)
|
'monitor-config-migration-unit-tests.h',
|
||||||
|
'monitor-store-unit-tests.c',
|
||||||
anonymous_file_test = executable('anonymous-file-tests',
|
'monitor-store-unit-tests.h',
|
||||||
sources: [
|
'monitor-transform-tests.c',
|
||||||
'anonymous-file.c',
|
'monitor-transform-tests.h',
|
||||||
],
|
'orientation-manager-unit-tests.c',
|
||||||
include_directories: tests_includes,
|
],
|
||||||
c_args: tests_c_args,
|
},
|
||||||
dependencies: [tests_deps],
|
{
|
||||||
install: have_installed_tests,
|
'name': 'monitor-unit',
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
'suite': 'backend',
|
||||||
)
|
'sources': [ 'monitor-unit-tests.c', ],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'headless-start',
|
||||||
|
'suite': 'backend',
|
||||||
|
'sources': [ 'headless-start-test.c', ],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'stage-views',
|
||||||
|
'suite': 'compositor',
|
||||||
|
'sources': [ 'stage-view-tests.c', ],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'anonymous-file',
|
||||||
|
'suite': 'unit',
|
||||||
|
'sources': [ 'anonymous-file.c', ],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
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,71 +203,97 @@ 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',
|
||||||
include_directories: tests_includes,
|
'sources': [ 'kms-utils-unit-tests.c', ],
|
||||||
c_args: tests_c_args,
|
},
|
||||||
dependencies: libmutter_test_dep,
|
{
|
||||||
install: have_installed_tests,
|
'name': 'native-unit',
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
'suite': 'backends/native',
|
||||||
)
|
'sources': [
|
||||||
|
'native-headless.c',
|
||||||
|
'native-screen-cast.c',
|
||||||
|
'native-screen-cast.h',
|
||||||
|
'native-virtual-monitor.c',
|
||||||
|
'native-virtual-monitor.h',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'pointer-constraints',
|
||||||
|
'suite': 'backends/native',
|
||||||
|
'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,
|
'meta-kms-test-utils.c',
|
||||||
dependencies: libmutter_test_dep,
|
'meta-kms-test-utils.h',
|
||||||
install: have_installed_tests,
|
'native-kms-device.c',
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
],
|
||||||
)
|
},
|
||||||
|
{
|
||||||
|
'name': 'kms-update',
|
||||||
|
'suite': 'backends/native/kms',
|
||||||
|
'sources': [
|
||||||
|
'meta-kms-test-utils.c',
|
||||||
|
'meta-kms-test-utils.h',
|
||||||
|
'native-kms-updates.c',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
native_kms_render_tests = executable('mutter-native-kms-render',
|
# Wayland tests
|
||||||
sources: [
|
test_cases += [
|
||||||
'native-kms-render.c',
|
{
|
||||||
],
|
'name': 'wayland-unit',
|
||||||
include_directories: tests_includes,
|
'suite': 'wayland',
|
||||||
c_args: tests_c_args,
|
'sources': [
|
||||||
dependencies: libmutter_test_dep,
|
'wayland-unit-tests.c',
|
||||||
install: have_installed_tests,
|
wayland_test_utils,
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
],
|
||||||
)
|
},
|
||||||
|
]
|
||||||
|
|
||||||
native_kms_device_tests = executable('mutter-native-kms-device',
|
foreach test_case: test_cases
|
||||||
sources: [
|
test_executable = executable('mutter-' + test_case['name'],
|
||||||
'meta-kms-test-utils.c',
|
sources: test_case['sources'],
|
||||||
'meta-kms-test-utils.h',
|
include_directories: tests_includes,
|
||||||
'native-kms-device.c',
|
c_args: tests_c_args,
|
||||||
],
|
dependencies: libmutter_test_dep,
|
||||||
include_directories: tests_includes,
|
install: have_installed_tests,
|
||||||
c_args: tests_c_args,
|
install_dir: mutter_installed_tests_libexecdir,
|
||||||
dependencies: libmutter_test_dep,
|
)
|
||||||
install: have_installed_tests,
|
|
||||||
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,
|
endforeach
|
||||||
c_args: tests_c_args,
|
|
||||||
dependencies: libmutter_test_dep,
|
|
||||||
install: have_installed_tests,
|
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
|
||||||
)
|
|
||||||
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