1test_utils_name = 'test-utils' 2installed_tests_metadir = join_paths(get_option('datadir'), 'installed-tests', libsoup_api_name) 3installed_tests_execdir = join_paths(get_option('libexecdir'), 'installed-tests', libsoup_api_name) 4installed_tests_enabled = get_option('installed_tests') 5installed_tests_template_tap = files('template-tap.test.in') 6abs_installed_tests_execdir = join_paths(prefix, installed_tests_execdir) 7 8if cc.get_id() == 'msvc' 9 test_utils = static_library(test_utils_name, test_utils_name + '.c', 10 dependencies : [ libsoup_static_dep, unix_socket_dep ]) 11else 12 test_utils = library(test_utils_name, test_utils_name + '.c', 13 dependencies : [ libsoup_static_dep, unix_socket_dep ], 14 install : installed_tests_enabled, 15 install_dir : installed_tests_execdir, 16 ) 17endif 18 19test_resources = gnome.compile_resources('soup-tests', 20 'soup-tests.gresource.xml', 21 gresource_bundle : true, 22 install : installed_tests_enabled, 23 install_dir : installed_tests_execdir, 24) 25 26if gnutls_dep.found() 27 mock_pkcs11_module = shared_module('mock-pkcs11', 28 sources: 'mock-pkcs11.c', 29 name_prefix: '', 30 gnu_symbol_visibility: 'hidden', 31 include_directories: include_directories('pkcs11'), 32 dependencies: [ 33 gio_dep, 34 gnutls_dep, 35 ], 36 install: installed_tests_enabled, 37 install_dir: installed_tests_execdir 38 ) 39else 40 mock_pkcs11_module = [] 41endif 42 43configure_file(input : 'index.txt', 44 output : 'index.txt', 45 copy : true) 46configure_file(input : 'test-cert.pem', 47 output : 'test-cert.pem', 48 copy : true) 49configure_file(input : 'test-key.pem', 50 output : 'test-key.pem', 51 copy : true) 52configure_file(input : 'test-cert-2.pem', 53 output : 'test-cert-2.pem', 54 copy : true) 55configure_file(input : 'test-key-2.pem', 56 output : 'test-key-2.pem', 57 copy : true) 58 59if installed_tests_enabled 60 install_data( 61 'index.txt', 62 'test-cert.pem', 63 'test-key.pem', 64 install_dir : installed_tests_execdir 65 ) 66endif 67 68# ['name', is_parallel, extra_deps] 69tests = [ 70 {'name': 'cache'}, 71 {'name': 'chunk-io'}, 72 {'name': 'coding'}, 73 {'name': 'context'}, 74 {'name': 'continue'}, 75 {'name': 'cookies'}, 76 {'name': 'date'}, 77 {'name': 'forms'}, 78 {'name': 'header-parsing'}, 79 {'name': 'http2-body-stream'}, 80 {'name': 'hsts'}, 81 {'name': 'hsts-db'}, 82 {'name': 'logger'}, 83 {'name': 'misc'}, 84 {'name': 'multipart'}, 85 {'name': 'no-ssl'}, 86 {'name': 'ntlm'}, 87 {'name': 'redirect'}, 88 {'name': 'request-body'}, 89 {'name': 'samesite'}, 90 {'name': 'session'}, 91 {'name': 'server-auth'}, 92 {'name': 'server'}, 93 {'name': 'sniffing'}, 94 {'name': 'socket'}, 95 {'name': 'ssl', 96 'dependencies': [gnutls_dep], 97 'depends': mock_pkcs11_module, 98 'c_args': '-DHAVE_GNUTLS=@0@'.format(gnutls_dep.found() ? 1 : 0), 99 }, 100 {'name': 'streaming'}, 101 {'name': 'timeout'}, 102 {'name': 'tld'}, 103 {'name': 'uri-parsing'}, 104 {'name': 'websocket', 105 'dependencies': [libz_dep]}, 106] 107 108if quart_found 109 configure_file(input : 'http2-server.py', 110 output : 'http2-server.py', 111 copy : true) 112 113 tests += [{'name': 'http2'}] 114endif 115 116if brotlidec_dep.found() 117 tests += [{'name': 'brotli-decompressor'}] 118 119 if installed_tests_enabled 120 install_data( 121 'brotli-data/compressed.br', 122 'brotli-data/corrupt.br', 123 'brotli-data/uncompressed.txt', 124 install_dir : join_paths(installed_tests_execdir, 'brotli-data'), 125 ) 126 endif 127endif 128 129if unix_socket_dep.found() 130 tests += [{ 131 'name': 'unix-socket', 132 'dependencies': [unix_socket_dep], 133 }] 134endif 135 136if have_apache 137 tests += [ 138 {'name': 'auth', 'parallel': false}, 139 {'name': 'connection', 'parallel': false}, 140 {'name': 'range', 'parallel': false}, 141 {'name': 'proxy', 'parallel': false}, 142 ] 143 144 configure_file(output : 'httpd.conf', 145 input : 'httpd.conf.in', 146 configuration : cdata, 147 install : installed_tests_enabled, 148 install_dir : installed_tests_execdir, 149 ) 150 151 configure_file(input : 'htdigest', 152 output : 'htdigest', 153 copy : true) 154 configure_file(input : 'htpasswd', 155 output : 'htpasswd', 156 copy : true) 157 158 if installed_tests_enabled 159 install_data( 160 'htdigest', 161 'htpasswd', 162 install_dir : installed_tests_execdir, 163 ) 164 endif 165endif 166 167env = environment() 168env.set('G_TEST_SRCDIR', meson.current_source_dir()) 169env.set('G_TEST_BUILDDIR', meson.current_build_dir()) 170env.set('G_DEBUG', 'gc-friendly') 171# See https://github.com/mesonbuild/meson/issues/1383 for the workaround below 172env.prepend('LD_LIBRARY_PATH', meson.build_root() + '/libsoup') 173env.set('MALLOC_CHECK_', '2') 174# This is set by Meson if empty 175env.set('MALLOC_PERTURB_', '') 176 177if meson.version().version_compare('>= 0.58.0') 178 meson.add_devenv(env) 179endif 180 181if have_autobahn 182 subdir('autobahn') 183endif 184 185foreach test: tests 186 test_name = '@0@-test'.format(test['name']) 187 188 if installed_tests_enabled 189 test_conf = configuration_data() 190 test_conf.set('installed_tests_dir', abs_installed_tests_execdir) 191 test_conf.set('program', test_name) 192 test_conf.set('env', '') 193 test_conf.set('type', test.get('parallel', true) ? 'session' : 'session-exclusive') 194 configure_file( 195 input : installed_tests_template_tap, 196 output : test_name + '.test', 197 install_dir : installed_tests_metadir, 198 configuration : test_conf, 199 ) 200 endif 201 202 test_deps = [ libsoup_static_dep ] + test.get('dependencies', []) 203 test_target = executable(test_name, 204 sources : [ test_name + '.c', test_resources ], 205 c_args : test.get('c_args', []), 206 include_directories : test.get('includes', []), 207 link_with : test_utils, 208 dependencies : test_deps, 209 install : installed_tests_enabled, 210 install_dir : installed_tests_execdir, 211 install_rpath : abs_installed_tests_execdir, 212 ) 213 # Increase the timeout as on some architectures the tests could be slower 214 # than the default 30 seconds. 215 test(test_name, test_target, 216 args : ['--debug'], 217 env : env, 218 is_parallel : test.get('parallel', true), 219 depends : test.get('depends', []), 220 timeout : 60, 221 protocol : 'tap', 222 ) 223endforeach 224 225executable('ntlm-test-helper', 'ntlm-test-helper.c', 226 dependencies : libsoup_dep, 227 install : installed_tests_enabled, 228 install_dir : installed_tests_execdir, 229 install_rpath : abs_installed_tests_execdir, 230) 231