meson.build 5.56 KB
Newer Older
1
envs = environment()
2
# Enable debug messages and abort on warnings
3
4
envs.set('G_DEBUG', 'fatal-warnings')
envs.set('G_MESSAGES_DEBUG', 'all')
5
6

# Setup paths
7
envs.set('MESON_SOURCE_ROOT', meson.source_root())
8
envs.prepend('LD_LIBRARY_PATH', join_paths(meson.build_root(), 'libfprint'))
9
10
11
12
13

# Set FP_DEVICE_EMULATION so that drivers can adapt (e.g. to use fixed
# random numbers rather than proper ones)
envs.set('FP_DEVICE_EMULATION', '1')

14
15
16
# Set a colon-separated list of native drivers we enable in tests
envs.set('FP_DRIVERS_WHITELIST', 'virtual_image')

17
18
envs.set('NO_AT_BRIDGE', '1')

19
drivers_tests = [
Benjamin Berg's avatar
Benjamin Berg committed
20
    'aes3500',
21
22
    'elan',
    'synaptics',
23
    'vfs0050',
24
    'vfs301',
25
    'vfs5011',
26
    'goodixmoc',
27
28
]

29
if get_option('introspection')
30
31
    envs.prepend('GI_TYPELIB_PATH', join_paths(meson.build_root(), 'libfprint'))

32
    if 'virtual_image' in drivers
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
        python3 = find_program('python3')
        unittest_inspector = find_program('unittest_inspector.py')
        base_args = files('virtual-image.py')
        suite = []

        r = run_command(unittest_inspector, files('virtual-image.py'))
        unit_tests = r.stdout().strip().split('\n')

        if r.returncode() == 0 and unit_tests.length() > 0
            suite += 'virtual-image'
        else
            unit_tests = ['virtual-image']
        endif

        foreach ut: unit_tests
            ut_suite = suite
            ut_args = base_args
            if unit_tests.length() > 1
                ut_args += ut
                ut_suite += ut.split('.')[0]
            endif
            test(ut,
                python3,
                args: ut_args,
                suite: ut_suite,
                depends: libfprint_typelib,
                env: envs,
            )
        endforeach
62
63
64
65
66
    else
        test('virtual-image',
            find_program('sh'),
            args: ['-c', 'exit 77']
        )
67
    endif
68

69
    foreach driver_test: drivers_tests
70
71
72
        driver_envs = envs
        driver_envs.set('FP_DRIVERS_WHITELIST', driver_test)

73
74
        if (driver_test in supported_drivers and
            gusb_dep.version().version_compare('>= 0.3.0'))
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
            test(driver_test,
                find_program('umockdev-test.py'),
                args: join_paths(meson.current_source_dir(), driver_test),
                env: driver_envs,
                suite: ['drivers'],
                timeout: 10,
                depends: libfprint_typelib,
            )
        else
            test(driver_test,
                find_program('sh'),
                args: ['-c', 'exit 77']
            )
        endif
    endforeach
else
    warning('Skipping all driver tests as introspection bindings are missing')
    test('virtual-image',
        find_program('sh'),
        args: ['-c', 'exit 77']
    )

    foreach driver_test: drivers_tests
98
        test(driver_test,
99
100
            find_program('sh'),
            args: ['-c', 'exit 77']
101
        )
102
    endforeach
103
endif
104

105
106
107
108
109
110
111
112
test_utils = static_library('fprint-test-utils',
    sources: [
        'test-utils.c',
        'test-device-fake.c',
    ],
    dependencies: libfprint_private_dep,
    install: false)

Marco Trevisan's avatar
Marco Trevisan committed
113
114
unit_tests = [
    'fpi-device',
115
    'fpi-ssm',
116
    'fpi-assembling',
Marco Trevisan's avatar
Marco Trevisan committed
117
]
118

119
120
if 'virtual_image' in drivers
    unit_tests += [
121
        'fp-context',
122
        'fp-device',
123
124
125
    ]
endif

126
127
128
129
130
131
unit_tests_deps = { 'fpi-assembling' : [cairo_dep] }

test_config = configuration_data()
test_config.set_quoted('SOURCE_ROOT', meson.source_root())
test_config_h = configure_file(output: 'test-config.h', configuration: test_config)

132
foreach test_name: unit_tests
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
    if unit_tests_deps.has_key(test_name)
        missing_deps = false
        foreach dep: unit_tests_deps[test_name]
            if not dep.found()
                missing_deps = true
                break
            endif
        endforeach

        if missing_deps
            # Create a dummy test that always skips instead
            warning('Test @0@ cannot be compiled due to missing dependencies'.format(test_name))
            test(test_name,
                find_program('sh'),
                suite: ['unit-tests'],
                args: ['-c', 'exit 77'],
            )
            continue
        endif
        extra_deps = unit_tests_deps[test_name]
    else
        extra_deps = []
    endif

157
158
    basename = 'test-' + test_name
    test_exe = executable(basename,
159
160
        sources: [basename + '.c', test_config_h],
        dependencies: [ libfprint_private_dep ] + extra_deps,
161
162
163
164
165
166
167
168
169
170
171
        c_args: common_cflags,
        link_with: test_utils,
    )
    test(test_name,
        find_program('test-runner.sh'),
        suite: ['unit-tests'],
        args: [test_exe],
        env: envs,
    )
endforeach

172
# Run udev rule generator with fatal warnings
173
174
test('udev-hwdb',
     udev_hwdb,
175
176
     env: envs)

177
178
179
180
181
182
183
184
185
gdb = find_program('gdb', required: false)
if gdb.found()
    add_test_setup('gdb',
        timeout_multiplier: 1000,
        env: [
            'LIBFPRINT_TEST_WRAPPER=@0@ --args'.format(
                gdb.path())
        ])
endif
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201

valgrind = find_program('valgrind', required: false)
if valgrind.found()
    glib_share = glib_dep.get_pkgconfig_variable('prefix') / 'share' / glib_dep.name()
    glib_suppressions = glib_share + '/valgrind/glib.supp'
    python_suppressions = '@0@/@1@'.format(meson.source_root(),
        files('valgrind-python.supp')[0])
    add_test_setup('valgrind',
        timeout_multiplier: 10,
        env: [
            'G_SLICE=always-malloc',
            ('LIBFPRINT_TEST_WRAPPER=@0@ --tool=memcheck --leak-check=full ' +
             '--suppressions=@1@ --suppressions=@2@').format(
                valgrind.path(), glib_suppressions, python_suppressions)
        ])
endif