• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_dep)
11else
12  test_utils = library(test_utils_name, test_utils_name + '.c',
13    dependencies : libsoup_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 installed_tests_enabled
27  install_data(
28    'index.txt',
29    'test-cert.pem',
30    'test-key.pem',
31    install_dir : installed_tests_execdir
32  )
33endif
34
35# ['name', is_parallel, extra_deps]
36tests = [
37  ['cache', true, []],
38  ['chunk', true, []],
39  ['chunk-io', true, []],
40  ['coding', true, []],
41  ['context', true, []],
42  ['continue', true, []],
43  ['cookies', true, []],
44  ['date', true, []],
45  ['forms', true, []],
46  ['header-parsing', true, []],
47  ['hsts', true, []],
48  ['hsts-db', true, []],
49  ['misc', true, []],
50  ['multipart', true, []],
51  ['no-ssl', true, []],
52  ['ntlm', true, []],
53  ['redirect', true, []],
54  ['requester', true, []],
55  ['resource', true, []],
56  ['samesite', true, []],
57  ['session', true, []],
58  ['server-auth', true, []],
59  ['server', true, []],
60  ['sniffing', true, []],
61  ['socket', true, []],
62  ['ssl', true, []],
63  ['streaming', true, []],
64  ['timeout', true, []],
65  ['tld', true, []],
66  ['uri-parsing', true, []],
67  ['websocket', true, [libz_dep]]
68]
69
70if brotlidec_dep.found()
71  tests += [
72    ['brotli-decompressor', true, []],
73  ]
74
75  if installed_tests_enabled
76    install_data(
77      'brotli-data/compressed.br',
78      'brotli-data/corrupt.br',
79      'brotli-data/uncompressed.txt',
80      install_dir : join_paths(installed_tests_execdir, 'brotli-data'),
81    )
82  endif
83endif
84
85if have_apache
86  tests += [
87    ['auth', false, []],
88    ['connection', false, []],
89    ['range', false, []],
90    ['proxy', false, []],
91    ['pull-api', false, []],
92  ]
93
94  configure_file(output : 'httpd.conf',
95    input : 'httpd.conf.in',
96    configuration : cdata,
97    install : installed_tests_enabled,
98    install_dir : installed_tests_execdir,
99  )
100
101  configure_file(input : 'htdigest',
102    output : 'htdigest',
103    copy : true)
104  configure_file(input : 'htpasswd',
105    output : 'htpasswd',
106    copy : true)
107  configure_file(input : 'index.txt',
108    output : 'index.txt',
109    copy : true)
110  configure_file(input : 'test-cert.pem',
111    output : 'test-cert.pem',
112    copy : true)
113  configure_file(input : 'test-key.pem',
114    output : 'test-key.pem',
115    copy : true)
116
117  if installed_tests_enabled
118    install_data(
119      'htdigest',
120      'htpasswd',
121      install_dir : installed_tests_execdir,
122    )
123  endif
124endif
125
126if have_php
127  configure_file(output : 'php.ini',
128    input : 'php.ini.in',
129    configuration : cdata,
130    install : installed_tests_enabled,
131    install_dir : installed_tests_execdir,
132  )
133endif
134
135if have_php_xmlrpc
136  tests += [
137    ['xmlrpc-old-server', true, []],
138    ['xmlrpc-old', false, []],
139    ['xmlrpc-server', true, []],
140    ['xmlrpc', false, []]
141  ]
142
143  configure_file(input : 'xmlrpc-server.php',
144    output : 'xmlrpc-server.php',
145    copy : true)
146
147  if installed_tests_enabled
148    install_data(
149      'xmlrpc-server.php',
150      install_dir : installed_tests_execdir,
151    )
152  endif
153endif
154
155env = environment()
156env.set('G_TEST_SRCDIR', meson.current_source_dir())
157env.set('G_TEST_BUILDDIR', meson.current_build_dir())
158env.set('G_DEBUG', 'gc-friendly')
159# See https://github.com/mesonbuild/meson/issues/1383 for the workaround below
160env.prepend('LD_LIBRARY_PATH', meson.build_root() + '/libsoup')
161env.set('MALLOC_CHECK_', '2')
162# This is set by Meson if empty
163env.set('MALLOC_PERTURB_', '')
164
165foreach test: tests
166  test_name = '@0@-test'.format(test[0])
167
168  if installed_tests_enabled
169    test_conf = configuration_data()
170    test_conf.set('installed_tests_dir', abs_installed_tests_execdir)
171    test_conf.set('program', test_name)
172    test_conf.set('env', '')
173    test_conf.set('type', test[1] ? 'session' : 'session-exclusive')
174    configure_file(
175      input : installed_tests_template_tap,
176      output : test_name + '.test',
177      install_dir : installed_tests_metadir,
178      configuration : test_conf,
179    )
180  endif
181
182  test_deps = [ libsoup_dep ] + test[2]
183  test_target = executable(test_name,
184    sources : [ test_name + '.c', test_resources ],
185    link_with : test_utils,
186    dependencies : test_deps,
187    install : installed_tests_enabled,
188    install_dir : installed_tests_execdir,
189    install_rpath : abs_installed_tests_execdir,
190  )
191  # Increase the timeout as on some architectures the tests could be slower
192  # than the default 30 seconds.
193  test(test_name, test_target, env : env, is_parallel : test[1], timeout : 60)
194endforeach
195
196executable('ntlm-test-helper', 'ntlm-test-helper.c',
197  dependencies : libsoup_dep,
198  install : installed_tests_enabled,
199  install_dir : installed_tests_execdir,
200  install_rpath : abs_installed_tests_execdir,
201)
202