aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2022-04-21 16:48:16 +0100
committerJohn Levon <levon@movementarian.org>2022-05-09 23:28:10 +0100
commit5b69b60c197695579fd48abaa81c39b9984f1cab (patch)
treecd4717b8a875b2810af93d72e21b34248c62e761 /test
parent18fb66bcec7b88301f949e586dbd773b8e3ee067 (diff)
downloadlibvfio-user-5b69b60c197695579fd48abaa81c39b9984f1cab.zip
libvfio-user-5b69b60c197695579fd48abaa81c39b9984f1cab.tar.gz
libvfio-user-5b69b60c197695579fd48abaa81c39b9984f1cab.tar.bz2
build: introduce Meson build file rules
The Meson build system used by many other virt projects (QEMU, libvirt and others) is easier to understand & maintain rules for than cmake, guiding towards best practice. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/meson.build99
-rw-r--r--test/py/meson.build71
2 files changed, 170 insertions, 0 deletions
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..ba6f7c5
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,99 @@
+
+if valgrind.found()
+ valgrind_common_wrapper = [
+ valgrind,
+ '--quiet',
+ '--track-origins=yes',
+ '--error-exitcode=1',
+ '--exit-on-first-error=yes',
+ '--leak-check=full',
+ ]
+
+ valgrind_unit_wrapper = valgrind_common_wrapper + [
+ '--suppressions=' + ( meson.current_source_dir() / 'valgrind.supp' ),
+ '--show-leak-kinds=all',
+ ]
+ if meson.version().version_compare('<0.57.0')
+ add_test_setup('valgrind',
+ exe_wrapper: valgrind_unit_wrapper)
+ else
+ add_test_setup('valgrind',
+ exclude_suites: ['functional', 'pyunit', 'style'],
+ exe_wrapper: valgrind_unit_wrapper)
+ endif
+endif
+
+unit_tests_sources = [
+ 'unit-tests.c',
+ 'mocks.c',
+ '../lib/dma.c',
+ '../lib/irq.c',
+ '../lib/libvfio-user.c',
+ '../lib/migration.c',
+ '../lib/pci.c',
+ '../lib/pci_caps.c',
+ '../lib/tran.c',
+ '../lib/tran_pipe.c',
+ '../lib/tran_sock.c',
+]
+
+unit_tests_deps = [
+ json_c_dep,
+ cmocka_dep,
+ dl_dep,
+]
+unit_tests_cflags = [
+ '-DUNIT_TEST',
+ '-DWITH_TRAN_PIPE',
+]
+
+unit_tests = executable(
+ 'unit_tests',
+ unit_tests_sources,
+ c_args: unit_tests_cflags + common_cflags,
+ dependencies: unit_tests_deps,
+ include_directories: public_include_dir + lib_include_dir,
+ install: false,
+)
+
+test(
+ 'unit_tests',
+ unit_tests,
+ suite: 'unit',
+)
+
+test(
+ 'test-lspci',
+ find_program('test-lspci.sh'),
+ suite: 'functional',
+ args: [lspci],
+)
+
+csenv = []
+if opt_sanitizers != 'none'
+ csenv += ['WITH_ASAN=1']
+endif
+
+test(
+ 'test-client-server',
+ find_program('test-client-server.sh'),
+ env: csenv,
+ suite: 'functional',
+ args: [client, server],
+ timeout: 90,
+)
+
+if opt_sanitizers == 'none'
+ test(
+ 'test-linkage.sh',
+ find_program('test-linkage.sh'),
+ suite: 'functional',
+ args: [
+ meson.source_root(),
+ meson.build_root(),
+ ' '.join(cc.cmd_array()),
+ ]
+ )
+endif
+
+subdir('py')
diff --git a/test/py/meson.build b/test/py/meson.build
new file mode 100644
index 0000000..e8266e7
--- /dev/null
+++ b/test/py/meson.build
@@ -0,0 +1,71 @@
+
+if valgrind.found()
+ valgrind_pyunit_wrapper = valgrind_common_wrapper + [
+ '--suppressions=' + ( meson.current_source_dir() / 'valgrind.supp' ),
+ '--show-leak-kinds=definite',
+ '--errors-for-leak-kinds=definite',
+ ]
+ valgrind_pyunit_env = ['PYTHONMALLOC=malloc']
+
+ if meson.version().version_compare('<0.57.0')
+ add_test_setup('pyvalgrind',
+ env: valgrind_pyunit_env,
+ exe_wrapper: valgrind_pyunit_wrapper,
+ timeout_multiplier: 10)
+ else
+ add_test_setup('pyvalgrind',
+ exclude_suites: ['functional', 'unit', 'style'],
+ env: valgrind_pyunit_env,
+ exe_wrapper: valgrind_pyunit_wrapper,
+ timeout_multiplier: 10)
+ endif
+endif
+
+python_tests_common = [
+ 'libvfio_user.py',
+]
+
+python_tests = [
+ 'test_destroy.py',
+ 'test_device_get_info.py',
+ 'test_device_get_irq_info.py',
+ 'test_device_get_region_info.py',
+ 'test_device_get_region_info_zero_size.py',
+ 'test_device_get_region_io_fds.py',
+ 'test_device_set_irqs.py',
+ 'test_dirty_pages.py',
+ 'test_dma_map.py',
+ 'test_dma_unmap.py',
+ 'test_irq_trigger.py',
+ 'test_map_unmap_sg.py',
+ 'test_migration.py',
+ 'test_negotiate.py',
+ 'test_pci_caps.py',
+ 'test_pci_ext_caps.py',
+ 'test_quiesce.py',
+ 'test_request_errors.py',
+ 'test_setup_region.py',
+ 'test_vfu_create_ctx.py',
+ 'test_vfu_realize_ctx.py',
+]
+
+python_files = python_tests_common + python_tests
+
+if pytest.found() and opt_sanitizers == 'none'
+ foreach testname: python_tests
+ test(testname,
+ pytest,
+ suite: 'pyunit',
+ env: environment({'LIBVFIO_SO_DIR': libvfio_so_dir}),
+ args: [files(testname)])
+ endforeach
+endif
+
+if flake8.found()
+ flake8_ignore = 'F405,F403,E128,E131,E127'
+ test('flake8',
+ flake8,
+ suite: 'style',
+ args: ['--extend-ignore', flake8_ignore,
+ files(python_files)])
+endif