xref: /openbmc/qemu/tests/unit/meson.build (revision dec490db)
1
2testblock = declare_dependency(dependencies: [block], sources: 'iothread.c')
3
4tests = {
5  'check-block-qdict': [],
6  'check-qdict': [],
7  'check-qnum': [],
8  'check-qstring': [],
9  'check-qlist': [],
10  'check-qnull': [],
11  'check-qobject': [],
12  'check-qjson': [],
13  'check-qlit': [],
14  'test-qobject-output-visitor': [testqapi],
15  'test-clone-visitor': [testqapi],
16  'test-qobject-input-visitor': [testqapi],
17  'test-forward-visitor': [testqapi],
18  'test-string-input-visitor': [testqapi],
19  'test-string-output-visitor': [testqapi],
20  'test-opts-visitor': [testqapi],
21  'test-visitor-serialization': [testqapi],
22  'test-bitmap': [],
23  # all code tested by test-x86-cpuid is inside topology.h
24  'test-x86-cpuid': [],
25  'test-cutils': [],
26  'test-shift128': [],
27  'test-mul64': [],
28  # all code tested by test-int128 is inside int128.h
29  'test-int128': [],
30  'rcutorture': [],
31  'test-rcu-list': [],
32  'test-rcu-simpleq': [],
33  'test-rcu-tailq': [],
34  'test-rcu-slist': [],
35  'test-qdist': [],
36  'test-qht': [],
37  'test-bitops': [],
38  'test-bitcnt': [],
39  'test-qgraph': ['../qtest/libqos/qgraph.c'],
40  'check-qom-interface': [qom],
41  'check-qom-proplist': [qom],
42  'test-qemu-opts': [],
43  'test-keyval': [testqapi],
44  'test-logging': [],
45  'test-uuid': [],
46  'ptimer-test': ['ptimer-test-stubs.c', meson.project_source_root() / 'hw/core/ptimer.c'],
47  'test-qapi-util': [],
48}
49
50if have_system or have_tools
51  tests += {
52    'test-qmp-event': [testqapi],
53  }
54endif
55
56if have_block
57  tests += {
58    'test-coroutine': [testblock],
59    'test-aio': [testblock],
60    'test-aio-multithread': [testblock],
61    'test-throttle': [testblock],
62    'test-thread-pool': [testblock],
63    'test-hbitmap': [testblock],
64    'test-bdrv-drain': [testblock],
65    'test-bdrv-graph-mod': [testblock],
66    'test-blockjob': [testblock],
67    'test-blockjob-txn': [testblock],
68    'test-block-backend': [testblock],
69    'test-block-iothread': [testblock],
70    'test-write-threshold': [testblock],
71    'test-crypto-hash': [crypto],
72    'test-crypto-hmac': [crypto],
73    'test-crypto-cipher': [crypto],
74    'test-crypto-secret': [crypto, keyutils],
75    'test-authz-simple': [authz],
76    'test-authz-list': [authz],
77    'test-authz-listfile': [authz],
78    'test-io-task': [testblock],
79    'test-io-channel-socket': ['socket-helpers.c', 'io-channel-helpers.c', io],
80    'test-io-channel-file': ['io-channel-helpers.c', io],
81    'test-io-channel-command': ['io-channel-helpers.c', io],
82    'test-io-channel-buffer': ['io-channel-helpers.c', io],
83    'test-crypto-ivgen': [io],
84    'test-crypto-afsplit': [io],
85    'test-crypto-block': [io],
86  }
87  if gnutls.found() and \
88     tasn1.found() and \
89     'CONFIG_POSIX' in config_host
90    tests += {
91      'test-crypto-tlscredsx509': ['crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',
92                                   tasn1, crypto, gnutls],
93      'test-crypto-tlssession': ['crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c', 'crypto-tls-psk-helpers.c',
94                                 tasn1, crypto, gnutls],
95      'test-io-channel-tls': ['io-channel-helpers.c', 'crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',
96                              tasn1, io, crypto, gnutls]}
97  endif
98  if pam.found()
99    tests += {'test-authz-pam': [authz]}
100  endif
101  if xts == 'private'
102    tests += {'test-crypto-xts': [crypto, io]}
103  endif
104  if 'CONFIG_POSIX' in config_host
105    tests += {'test-image-locking': [testblock]}
106  endif
107  if 'CONFIG_REPLICATION' in config_host
108    tests += {'test-replication': [testblock]}
109  endif
110  if nettle.found() or gcrypt.found()
111    tests += {'test-crypto-pbkdf': [io]}
112  endif
113  if 'CONFIG_EPOLL_CREATE1' in config_host
114    tests += {'test-fdmon-epoll': [testblock]}
115  endif
116endif
117
118if have_system
119  tests += {
120    'test-iov': [],
121    'test-qmp-cmds': [testqapi],
122    'test-xbzrle': [migration],
123    'test-timed-average': [],
124    'test-util-sockets': ['socket-helpers.c'],
125    'test-base64': [],
126    'test-bufferiszero': [],
127    'test-vmstate': [migration, io],
128    'test-yank': ['socket-helpers.c', qom, io, chardev]
129  }
130  if 'CONFIG_INOTIFY1' in config_host
131    tests += {'test-util-filemonitor': []}
132  endif
133
134  # Some tests: test-char, test-qdev-global-props, and test-qga,
135  # are not runnable under TSan due to a known issue.
136  # https://github.com/google/sanitizers/issues/1116
137  if 'CONFIG_TSAN' not in config_host
138    if 'CONFIG_POSIX' in config_host
139        tests += {
140          'test-char': ['socket-helpers.c', qom, io, chardev]
141        }
142    endif
143
144    tests += {
145      'test-qdev-global-props': [qom, hwcore, testqapi]
146    }
147  endif
148endif
149
150if 'CONFIG_TSAN' not in config_host and \
151   'CONFIG_GUEST_AGENT' in config_host and \
152   'CONFIG_LINUX' in config_host
153  tests += {'test-qga': ['../qtest/libqtest.c']}
154  test_deps += {'test-qga': qga}
155endif
156
157test_env = environment()
158test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
159test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
160
161slow_tests = {
162  'test-crypto-tlscredsx509': 45,
163  'test-crypto-tlssession': 45
164}
165
166foreach test_name, extra: tests
167  src = [test_name + '.c']
168  deps = [qemuutil]
169  if extra.length() > 0
170    # use a sourceset to quickly separate sources and deps
171    test_ss = ss.source_set()
172    test_ss.add(extra)
173    src += test_ss.all_sources()
174    deps += test_ss.all_dependencies()
175  endif
176  exe = executable(test_name, src, genh, dependencies: deps)
177
178  test(test_name, exe,
179       depends: test_deps.get(test_name, []),
180       env: test_env,
181       args: ['--tap', '-k'],
182       protocol: 'tap',
183       timeout: slow_tests.get(test_name, 30),
184       priority: slow_tests.get(test_name, 30),
185       suite: ['unit'])
186endforeach
187