xref: /openbmc/qemu/tests/meson.build (revision 0ed93f4c)
1py3 = import('python').find_installation()
2
3qht_bench = executable('qht-bench',
4                       sources: 'qht-bench.c',
5                       dependencies: [qemuutil])
6
7executable('atomic_add-bench',
8           sources: files('atomic_add-bench.c'),
9           dependencies: [qemuutil],
10           build_by_default: false)
11
12executable('atomic64-bench',
13           sources: files('atomic64-bench.c'),
14           dependencies: [qemuutil],
15           build_by_default: false)
16
17test_qapi_outputs = [
18  'qapi-builtin-types.c',
19  'qapi-builtin-types.h',
20  'qapi-builtin-visit.c',
21  'qapi-builtin-visit.h',
22  'test-qapi-commands-sub-sub-module.c',
23  'test-qapi-commands-sub-sub-module.h',
24  'test-qapi-commands.c',
25  'test-qapi-commands.h',
26  'test-qapi-emit-events.c',
27  'test-qapi-emit-events.h',
28  'test-qapi-events-sub-sub-module.c',
29  'test-qapi-events-sub-sub-module.h',
30  'test-qapi-events.c',
31  'test-qapi-events.h',
32  'test-qapi-init-commands.c',
33  'test-qapi-init-commands.h',
34  'test-qapi-introspect.c',
35  'test-qapi-introspect.h',
36  'test-qapi-types-sub-sub-module.c',
37  'test-qapi-types-sub-sub-module.h',
38  'test-qapi-types.c',
39  'test-qapi-types.h',
40  'test-qapi-visit-sub-sub-module.c',
41  'test-qapi-visit-sub-sub-module.h',
42  'test-qapi-visit.c',
43  'test-qapi-visit.h',
44]
45
46test_qapi_files = custom_target('Test QAPI files',
47                                output: test_qapi_outputs,
48                                input: files('qapi-schema/qapi-schema-test.json',
49                                             'qapi-schema/include/sub-module.json',
50                                             'qapi-schema/sub-sub-module.json'),
51                                command: [ qapi_gen, '-o', meson.current_build_dir(),
52                                           '-b', '-p', 'test-', '@INPUT0@' ],
53                                depend_files: qapi_gen_depends)
54
55# meson doesn't like generated output in other directories
56# perhaps change qapi_gen to replace / with _, like Meson itself does?
57subdir('include')
58
59libtestqapi = static_library('testqapi', sources: [test_qapi_files, test_qapi_outputs_extra])
60testqapi = declare_dependency(link_with: libtestqapi)
61
62testblock = declare_dependency(dependencies: [block], sources: 'iothread.c')
63
64tests = {
65  'check-block-qdict': [],
66  'check-qdict': [],
67  'check-qnum': [],
68  'check-qstring': [],
69  'check-qlist': [],
70  'check-qnull': [],
71  'check-qobject': [],
72  'check-qjson': [],
73  'check-qlit': [],
74  'test-qobject-output-visitor': [testqapi],
75  'test-clone-visitor': [testqapi],
76  'test-qobject-input-visitor': [testqapi],
77  'test-string-input-visitor': [testqapi],
78  'test-string-output-visitor': [testqapi],
79  'test-qmp-event': [testqapi],
80  'test-opts-visitor': [testqapi],
81  'test-visitor-serialization': [testqapi],
82  'test-bitmap': [],
83  # all code tested by test-x86-cpuid is inside topology.h
84  'test-x86-cpuid': [],
85  'test-cutils': [],
86  'test-shift128': [],
87  'test-mul64': [],
88  # all code tested by test-int128 is inside int128.h
89  'test-int128': [],
90  'rcutorture': [],
91  'test-rcu-list': [],
92  'test-rcu-simpleq': [],
93  'test-rcu-tailq': [],
94  'test-rcu-slist': [],
95  'test-qdist': [],
96  'test-qht': [],
97  'test-bitops': [],
98  'test-bitcnt': [],
99  'test-qgraph': ['qtest/libqos/qgraph.c'],
100  'check-qom-interface': [qom],
101  'check-qom-proplist': [qom],
102  'test-qemu-opts': [],
103  'test-keyval': [testqapi],
104  'test-logging': [],
105  'test-uuid': [],
106  'ptimer-test': ['ptimer-test-stubs.c', meson.source_root() / 'hw/core/ptimer.c'],
107  'test-qapi-util': [],
108}
109
110test_deps = {
111  'test-qht-par': qht_bench,
112}
113
114benchs = {}
115
116if have_block
117  tests += {
118    'test-coroutine': [testblock],
119    'test-aio': [testblock],
120    'test-aio-multithread': [testblock],
121    'test-throttle': [testblock],
122    'test-thread-pool': [testblock],
123    'test-hbitmap': [testblock],
124    'test-bdrv-drain': [testblock],
125    'test-bdrv-graph-mod': [testblock],
126    'test-blockjob': [testblock],
127    'test-blockjob-txn': [testblock],
128    'test-block-backend': [testblock],
129    'test-block-iothread': [testblock],
130    'test-write-threshold': [testblock],
131    'test-crypto-hash': [crypto],
132    'test-crypto-hmac': [crypto],
133    'test-crypto-cipher': [crypto],
134    'test-crypto-secret': [crypto, keyutils],
135    'test-authz-simple': [authz],
136    'test-authz-list': [authz],
137    'test-authz-listfile': [authz],
138    'test-io-task': [testblock],
139    'test-io-channel-socket': ['socket-helpers.c', 'io-channel-helpers.c', io],
140    'test-io-channel-file': ['io-channel-helpers.c', io],
141    'test-io-channel-command': ['io-channel-helpers.c', io],
142    'test-io-channel-buffer': ['io-channel-helpers.c', io],
143    'test-crypto-ivgen': [io],
144    'test-crypto-afsplit': [io],
145    'test-crypto-block': [io],
146  }
147  if 'CONFIG_GNUTLS' in config_host and \
148     'CONFIG_TASN1' in config_host and \
149     'CONFIG_POSIX' in config_host
150    tests += {
151      'test-crypto-tlscredsx509': ['crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',
152                                   tasn1, crypto],
153      'test-crypto-tlssession': ['crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c', 'crypto-tls-psk-helpers.c',
154                                 tasn1, crypto],
155      'test-io-channel-tls': ['io-channel-helpers.c', 'crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',
156                              tasn1, io, crypto]}
157  endif
158  if 'CONFIG_AUTH_PAM' in config_host
159    tests += {'test-authz-pam': [authz]}
160  endif
161  if 'CONFIG_QEMU_PRIVATE_XTS' in config_host
162    tests += {'test-crypto-xts': [crypto, io]}
163  endif
164  if 'CONFIG_POSIX' in config_host
165    tests += {'test-image-locking': [testblock]}
166  endif
167  if 'CONFIG_REPLICATION' in config_host
168    tests += {'test-replication': [testblock]}
169  endif
170  if 'CONFIG_NETTLE' in config_host or 'CONFIG_GCRYPT' in config_host
171    tests += {'test-crypto-pbkdf': [io]}
172  endif
173  if 'CONFIG_EPOLL_CREATE1' in config_host
174    tests += {'test-fdmon-epoll': [testblock]}
175  endif
176  benchs += {
177     'benchmark-crypto-hash': [crypto],
178     'benchmark-crypto-hmac': [crypto],
179     'benchmark-crypto-cipher': [crypto],
180  }
181endif
182
183if have_system
184  tests += {
185    'test-iov': [],
186    'test-qmp-cmds': [testqapi],
187    'test-xbzrle': [migration],
188    'test-timed-average': [],
189    'test-util-sockets': ['socket-helpers.c'],
190    'test-base64': [],
191    'test-bufferiszero': [],
192    'test-vmstate': [migration, io]
193  }
194  if 'CONFIG_INOTIFY1' in config_host
195    tests += {'test-util-filemonitor': []}
196  endif
197
198  # Some tests: test-char, test-qdev-global-props, and test-qga,
199  # are not runnable under TSan due to a known issue.
200  # https://github.com/google/sanitizers/issues/1116
201  if 'CONFIG_TSAN' not in config_host
202    if 'CONFIG_POSIX' in config_host
203        tests += {
204          'test-char': ['socket-helpers.c', qom, io, chardev]
205        }
206    endif
207
208    tests += {
209      'test-qdev-global-props': [qom, hwcore, testqapi]
210    }
211  endif
212endif
213
214if 'CONFIG_TSAN' not in config_host and \
215   'CONFIG_GUEST_AGENT' in config_host and \
216   'CONFIG_LINUX' in config_host
217  tests += {'test-qga': ['qtest/libqtest.c']}
218  test_deps += {'test-qga': qga}
219endif
220
221test_env = environment()
222test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
223test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
224
225foreach test_name, extra: tests
226  src = [test_name + '.c']
227  deps = [qemuutil]
228  if extra.length() > 0
229    # use a sourceset to quickly separate sources and deps
230    test_ss = ss.source_set()
231    test_ss.add(extra)
232    src += test_ss.all_sources()
233    deps += test_ss.all_dependencies()
234  endif
235  exe = executable(test_name, src, dependencies: deps)
236
237  test(test_name, exe,
238       depends: test_deps.get(test_name, []),
239       env: test_env,
240       args: ['--tap', '-k'],
241       protocol: 'tap',
242       suite: ['unit'])
243endforeach
244
245foreach bench_name, deps: benchs
246  exe = executable(bench_name, bench_name + '.c',
247                   dependencies: [qemuutil] + deps)
248  benchmark(bench_name, exe,
249            args: ['--tap', '-k'],
250            protocol: 'tap',
251            suite: ['speed'])
252endforeach
253
254if have_tools and 'CONFIG_VHOST_USER' in config_host
255  executable('vhost-user-bridge',
256             sources: files('vhost-user-bridge.c'),
257             link_with: [libvhost_user],
258             dependencies: [qemuutil],
259             build_by_default: false)
260endif
261
262if have_system and 'CONFIG_POSIX' in config_host
263  subdir('qemu-iotests')
264endif
265
266test('decodetree', sh,
267     args: [ files('decode/check.sh'), config_host['PYTHON'], files('../scripts/decodetree.py') ],
268     workdir: meson.current_source_dir() / 'decode',
269     suite: 'decodetree')
270
271subdir('fp')
272
273if 'CONFIG_TCG' in config_host
274  if 'CONFIG_PLUGIN' in config_host
275    subdir('plugin')
276  endif
277endif
278
279subdir('qapi-schema')
280subdir('qtest')
281subdir('migration')
282