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