meson.build 5.57 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
glib_tests = {
  'array-test' : {},
  'asyncqueue' : {},
  'atomic' : {
    'c_args' : cc.get_id() == 'gcc' ? ['-Wstrict-aliasing=2'] : [],
  },
  'base64' : {},
  'bitlock' : {},
  'bookmarkfile' : {},
  'bytes' : {},
  'cache' : {},
  'charset' : {},
  'checksum' : {},
  'collate' : {},
  'cond' : {},
  'convert' : {},
  'dataset' : {},
  'date' : {},
  'dir' : {},
  'environment' : {},
  'error' : {},
  'fileutils' : {},
23 24 25
  'gdatetime' : {
    'suite' : ['slow'],
  },
26 27 28 29 30 31
  'guuid' : {},
  'gvariant' : {
    'suite' : ['slow'],
  },
  'gwakeup' : {
    'source' : ['gwakeuptest.c', '../gwakeup.c'],
32
    'install' : false,
33 34 35 36 37 38 39 40
  },
  'hash' : {},
  'hmac' : {},
  'hook' : {},
  'hostutils' : {},
  'keyfile' : {},
  'list' : {},
  'logging' : {},
41
  'macros' : {},
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
  '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' : {},
  'uri' : {},
  '1bit-mutex' : {},
  '1bit-emufutex' : {
    'source' : '1bit-mutex.c',
    'c_args' : ['-DTEST_EMULATED_FUTEX'],
108
    'install' : false,
109
    'suite' : ['slow'],
110 111 112 113 114 115 116 117 118 119
  },
  '642026' : {
    'suite' : ['slow'],
  },
  '642026-ec' : {
    'source' : '642026.c',
    'c_args' : ['-DG_ERRORCHECK_MUTEXES'],
    'suite' : ['slow'],
  },
}
120

121 122 123 124 125 126 127 128 129 130 131 132 133 134
if cc.get_id() != 'msvc'
  glib_tests += {'autoptr' : {}}
endif

if glib_conf.has('HAVE_EVENTFD')
  glib_tests += {
    'gwakeup-fallback' : {
      'source' : ['gwakeuptest.c', '../gwakeup.c'],
      'c_args' : ['-DTEST_EVENTFD_FALLBACK'],
      'install' : false,
    },
  }
endif

135 136 137 138 139 140 141 142 143
if host_machine.system() == 'windows'
  if winsock2.found()
    glib_tests += {
      'gpoll' : {
        'dependencies' : [winsock2],
      },
    }
  endif
else
144 145 146 147 148 149
  glib_tests += {
    'include' : {},
    'unix' : {},
  }
endif

150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
if installed_tests_enabled
  install_data(
    'keyfiletest.ini',
    'pages.ini',
    'keyfile.c',
    'empty',
    '4096-random-bytes',
    'echo-script',
    'echo-script.bat',
    install_dir : installed_tests_execdir,
  )
  install_subdir('bookmarks', install_dir : installed_tests_execdir)
  install_subdir('markups', install_dir : installed_tests_execdir)
endif

165
# Not entirely random of course, but at least it changes over time
166
random_number = minor_version + meson.version().split('.').get(1).to_int()
167

168 169 170 171 172 173
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))
174

175
test_deps = [libm, thread_dep, libglib_dep]
176
test_cargs = ['-DG_LOG_DOMAIN="GLib"']
177

178
foreach test_name, extra_args : glib_tests
179 180
  source = extra_args.get('source', test_name + '.c')
  install = installed_tests_enabled and extra_args.get('install', true)
181

182 183 184 185 186 187 188 189 190
  if install
    test_conf = configuration_data()
    test_conf.set('installed_tests_dir', installed_tests_execdir)
    test_conf.set('program', test_name)
    configure_file(
      input: installed_tests_template_tap,
      output: test_name + '.test',
      install_dir: installed_tests_metadir,
      configuration: test_conf
191
    )
192
  endif
193 194 195 196 197 198 199 200 201

  exe = executable(test_name, source,
    c_args : test_cargs + extra_args.get('c_args', []),
    dependencies : test_deps + extra_args.get('dependencies', []),
    install_dir: installed_tests_execdir,
    install: install,
  )

  suite = ['glib'] + extra_args.get('suite', [])
202
  timeout = suite.contains('slow') ? test_timeout_slow : test_timeout
203 204
  test(test_name, exe, env : test_env, timeout : timeout, suite : suite,
    args : ['--tap'])
205 206
endforeach

207
# test-spawn-echo helper binary required by the spawn tests above
208
executable('test-spawn-echo', 'test-spawn-echo.c',
209
  c_args : test_cargs,
210
  dependencies : test_deps,
211 212
  install_dir: installed_tests_execdir,
  install: installed_tests_enabled,
213
)
214

215 216 217 218 219 220 221
executable('testing-helper', 'testing-helper.c',
  c_args : test_cargs,
  dependencies : test_deps,
  install_dir: installed_tests_execdir,
  install: installed_tests_enabled,
)

222
# some testing of gtester functionality
223
if not meson.is_cross_build() and host_system != 'windows'
224
  xmllint = find_program('xmllint', required: false)
225 226 227 228 229 230 231 232
  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],
Emmanuele Bassi's avatar
Emmanuele Bassi committed
233 234 235
      env : test_env,
      suite : ['glib'],
    )
236 237
  endif
endif