aboutsummaryrefslogtreecommitdiff
path: root/test/meson.build
blob: 1c3aef5998aad2784a5b28e8b0062d1b468e8141 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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' and meson.version().version_compare('>=0.56.0')
    test(
        'test-linkage.sh',
        find_program('test-linkage.sh'),
        suite: 'functional',
        args: [
            meson.project_source_root(),
            meson.project_build_root(),
            ' '.join(cc.cmd_array()),
        ]
    )
endif

subdir('py')