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