test: meson: Use dictionaries instead of arrays to store test information

Tests are listed in meson.build using arrays that contain the test name
and source files at fixed positions. This isn't very readable, leading
to code using test[0], test[1] and test[2]. Replace the arrays with
dictionaries to improve readability.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
This commit is contained in:
Laurent Pinchart 2022-10-05 21:16:13 +03:00
parent 2ee8faf3c8
commit 8abcce31ee
15 changed files with 110 additions and 110 deletions

View file

@ -3,18 +3,18 @@
# Tests are listed in order of complexity.
# They are not alphabetically sorted.
camera_tests = [
['configuration_default', 'configuration_default.cpp'],
['configuration_set', 'configuration_set.cpp'],
['buffer_import', 'buffer_import.cpp'],
['statemachine', 'statemachine.cpp'],
['capture', 'capture.cpp'],
['camera_reconfigure', 'camera_reconfigure.cpp'],
{'name': 'configuration_default', 'sources': ['configuration_default.cpp']},
{'name': 'configuration_set', 'sources': ['configuration_set.cpp']},
{'name': 'buffer_import', 'sources': ['buffer_import.cpp']},
{'name': 'statemachine', 'sources': ['statemachine.cpp']},
{'name': 'capture', 'sources': ['capture.cpp']},
{'name': 'camera_reconfigure', 'sources': ['camera_reconfigure.cpp']},
]
foreach test : camera_tests
exe = executable(test[0], test[1],
exe = executable(test['name'], test['sources'],
dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
test(test[0], exe, suite : 'camera', is_parallel : false)
test(test['name'], exe, suite : 'camera', is_parallel : false)
endforeach

View file

@ -1,16 +1,16 @@
# SPDX-License-Identifier: CC0-1.0
control_tests = [
['control_info', 'control_info.cpp'],
['control_info_map', 'control_info_map.cpp'],
['control_list', 'control_list.cpp'],
['control_value', 'control_value.cpp'],
{'name': 'control_info', 'sources': ['control_info.cpp']},
{'name': 'control_info_map', 'sources': ['control_info_map.cpp']},
{'name': 'control_list', 'sources': ['control_list.cpp']},
{'name': 'control_value', 'sources': ['control_value.cpp']},
]
foreach test : control_tests
exe = executable(test[0], test[1],
exe = executable(test['name'], test['sources'],
dependencies : libcamera_public,
link_with : test_libraries,
include_directories : test_includes_internal)
test(test[0], exe, suite : 'controls', is_parallel : false)
test(test['name'], exe, suite : 'controls', is_parallel : false)
endforeach

View file

@ -5,16 +5,16 @@ if not gst_enabled
endif
gstreamer_tests = [
['single_stream_test', 'gstreamer_single_stream_test.cpp'],
['multi_stream_test', 'gstreamer_multi_stream_test.cpp'],
{'name': 'single_stream_test', 'sources': ['gstreamer_single_stream_test.cpp']},
{'name': 'multi_stream_test', 'sources': ['gstreamer_multi_stream_test.cpp']},
]
gstreamer_dep = dependency('gstreamer-1.0', required: true)
foreach test : gstreamer_tests
exe = executable(test[0], test[1], 'gstreamer_test.cpp',
exe = executable(test['name'], test['sources'], 'gstreamer_test.cpp',
dependencies : [libcamera_private, gstreamer_dep],
link_with : test_libraries,
include_directories : test_includes_internal)
test(test[0], exe, suite : 'gstreamer', is_parallel : false)
test(test['name'], exe, suite : 'gstreamer', is_parallel : false)
endforeach

View file

@ -1,15 +1,15 @@
# SPDX-License-Identifier: CC0-1.0
ipa_test = [
['ipa_module_test', 'ipa_module_test.cpp'],
['ipa_interface_test', 'ipa_interface_test.cpp'],
{'name': 'ipa_module_test', 'sources': ['ipa_module_test.cpp']},
{'name': 'ipa_interface_test', 'sources': ['ipa_interface_test.cpp']},
]
foreach test : ipa_test
exe = executable(test[0], [test[1], libcamera_generated_ipa_headers],
exe = executable(test['name'], test['sources'], libcamera_generated_ipa_headers,
dependencies : libcamera_private,
link_with : [libipa, test_libraries],
include_directories : [libipa_includes, test_includes_internal])
test(test[0], exe, suite : 'ipa')
test(test['name'], exe, suite : 'ipa')
endforeach

View file

@ -1,15 +1,15 @@
# SPDX-License-Identifier: CC0-1.0
ipc_tests = [
['unixsocket_ipc', 'unixsocket_ipc.cpp'],
['unixsocket', 'unixsocket.cpp'],
{'name': 'unixsocket_ipc', 'sources': ['unixsocket_ipc.cpp']},
{'name': 'unixsocket', 'sources': ['unixsocket.cpp']},
]
foreach test : ipc_tests
exe = executable(test[0], test[1],
exe = executable(test['name'], test['sources'],
dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
test(test[0], exe, suite : 'ipc')
test(test['name'], exe, suite : 'ipc')
endforeach

View file

@ -1,15 +1,15 @@
# SPDX-License-Identifier: CC0-1.0
log_test = [
['log_api', 'log_api.cpp'],
['log_process', 'log_process.cpp'],
{'name': 'log_api', 'sources': ['log_api.cpp']},
{'name': 'log_process', 'sources': ['log_process.cpp']},
]
foreach test : log_test
exe = executable(test[0], test[1],
exe = executable(test['name'], test['sources'],
dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
test(test[0], exe, suite : 'log')
test(test['name'], exe, suite : 'log')
endforeach

View file

@ -5,9 +5,9 @@ lib_mdev_test_sources = files([
])
media_device_tests = [
['media_device_acquire', 'media_device_acquire.cpp'],
['media_device_print_test', 'media_device_print_test.cpp'],
['media_device_link_test', 'media_device_link_test.cpp'],
{'name': 'media_device_acquire', 'sources': ['media_device_acquire.cpp']},
{'name': 'media_device_print_test', 'sources': ['media_device_print_test.cpp']},
{'name': 'media_device_link_test', 'sources': ['media_device_link_test.cpp']},
]
lib_mdev_test = static_library('lib_mdev_test', lib_mdev_test_sources,
@ -15,10 +15,10 @@ lib_mdev_test = static_library('lib_mdev_test', lib_mdev_test_sources,
include_directories : test_includes_internal)
foreach test : media_device_tests
exe = executable(test[0], test[1],
exe = executable(test['name'], test['sources'],
dependencies : libcamera_private,
link_with : [test_libraries, lib_mdev_test],
include_directories : test_includes_internal)
test(test[0], exe, suite : 'media_device', is_parallel : false)
test(test['name'], exe, suite : 'media_device', is_parallel : false)
endforeach

View file

@ -26,82 +26,82 @@ subdir('v4l2_subdevice')
subdir('v4l2_videodevice')
public_tests = [
['color-space', 'color-space.cpp'],
['geometry', 'geometry.cpp'],
['public-api', 'public-api.cpp'],
['signal', 'signal.cpp'],
['span', 'span.cpp'],
{'name': 'color-space', 'sources': ['color-space.cpp']},
{'name': 'geometry', 'sources': ['geometry.cpp']},
{'name': 'public-api', 'sources': ['public-api.cpp']},
{'name': 'signal', 'sources': ['signal.cpp']},
{'name': 'span', 'sources': ['span.cpp']},
]
internal_tests = [
['bayer-format', 'bayer-format.cpp'],
['byte-stream-buffer', 'byte-stream-buffer.cpp'],
['camera-sensor', 'camera-sensor.cpp'],
['delayed_controls', 'delayed_controls.cpp'],
['event', 'event.cpp'],
['event-dispatcher', 'event-dispatcher.cpp'],
['event-thread', 'event-thread.cpp'],
['file', 'file.cpp'],
['flags', 'flags.cpp'],
['hotplug-cameras', 'hotplug-cameras.cpp'],
['message', 'message.cpp'],
['object', 'object.cpp'],
['object-delete', 'object-delete.cpp'],
['object-invoke', 'object-invoke.cpp'],
['pixel-format', 'pixel-format.cpp'],
['shared-fd', 'shared-fd.cpp'],
['signal-threads', 'signal-threads.cpp'],
['threads', 'threads.cpp', [libthreads]],
['timer', 'timer.cpp'],
['timer-thread', 'timer-thread.cpp'],
['unique-fd', 'unique-fd.cpp'],
['utils', 'utils.cpp'],
['yaml-parser', 'yaml-parser.cpp'],
{'name': 'bayer-format', 'sources': ['bayer-format.cpp']},
{'name': 'byte-stream-buffer', 'sources': ['byte-stream-buffer.cpp']},
{'name': 'camera-sensor', 'sources': ['camera-sensor.cpp']},
{'name': 'delayed_controls', 'sources': ['delayed_controls.cpp']},
{'name': 'event', 'sources': ['event.cpp']},
{'name': 'event-dispatcher', 'sources': ['event-dispatcher.cpp']},
{'name': 'event-thread', 'sources': ['event-thread.cpp']},
{'name': 'file', 'sources': ['file.cpp']},
{'name': 'flags', 'sources': ['flags.cpp']},
{'name': 'hotplug-cameras', 'sources': ['hotplug-cameras.cpp']},
{'name': 'message', 'sources': ['message.cpp']},
{'name': 'object', 'sources': ['object.cpp']},
{'name': 'object-delete', 'sources': ['object-delete.cpp']},
{'name': 'object-invoke', 'sources': ['object-invoke.cpp']},
{'name': 'pixel-format', 'sources': ['pixel-format.cpp']},
{'name': 'shared-fd', 'sources': ['shared-fd.cpp']},
{'name': 'signal-threads', 'sources': ['signal-threads.cpp']},
{'name': 'threads', 'sources': 'threads.cpp', 'dependencies': [libthreads]},
{'name': 'timer', 'sources': ['timer.cpp']},
{'name': 'timer-thread', 'sources': ['timer-thread.cpp']},
{'name': 'unique-fd', 'sources': ['unique-fd.cpp']},
{'name': 'utils', 'sources': ['utils.cpp']},
{'name': 'yaml-parser', 'sources': ['yaml-parser.cpp']},
]
internal_non_parallel_tests = [
['fence', 'fence.cpp'],
['mapped-buffer', 'mapped-buffer.cpp'],
{'name': 'fence', 'sources': ['fence.cpp']},
{'name': 'mapped-buffer', 'sources': ['mapped-buffer.cpp']},
]
foreach test : public_tests
deps = [libcamera_public]
if test.length() > 2
deps += test[2]
if 'dependencies' in test
deps += test['dependencies']
endif
exe = executable(test[0], test[1],
exe = executable(test['name'], test['sources'],
dependencies : deps,
link_with : test_libraries,
include_directories : test_includes_public)
test(test[0], exe)
test(test['name'], exe)
endforeach
foreach test : internal_tests
deps = [libcamera_private]
if test.length() > 2
deps += test[2]
if 'dependencies' in test
deps += test['dependencies']
endif
exe = executable(test[0], test[1],
exe = executable(test['name'], test['sources'],
dependencies : deps,
link_with : test_libraries,
include_directories : test_includes_internal)
test(test[0], exe)
test(test['name'], exe)
endforeach
foreach test : internal_non_parallel_tests
deps = [libcamera_private]
if test.length() > 2
deps += test[2]
if 'dependencies' in test
deps += test['dependencies']
endif
exe = executable(test[0], test[1],
exe = executable(test['name'], test['sources'],
dependencies : deps,
link_with : test_libraries,
include_directories : test_includes_internal)
test(test[0], exe, is_parallel : false)
test(test['name'], exe, is_parallel : false)
endforeach

View file

@ -1,14 +1,14 @@
# SPDX-License-Identifier: CC0-1.0
ipu3_test = [
['ipu3_pipeline_test', 'ipu3_pipeline_test.cpp'],
{'name': 'ipu3_pipeline_test', 'sources': ['ipu3_pipeline_test.cpp']},
]
foreach test : ipu3_test
exe = executable(test[0], test[1],
exe = executable(test['name'], test['sources'],
dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
test(test[0], exe, suite : 'ipu3', is_parallel : false)
test(test['name'], exe, suite : 'ipu3', is_parallel : false)
endforeach

View file

@ -1,14 +1,14 @@
# SPDX-License-Identifier: CC0-1.0
rkisp1_test = [
['rkisp1_pipeline_test', 'rkisp1_pipeline_test.cpp'],
{'name': 'rkisp1_pipeline_test', 'sources': ['rkisp1_pipeline_test.cpp']},
]
foreach test : rkisp1_test
exe = executable(test[0], test[1],
exe = executable(test['name'], test['sources'],
dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
test(test[0], exe, suite : 'rkisp1', is_parallel : false)
test(test['name'], exe, suite : 'rkisp1', is_parallel : false)
endforeach

View file

@ -1,14 +1,14 @@
# SPDX-License-Identifier: CC0-1.0
process_tests = [
['process_test', 'process_test.cpp'],
{'name': 'process_test', 'sources': ['process_test.cpp']},
]
foreach test : process_tests
exe = executable(test[0], test[1],
exe = executable(test['name'], test['sources'],
dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
test(test[0], exe, suite : 'process', is_parallel : false)
test(test['name'], exe, suite : 'process', is_parallel : false)
endforeach

View file

@ -3,14 +3,14 @@
subdir('generated_serializer')
serialization_tests = [
['control_serialization', 'control_serialization.cpp'],
['ipa_data_serializer_test', 'ipa_data_serializer_test.cpp'],
{'name': 'control_serialization', 'sources': ['control_serialization.cpp']},
{'name': 'ipa_data_serializer_test', 'sources': ['ipa_data_serializer_test.cpp']},
]
foreach test : serialization_tests
exe = executable(test[0], [test[1], 'serialization_test.cpp'],
exe = executable(test['name'], test['sources'], 'serialization_test.cpp',
dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
test(test[0], exe, suite : 'serialization', is_parallel : false)
test(test['name'], exe, suite : 'serialization', is_parallel : false)
endforeach

View file

@ -1,14 +1,14 @@
# SPDX-License-Identifier: CC0-1.0
stream_tests = [
['stream_colorspace', 'stream_colorspace.cpp'],
['stream_formats', 'stream_formats.cpp'],
{'name': 'stream_colorspace', 'sources': ['stream_colorspace.cpp']},
{'name': 'stream_formats', 'sources': ['stream_formats.cpp']},
]
foreach test : stream_tests
exe = executable(test[0], test[1],
exe = executable(test['name'], test['sources'],
dependencies : libcamera_public,
link_with : test_libraries,
include_directories : test_includes_internal)
test(test[0], exe, suite: 'stream')
test(test['name'], exe, suite: 'stream')
endforeach

View file

@ -1,14 +1,14 @@
# SPDX-License-Identifier: CC0-1.0
v4l2_subdevice_tests = [
['list_formats', 'list_formats.cpp'],
['test_formats', 'test_formats.cpp'],
{'name': 'list_formats', 'sources': ['list_formats.cpp']},
{'name': 'test_formats', 'sources': ['test_formats.cpp']},
]
foreach test : v4l2_subdevice_tests
exe = executable(test[0], [test[1], 'v4l2_subdevice_test.cpp'],
exe = executable(test['name'], test['sources'], 'v4l2_subdevice_test.cpp',
dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
test(test[0], exe, suite : 'v4l2_subdevice', is_parallel : false)
test(test['name'], exe, suite : 'v4l2_subdevice', is_parallel : false)
endforeach

View file

@ -3,22 +3,22 @@
# Tests are listed in order of complexity.
# They are not alphabetically sorted.
v4l2_videodevice_tests = [
['double_open', 'double_open.cpp'],
['controls', 'controls.cpp'],
['formats', 'formats.cpp'],
['dequeue_watchdog', 'dequeue_watchdog.cpp'],
['request_buffers', 'request_buffers.cpp'],
['buffer_cache', 'buffer_cache.cpp'],
['stream_on_off', 'stream_on_off.cpp'],
['capture_async', 'capture_async.cpp'],
['buffer_sharing', 'buffer_sharing.cpp'],
['v4l2_m2mdevice', 'v4l2_m2mdevice.cpp'],
{'name': 'double_open', 'sources': ['double_open.cpp']},
{'name': 'controls', 'sources': ['controls.cpp']},
{'name': 'formats', 'sources': ['formats.cpp']},
{'name': 'dequeue_watchdog', 'sources': ['dequeue_watchdog.cpp']},
{'name': 'request_buffers', 'sources': ['request_buffers.cpp']},
{'name': 'buffer_cache', 'sources': ['buffer_cache.cpp']},
{'name': 'stream_on_off', 'sources': ['stream_on_off.cpp']},
{'name': 'capture_async', 'sources': ['capture_async.cpp']},
{'name': 'buffer_sharing', 'sources': ['buffer_sharing.cpp']},
{'name': 'v4l2_m2mdevice', 'sources': ['v4l2_m2mdevice.cpp']},
]
foreach test : v4l2_videodevice_tests
exe = executable(test[0], [test[1], 'v4l2_videodevice_test.cpp'],
exe = executable(test['name'], [test['sources'], 'v4l2_videodevice_test.cpp'],
dependencies : libcamera_private,
link_with : test_libraries,
include_directories : test_includes_internal)
test(test[0], exe, suite : 'v4l2_videodevice', is_parallel : false)
test(test['name'], exe, suite : 'v4l2_videodevice', is_parallel : false)
endforeach