Imported Upstream version 2.72.3
[platform/upstream/glib.git] / gio / tests / meson.build
index 881f07c..3ed23a5 100644 (file)
@@ -12,6 +12,21 @@ test_c_args = [
   '-UG_DISABLE_ASSERT',
 ]
 
+# workaround for https://github.com/mesonbuild/meson/issues/6880
+if build_machine.system() == 'linux'
+  libutil_name = 'libutil'
+  libutil = run_command('sh', '-c',
+    '''ldconfig -p | grep -o "[[:space:]]@0@\.so\(\.[0-9]\+\)\?\b"'''
+    .format(libutil_name), check: false).stdout().strip().split('\n')
+
+  if libutil.length() > 0
+      message('Found libutil as @0@'.format(libutil[0]))
+      test_c_args += '-DLIBUTIL_SONAME="@0@"'.format(libutil[0])
+  else
+      warning('libutil not found')
+  endif # libutil.length() > 0
+endif # build_machine.system() == 'linux'
+
 if host_machine.system() == 'windows'
   common_gio_tests_deps += [iphlpapi_dep, winsock2, cc.find_library ('secur32')]
 endif
@@ -27,25 +42,42 @@ giotypefuncs_inc = custom_target(
 
 #  Test programs buildable on all platforms
 gio_tests = {
-  'appmonitor' : {},
+  'appmonitor' : {
+    # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392
+    'should_fail' : host_system == 'darwin',
+  },
   'async-close-output-stream' : {},
   'async-splice-output-stream' : {},
   'buffered-input-stream' : {},
   'buffered-output-stream' : {},
   'cancellable' : {},
   'contexts' : {},
-  'contenttype' : {},
+  'contenttype' : {
+    # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392 / https://gitlab.gnome.org/GNOME/glib/-/issues/1251
+    'should_fail' : host_system == 'darwin',
+  },
   'converter-stream' : {},
   'credentials' : {},
+  'cxx' : {
+    'source' : ['cxx.cpp'],
+  },
   'data-input-stream' : {},
   'data-output-stream' : {},
-  'defaultvalue' : {'extra_sources' : [giotypefuncs_inc]},
   'fileattributematcher' : {},
   'filter-streams' : {},
-  'giomodule' : {},
-  'gsubprocess' : {},
+  'giomodule' : {
+    # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392
+    'should_fail' : host_system == 'darwin',
+  },
+  'gsubprocess' : {
+    # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392
+    'should_fail' : host_system == 'darwin',
+  },
   'g-file' : {},
-  'g-file-info' : {},
+  'g-file-info' : {
+    # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392
+    'should_fail' : host_system == 'darwin',
+  },
   'g-icon' : {},
   'gdbus-addresses' : {},
   'gdbus-message' : {},
@@ -60,12 +92,16 @@ gio_tests = {
   'network-monitor-race' : {},
   'permission' : {},
   'pollable' : {'dependencies' : [libdl_dep]},
+  'power-profile-monitor' : {},
   'proxy-test' : {},
   'readwrite' : {},
   'simple-async-result' : {},
   'simple-proxy' : {},
   'sleepy-stream' : {},
-  'socket' : {},
+  'socket' : {
+    # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392
+    'should_fail' : host_system == 'darwin',
+  },
   'socket-listener' : {},
   'socket-service' : {},
   'srvtarget' : {},
@@ -79,7 +115,10 @@ gio_tests = {
   'tls-interaction' : {'extra_sources' : ['gtesttlsbackend.c']},
   'tls-database' : {'extra_sources' : ['gtesttlsbackend.c']},
   'tls-bindings' : {'extra_sources' : ['gtesttlsbackend.c']},
-  'gdbus-address-get-session' : {},
+  'gdbus-address-get-session' : {
+    # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392
+    'should_fail' : host_system == 'darwin',
+  },
   'win32-appinfo' : {},
 }
 
@@ -132,16 +171,27 @@ else
   }
 endif
 
+have_dbus_daemon = find_program('dbus-daemon', required : false).found()
+if have_dbus_daemon
+  gio_tests += {
+    'debugcontroller' : {},
+    'defaultvalue' : {'extra_sources' : [giotypefuncs_inc]},
+  }
+endif
+
 #  Test programs buildable on UNIX only
 if host_machine.system() != 'windows'
   gio_tests += {
     'file' : {},
     'gdbus-peer' : {
       'dependencies' : [libgdbus_example_objectmanager_dep],
-      'install_rpath' : installed_tests_execdir
+      'install_rpath' : installed_tests_execdir,
+      # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392
+      'should_fail' : host_system == 'darwin',
     },
     'gdbus-peer-object-manager' : {},
     'live-g-file' : {},
+    'resolver-parsing' : {'dependencies' : [network_libs]},
     'socket-address' : {},
     'stream-rw_all' : {},
     'unix-fd' : {},
@@ -203,8 +253,6 @@ if host_machine.system() != 'windows'
     }
   endif
 
-  #  Test programs that need to bring up a session bus (requires dbus-daemon)
-  have_dbus_daemon = find_program('dbus-daemon', required : false).found()
   if have_dbus_daemon
     annotate_args = [
       '--annotate', 'org.project.Bar', 'Key1', 'Value1',
@@ -290,6 +338,7 @@ if host_machine.system() != 'windows'
         'suite' : ['slow'],
       },
       'gdbus-introspection' : {'extra_sources' : extra_sources},
+      'gdbus-method-invocation' : {'extra_sources' : extra_sources},
       'gdbus-names' : {'extra_sources' : extra_sources},
       'gdbus-proxy' : {'extra_sources' : extra_sources},
       'gdbus-proxy-threads' : {
@@ -525,27 +574,29 @@ if installed_tests_enabled
   install_subdir('static-link', install_dir : installed_tests_execdir)
   install_data('static-link.py', install_dir : installed_tests_execdir)
 
-  memory_monitor_tests = [
+  monitor_tests = [
     'memory-monitor-dbus',
     'memory-monitor-portal',
+    'power-profile-monitor-dbus',
+    'power-profile-monitor-portal'
   ]
 
-  foreach memory_monitor_test : memory_monitor_tests
+  foreach monitor_test : monitor_tests
     cdata = configuration_data()
     cdata.set('installed_tests_dir', installed_tests_execdir)
-    cdata.set('program', memory_monitor_test + '.py')
+    cdata.set('program', monitor_test + '.py')
     cdata.set('env', '')
     configure_file(
       input: installed_tests_template_tap,
-      output: memory_monitor_test + '.test',
+      output: monitor_test + '.test',
       install_dir: installed_tests_metadir,
       configuration: cdata
     )
     cdata = configuration_data()
     cdata.set('libexecdir', join_paths(glib_prefix, get_option('libexecdir')))
     configure_file(
-      input: memory_monitor_test + '.py.in',
-      output: memory_monitor_test + '.py',
+      input: monitor_test + '.py.in',
+      output: monitor_test + '.py',
       install_dir : installed_tests_execdir,
       configuration: cdata,
     )
@@ -554,12 +605,16 @@ endif
 
 if not meson.is_cross_build() or meson.has_exe_wrapper()
 
+  compiler_type = '--compiler=@0@'.format(cc.get_id())
+
   plugin_resources_c = custom_target('plugin-resources.c',
     input : 'test4.gresource.xml',
     output : 'plugin-resources.c',
     command : [glib_compile_resources,
+               compiler_type,
                '--target=@OUTPUT@',
                '--sourcedir=' + meson.current_source_dir(),
+               '--internal',
                '--generate-source',
                '--c-name', '_g_plugin',
                '@INPUT@'])
@@ -582,9 +637,11 @@ if not meson.is_cross_build() or meson.has_exe_wrapper()
     input : 'test.gresource.xml',
     output : 'test.gresource',
     command : [glib_compile_resources,
+               compiler_type,
                '--target=@OUTPUT@',
                '--sourcedir=' + meson.current_source_dir(),
                '--sourcedir=' + meson.current_build_dir(),
+               '--internal',
                '@INPUT@'],
     install_dir : installed_tests_execdir,
     install : installed_tests_enabled)
@@ -593,8 +650,10 @@ if not meson.is_cross_build() or meson.has_exe_wrapper()
     input : 'test3.gresource.xml',
     output : 'test_resources2.c',
     command : [glib_compile_resources,
+               compiler_type,
                '--target=@OUTPUT@',
                '--sourcedir=' + meson.current_source_dir(),
+               '--internal',
                '--generate',
                '--c-name', '_g_test2',
                '--manual-register',
@@ -604,8 +663,10 @@ if not meson.is_cross_build() or meson.has_exe_wrapper()
     input : 'test3.gresource.xml',
     output : 'test_resources2.h',
     command : [glib_compile_resources,
+               compiler_type,
                '--target=@OUTPUT@',
                '--sourcedir=' + meson.current_source_dir(),
+               '--internal',
                '--generate',
                '--c-name', '_g_test2',
                '--manual-register',
@@ -616,9 +677,11 @@ if not meson.is_cross_build() or meson.has_exe_wrapper()
     depends : big_test_resource,
     output : 'test_resources.c',
     command : [glib_compile_resources,
+               compiler_type,
                '--target=@OUTPUT@',
                '--sourcedir=' + meson.current_source_dir(),
                '--sourcedir=' + meson.current_build_dir(),
+               '--internal',
                '--generate-source',
                '--c-name', '_g_test1',
                '@INPUT@'])
@@ -627,9 +690,11 @@ if not meson.is_cross_build() or meson.has_exe_wrapper()
     input : '111_digit_test.gresource.xml',
     output : 'digit_test_resources.c',
     command : [glib_compile_resources,
+               compiler_type,
                '--target=@OUTPUT@',
                '--sourcedir=' + meson.current_source_dir(),
                '--sourcedir=' + meson.current_build_dir(),
+               '--internal',
                '--generate-source',
                '--manual-register',
                '@INPUT@'])
@@ -638,8 +703,10 @@ if not meson.is_cross_build() or meson.has_exe_wrapper()
     input : '111_digit_test.gresource.xml',
     output : 'digit_test_resources.h',
     command : [glib_compile_resources,
+               compiler_type,
                '--target=@OUTPUT@',
                '--sourcedir=' + meson.current_source_dir(),
+               '--internal',
                '--generate',
                '--manual-register',
                '@INPUT@'])
@@ -660,26 +727,33 @@ if not meson.is_cross_build() or meson.has_exe_wrapper()
   ]
 
   # Create object file containing resource data for testing the --external-data
-  # option. Currently only GNU ld and GNU objcopy support the right options.
-  # Support for --add-symbol was added to LLVM objcopy in 2019
-  # (https://reviews.llvm.org/D58234). FIXME: This test could be enabled for
-  # LLVM once that support is in a stable release.
+  # option. Currently only GNU ld and objcopy, or (as of 2019) LLVM ld and
+  # objcopy, support the right options.
   objcopy_supports_add_symbol = false
   objcopy = find_program('objcopy', required : false)
   if objcopy.found()
-    objcopy_supports_add_symbol = run_command(objcopy, '--help').stdout().contains('--add-symbol')
+    # FIXME: This should be `check: true` because we never really expect
+    # `objcopy --help` to fail, given that `objcopy` exists. However, it does
+    # fail on FreeBSD because ELF Tool Chain has
+    # [a bug](https://sourceforge.net/p/elftoolchain/code/3950/).
+    # This can be changed back to `check: true` once our CI uses a FreeBSD
+    # version which includes the fix.
+    # See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2360#note_1318608
+    objcopy_supports_add_symbol = run_command(objcopy, '--help', check: false).stdout().contains('--add-symbol')
   endif
 
   ld = find_program('ld', required : false)
 
-  if build_machine.system() == 'linux' and cc.get_id() == 'gcc' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
+  if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
     test_gresource_binary = custom_target('test5.gresource',
       input : 'test5.gresource.xml',
       output : 'test5.gresource',
       command : [glib_compile_resources,
+                 compiler_type,
                  '--target=@OUTPUT@',
                  '--sourcedir=' + meson.current_source_dir(),
                  '--sourcedir=' + meson.current_build_dir(),
+                 '--internal',
                  '@INPUT@'],
       install_dir : installed_tests_execdir,
       install : installed_tests_enabled)
@@ -689,9 +763,11 @@ if not meson.is_cross_build() or meson.has_exe_wrapper()
       input : 'test5.gresource.xml',
       output : 'test_resources_binary.c',
       command : [glib_compile_resources,
+                 compiler_type,
                  '--target=@OUTPUT@',
                  '--sourcedir=' + meson.current_source_dir(),
                  '--sourcedir=' + meson.current_build_dir(),
+                 '--internal',
                  '--generate-source',
                  '--external-data',
                  '--c-name', '_g_binary_test1',
@@ -702,17 +778,24 @@ if not meson.is_cross_build() or meson.has_exe_wrapper()
       input : test_gresource_binary,
       output : 'test_resources.o',
       command : [ld,
+                 '-z', 'noexecstack',
                  '-r',
                  '-b','binary',
                  '@INPUT@',
                  '-o','@OUTPUT@'])
 
     # Rename symbol to match the one in the C file
+    if cc.get_id() == 'gcc' and host_system == 'windows'
+      underscore = '_'
+    else
+      underscore = ''
+    endif
     test_resources_binary2 = custom_target('test_resources2.o',
       input : test_resources_binary,
       output : 'test_resources2.o',
       command : [objcopy,
-                 '--add-symbol','_g_binary_test1_resource_data=.data:0',
+                 '--strip-all',
+                 '--add-symbol', underscore + '_g_binary_test1_resource_data=.data:0',
                  '@INPUT@',
                  '@OUTPUT@'])
 
@@ -725,6 +808,8 @@ if not meson.is_cross_build() or meson.has_exe_wrapper()
   gio_tests += {
     'resources' : {
       'extra_sources' : resources_extra_sources,
+      # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392
+      'should_fail' : host_system == 'darwin',
     },
   }
 endif
@@ -778,6 +863,7 @@ foreach test_name, extra_args : gio_tests
     suite : suite,
     is_parallel : extra_args.get('is_parallel', true),
     depends : extra_args.get('depends', []),
+    should_fail : extra_args.get('should_fail', false),
   )
 endforeach