mirror of
https://github.com/brl/mutter.git
synced 2024-11-24 17:10:40 -05:00
cogl/tests: Export and run unit tests if they are enabled
Cogl unit tests are just functions inside normal code files that needs to be dload'ed by the test binary. So in case unit-tests are enabled, we need to export those symbols. Since map file can't be overridden, use a configure_file to generate the map file when tests are enabled, in order to export the needed symbols. Then goes through the source files to look unit tests checking for their macro definition and load them with the runner script. https://gitlab.gnome.org/GNOME/mutter/merge_requests/442
This commit is contained in:
parent
5d1a87d355
commit
8374be46d2
@ -29,8 +29,6 @@ global:
|
||||
_cogl_texture_can_hardware_repeat;
|
||||
_cogl_pipeline_prune_to_n_layers;
|
||||
_cogl_primitive_draw;
|
||||
#test_;
|
||||
#unit_test_;
|
||||
_cogl_winsys_glx_get_vtable;
|
||||
_cogl_winsys_egl_xlib_get_vtable;
|
||||
_cogl_winsys_egl_get_vtable;
|
||||
@ -48,6 +46,7 @@ global:
|
||||
_cogl_pixel_format_get_bytes_per_pixel*;
|
||||
_cogl_system_error_quark;
|
||||
_cogl_util_next_p2;
|
||||
@unit_tests_symbols@
|
||||
local:
|
||||
*;
|
||||
};
|
@ -455,16 +455,24 @@ cogl_headers_all = [
|
||||
]
|
||||
|
||||
cogl_test_deps = []
|
||||
cogl_unit_tests_map_data = configuration_data()
|
||||
|
||||
if have_cogl_tests
|
||||
cogl_test_deps += [libmutter_cogl_test_fixtures_dep]
|
||||
|
||||
cogl_unit_tests_map_data.set('unit_tests_symbols', 'test_*; unit_test_*;')
|
||||
endif
|
||||
|
||||
libmutter_cogl_map = configure_file(
|
||||
input: 'libmutter-cogl.map.in',
|
||||
output: 'libmutter-cogl.map',
|
||||
configuration: cogl_unit_tests_map_data,
|
||||
install: false,
|
||||
)
|
||||
|
||||
libmutter_cogl_name = 'mutter-cogl-' + libmutter_api_version
|
||||
libmutter_cogl_map = 'libmutter-cogl.map'
|
||||
libmutter_cogl_link_args = [
|
||||
'-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(),
|
||||
libmutter_cogl_map),
|
||||
'-Wl,--version-script,@0@'.format(libmutter_cogl_map),
|
||||
]
|
||||
libmutter_cogl = shared_library(libmutter_cogl_name,
|
||||
sources: [cogl_sources, cogl_headers_all],
|
||||
|
@ -3,8 +3,6 @@
|
||||
inputfile="$1"
|
||||
outputfile="$2"
|
||||
|
||||
echo > "$outputfile"
|
||||
|
||||
sed -n -e 's/^ \{1,\}ADD_TEST *( *\([a-zA-Z0-9_]\{1,\}\).*/\1/p' "$inputfile" | while read -r test; do
|
||||
echo "$test" >> "$outputfile"
|
||||
done
|
||||
|
@ -23,20 +23,20 @@ libmutter_cogl_test_unit = executable('test-unit',
|
||||
install: false,
|
||||
)
|
||||
|
||||
find_unit_tests = find_program('meson/find-unit-tests.sh')
|
||||
cogl_unit_unit_tests = custom_target('cogl-tests-unit-unit-tests',
|
||||
output: 'unit-tests',
|
||||
input: libmutter_cogl,
|
||||
command: [find_unit_tests, '@INPUT@', '@OUTPUT@'],
|
||||
install: false,
|
||||
)
|
||||
cogl_unit_tests = run_command(
|
||||
find_program('meson/find-unit-tests.sh'), cogl_srcdir, '/dev/stdout',
|
||||
check: true,
|
||||
).stdout().strip().split('\n')
|
||||
|
||||
test('unit', cogl_run_tests,
|
||||
suite: ['cogl'],
|
||||
args: [
|
||||
cogl_config_env,
|
||||
libmutter_cogl_test_unit,
|
||||
cogl_unit_unit_tests
|
||||
],
|
||||
is_parallel: false,
|
||||
)
|
||||
foreach test_target: cogl_unit_tests
|
||||
test_name = '-'.join(test_target.split('_'))
|
||||
test(test_name, cogl_run_tests,
|
||||
suite: ['cogl', 'cogl/unit'],
|
||||
args: [
|
||||
cogl_config_env,
|
||||
libmutter_cogl_test_unit,
|
||||
'unit_test_' + test_target
|
||||
],
|
||||
is_parallel: false,
|
||||
)
|
||||
endforeach
|
||||
|
@ -1,6 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
inputfile="$1"
|
||||
inputdir="$1"
|
||||
outputfile="$2"
|
||||
|
||||
nm "$inputfile" | grep '[DR] _\?unit_test_'|sed 's/.\+ [DR] _\?//' > "$outputfile"
|
||||
echo > "$outputfile"
|
||||
|
||||
grep -h -r --include \*.c UNIT_TEST "$inputdir" | \
|
||||
sed -n -e 's/^UNIT_TEST *( *\([a-zA-Z0-9_]\{1,\}\).*/\1/p' > "$outputfile"
|
||||
|
Loading…
Reference in New Issue
Block a user