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