Merge branch 'wip/smcv/issue3226' into 'main'

tests: Don't test --external-data with toolchains that can't do the setup

Closes #3226

See merge request GNOME/glib!3819
This commit is contained in:
Philip Withnall 2024-01-15 15:41:44 +00:00
commit 048afc5923
2 changed files with 24 additions and 7 deletions

View File

@ -934,9 +934,19 @@ if not meson.is_cross_build()
ld = find_program('ld', required : false) ld = find_program('ld', required : false)
if build_machine.system() == 'linux' and \ if build_machine.system() != 'linux'
objcopy.found() and objcopy_supports_add_symbol and ld.found() and \ why_no_external_data = 'only works on Linux'
build_machine.cpu_family() not in ['mips', 'mips64'] elif not objcopy.found()
why_no_external_data = 'objcopy not found'
elif not objcopy_supports_add_symbol
why_no_external_data = 'objcopy does not support --add-symbol'
elif not ld.found()
why_no_external_data = 'ld not found'
elif build_machine.cpu_family() in ['mips', 'mips64']
why_no_external_data = 'cc -r can produce a mismatched MIPS ABI family, see GNOME/glib!3640'
else
why_no_external_data = ''
test_gresource_binary = custom_target('test5.gresource', test_gresource_binary = custom_target('test5.gresource',
input : 'test5.gresource.xml', input : 'test5.gresource.xml',
output : 'test5.gresource', output : 'test5.gresource',
@ -994,8 +1004,15 @@ if not meson.is_cross_build()
] ]
endif endif
resources_c_args = []
if why_no_external_data != ''
resources_c_args += '-DNO_EXTERNAL_DATA="@0@"'.format(why_no_external_data)
endif
gio_tests += { gio_tests += {
'resources' : { 'resources' : {
'c_args' : resources_c_args,
'extra_sources' : resources_extra_sources, 'extra_sources' : resources_extra_sources,
'depends' : resource_plugin, 'depends' : resource_plugin,
# FIXME: musl: https://gitlab.gnome.org/GNOME/glib/-/issues/3160 # FIXME: musl: https://gitlab.gnome.org/GNOME/glib/-/issues/3160

View File

@ -642,10 +642,10 @@ test_resource_manual2 (void)
static void static void
test_resource_binary_linked (void) test_resource_binary_linked (void)
{ {
#ifndef __linux__ #ifdef NO_EXTERNAL_DATA
g_test_skip ("--external-data test only works on Linux"); g_test_skip ("--external-data cannot be tested: " NO_EXTERNAL_DATA);
return; return;
#else /* if __linux__ */ #else /* !NO_EXTERNAL_DATA */
GError *error = NULL; GError *error = NULL;
gboolean found; gboolean found;
gsize size; gsize size;
@ -669,7 +669,7 @@ test_resource_binary_linked (void)
g_assert_cmpint (size, ==, 6); g_assert_cmpint (size, ==, 6);
g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test1\n"); g_assert_cmpstr (g_bytes_get_data (data, NULL), ==, "test1\n");
g_bytes_unref (data); g_bytes_unref (data);
#endif /* if __linux__ */ #endif /* !NO_EXTERNAL_DATA */
} }
/* Test resource whose xml file starts with more than one digit /* Test resource whose xml file starts with more than one digit