From a84cbf1434f7b2b5a19d800aa2b7ce294fed5f59 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Mon, 16 Jul 2018 13:37:29 -0400 Subject: [PATCH] Meson: Group all glib tests into a single dict --- glib/tests/meson.build | 397 +++++++++++++++++++++++-------------------------- 1 file changed, 183 insertions(+), 214 deletions(-) rewrite glib/tests/meson.build (76%) diff --git a/glib/tests/meson.build b/glib/tests/meson.build dissimilarity index 76% index ebce3c6b1..e684af45e 100644 --- a/glib/tests/meson.build +++ b/glib/tests/meson.build @@ -1,214 +1,183 @@ -glib_tests = [ - 'array-test', - 'asyncqueue', - 'base64', - 'bitlock', - 'bookmarkfile', - 'bytes', - 'cache', - 'charset', - 'checksum', - 'collate', - 'cond', - 'convert', - 'dataset', - 'date', - 'dir', - 'environment', - 'error', - 'fileutils', - 'gdatetime', - 'guuid', - 'gvariant', - 'hash', - 'hmac', - 'hook', - 'hostutils', - 'keyfile', - 'list', - 'logging', - 'mainloop', - 'mappedfile', - 'markup', - 'markup-parse', - 'markup-collect', - 'markup-escape', - 'markup-subparser', - 'mem-overflow', - 'mutex', - 'node', - 'once', - 'option-context', - 'option-argv0', - 'overflow', - # overflow-fallback handled separately below - 'pattern', - 'private', - 'protocol', - 'queue', - 'rand', - 'rcbox', - 'rec-mutex', - 'refcount', - 'refcount-macro', - 'refstring', - 'regex', - 'rwlock', - 'scannerapi', - 'search-utils', - 'sequence', - 'shell', - 'slice', - 'slist', - 'sort', - 'spawn-multithreaded', - 'spawn-singlethread', - 'strfuncs', - 'string', - 'testing', - 'test-printf', - 'thread', - 'timeout', - 'timer', - 'tree', - 'utf8-performance', - 'utf8-pointer', - 'utf8-validate', - 'utf8-misc', - 'utils', - 'unicode', - 'uri', - '1bit-mutex', - '642026', -] - -if host_machine.system() != 'windows' - glib_tests += [ 'unix', 'include' ] -endif - -if cc.get_id() != 'msvc' - glib_tests += [ 'autoptr' ] -endif - -# Not entirely random of course, but at least it changes over time -random_number = minor_version + meson.version().split('.').get(1).to_int() - -test_env = environment() -test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) -test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) -test_env.set('G_DEBUG', 'gc-friendly') -test_env.set('MALLOC_CHECK_', '2') -test_env.set('MALLOC_PERTURB_', '@0@'.format(random_number % 256)) - -test_cargs = ['-DG_LOG_DOMAIN="GLib"'] - -# Tests that consistently time out on the CI infrastructure -slow_tests = [ - 'gvariant', - 'sequence', - '642026', -] - -foreach test_name : glib_tests - deps = [libm, thread_dep, libglib_dep] - source = test_name + '.c' - c_args = test_cargs + ['-DPCRE_STATIC'] - if test_name == 'regex' - deps += [pcre] - endif - if test_name == 'gdatetime' - deps += [libintl] - endif - # We build the refcount test twice: one to test the function-based API, - # and the other to test the macro-based API that is used when disabling - # checks - if test_name == 'refcount-macro' - source = 'refcount.c' - c_args += ['-DG_DISABLE_CHECKS'] - endif - exe = executable(test_name, source, - c_args : c_args, - dependencies : deps, - install : false, - ) - # These tests may take more than 30 seconds to run on the CI infrastructure - if slow_tests.contains(test_name) - test(test_name, exe, env : test_env, timeout : 120, suite : ['glib', 'slow']) - else - test(test_name, exe, env : test_env, suite : ['glib']) - endif -endforeach - -c_args_atomic = [] -if cc.get_id() == 'gcc' - c_args_atomic += ['-Wstrict-aliasing=2'] -endif - -deps = [libm, thread_dep, libglib_dep] - -exe = executable('atomic', 'atomic.c', - c_args : test_cargs + c_args_atomic, - dependencies : deps, -) -test('atomic', exe, env : test_env, suite : ['glib']) - -# FIXME: consolidate all of these into the array -exe = executable('overflow-fallback', 'overflow.c', - c_args : test_cargs + ['-D_GLIB_TEST_OVERFLOW_FALLBACK'], - dependencies : deps, - install : false, -) -test('overflow-fallback', exe, env : test_env, suite : ['glib']) - -exe = executable('642026-ec', '642026.c', - c_args : test_cargs + ['-DG_ERRORCHECK_MUTEXES'], - dependencies : deps, - install : false, -) -test('642026-ec', exe, env : test_env, timeout : 90, suite : ['glib', 'slow']) - -exe = executable('1bit-emufutex', '1bit-mutex.c', - c_args : test_cargs + ['-DTEST_EMULATED_FUTEX'], - dependencies : deps, - install : false, -) -test('1bit-emufutex', exe, env : test_env, suite : ['glib']) - -exe = executable('gwakeup', 'gwakeuptest.c', '../gwakeup.c', - c_args : test_cargs, - dependencies : deps, - install : false) -test('gwakeup', exe, env : test_env, suite : ['glib']) - -if glib_conf.has('HAVE_EVENTFD') - exe = executable('gwakeup-fallback', 'gwakeuptest.c', '../gwakeup.c', - c_args : test_cargs + ['-DTEST_EVENTFD_FALLBACK'], - dependencies : deps, - install : false, - ) - test('gwakeup-fallback', exe, env : test_env, suite : ['glib']) -endif - -# test-spawn-echo helper binary required by the spawn tests above -executable('test-spawn-echo', 'test-spawn-echo.c', - c_args : test_cargs, - dependencies : deps, - install : false, -) - -# some testing of gtester functionality -if not meson.is_cross_build() and host_system != 'windows' - xmllint = find_program('xmllint', required: false) - if xmllint.found() - tmpsample_xml = custom_target('tmpsample.xml', - output : 'tmpsample.xml', - command : [ gtester, '-k', '--quiet', '-o', '@OUTPUT@', - '--test-arg=--gtester-selftest', gtester]) - - test('gtester-xmllint-check', xmllint, - args : ['--noout', tmpsample_xml], - env : test_env, - suite : ['glib'], - ) - endif -endif +glib_tests = { + 'array-test' : {}, + 'asyncqueue' : {}, + 'atomic' : { + 'c_args' : cc.get_id() == 'gcc' ? ['-Wstrict-aliasing=2'] : [], + }, + 'autoptr' : { + 'skip' : cc.get_id() == 'msvc', + }, + 'base64' : {}, + 'bitlock' : {}, + 'bookmarkfile' : {}, + 'bytes' : {}, + 'cache' : {}, + 'charset' : {}, + 'checksum' : {}, + 'collate' : {}, + 'cond' : {}, + 'convert' : {}, + 'dataset' : {}, + 'date' : {}, + 'dir' : {}, + 'environment' : {}, + 'error' : {}, + 'fileutils' : {}, + 'gdatetime' : {}, + 'guuid' : {}, + 'gvariant' : { + 'suite' : ['slow'], + }, + 'gwakeup' : { + 'source' : ['gwakeuptest.c', '../gwakeup.c'], + }, + 'gwakeup-fallback' : { + 'skip' : not glib_conf.has('HAVE_EVENTFD'), + 'source' : ['gwakeuptest.c', '../gwakeup.c'], + 'c_args' : ['-DTEST_EVENTFD_FALLBACK'], + }, + 'hash' : {}, + 'hmac' : {}, + 'hook' : {}, + 'hostutils' : {}, + 'include' : { + 'skip' : host_machine.system() == 'windows', + }, + 'keyfile' : {}, + 'list' : {}, + 'logging' : {}, + 'mainloop' : {}, + 'mappedfile' : {}, + 'markup' : {}, + 'markup-parse' : {}, + 'markup-collect' : {}, + 'markup-escape' : {}, + 'markup-subparser' : {}, + 'mem-overflow' : {}, + 'mutex' : {}, + 'node' : {}, + 'once' : {}, + 'option-context' : {}, + 'option-argv0' : {}, + 'overflow' : {}, + 'overflow-fallback' : { + 'source' : 'overflow.c', + 'c_args' : ['-D_GLIB_TEST_OVERFLOW_FALLBACK'], + }, + 'pattern' : {}, + 'private' : {}, + 'protocol' : {}, + 'queue' : {}, + 'rand' : {}, + 'rcbox' : {}, + 'rec-mutex' : {}, + 'refcount' : {}, + 'refcount-macro' : { + 'source' : 'refcount.c', + 'c_args' : ['-DG_DISABLE_CHECKS'], + }, + 'refstring' : {}, + 'regex' : { + 'dependencies' : [pcre], + 'c_args' : use_pcre_static_flag ? ['-DPCRE_STATIC'] : [], + }, + 'rwlock' : {}, + 'scannerapi' : {}, + 'search-utils' : {}, + 'sequence' : { + 'suite' : ['slow'], + }, + 'shell' : {}, + 'slice' : {}, + 'slist' : {}, + 'sort' : {}, + 'spawn-multithreaded' : {}, + 'spawn-singlethread' : {}, + 'strfuncs' : {}, + 'string' : {}, + 'testing' : {}, + 'test-printf' : {}, + 'thread' : {}, + 'timeout' : {}, + 'timer' : {}, + 'tree' : {}, + 'utf8-performance' : {}, + 'utf8-pointer' : {}, + 'utf8-validate' : {}, + 'utf8-misc' : {}, + 'utils' : {}, + 'unicode' : {}, + 'unix' : { + 'skip' : host_machine.system() == 'windows', + }, + 'uri' : {}, + '1bit-mutex' : {}, + '1bit-emufutex' : { + 'source' : '1bit-mutex.c', + 'c_args' : ['-DTEST_EMULATED_FUTEX'], + }, + '642026' : { + 'suite' : ['slow'], + }, + '642026-ec' : { + 'source' : '642026.c', + 'c_args' : ['-DG_ERRORCHECK_MUTEXES'], + 'suite' : ['slow'], + }, +} + +# Not entirely random of course, but at least it changes over time +random_number = minor_version + meson.version().split('.').get(1).to_int() + +test_env = environment() +test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) +test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) +test_env.set('G_DEBUG', 'gc-friendly') +test_env.set('MALLOC_CHECK_', '2') +test_env.set('MALLOC_PERTURB_', '@0@'.format(random_number % 256)) + +test_deps = [libm, thread_dep, libglib_dep] +test_cargs = ['-DG_LOG_DOMAIN="GLib"'] + +foreach test_name, extra_args : glib_tests + # FIXME: This condition is ugly, meson should either have 'continue' + # keyword (https://github.com/mesonbuild/meson/issues/3601), or support + # mutable to dictionaries (https://github.com/mesonbuild/meson/pull/3820). + if not extra_args.get('skip', false) + source = extra_args.get('source', test_name + '.c') + + exe = executable(test_name, source, + c_args : test_cargs + extra_args.get('c_args', []), + dependencies : test_deps + extra_args.get('dependencies', []), + install: false, + ) + + suite = ['glib'] + extra_args.get('suite', []) + timeout = suite.contains('slow') ? 120 : 30 + test(test_name, exe, env : test_env, timeout : timeout, suite : suite) + endif +endforeach + +# test-spawn-echo helper binary required by the spawn tests above +executable('test-spawn-echo', 'test-spawn-echo.c', + c_args : test_cargs, + dependencies : test_deps, + install : false, +) + +# some testing of gtester functionality +if not meson.is_cross_build() and host_system != 'windows' + xmllint = find_program('xmllint', required: false) + if xmllint.found() + tmpsample_xml = custom_target('tmpsample.xml', + output : 'tmpsample.xml', + command : [ gtester, '-k', '--quiet', '-o', '@OUTPUT@', + '--test-arg=--gtester-selftest', gtester]) + + test('gtester-xmllint-check', xmllint, + args : ['--noout', tmpsample_xml], + env : test_env, + suite : ['glib'], + ) + endif +endif -- 2.11.4.GIT