2019-07-03 21:39:08 +00:00
|
|
|
envs = environment()
|
2019-08-12 14:30:40 +00:00
|
|
|
# Enable debug messages and abort on warnings
|
2019-07-03 21:39:08 +00:00
|
|
|
envs.set('G_DEBUG', 'fatal-warnings')
|
|
|
|
envs.set('G_MESSAGES_DEBUG', 'all')
|
2019-08-12 14:30:40 +00:00
|
|
|
|
|
|
|
# Setup paths
|
2019-12-09 10:51:12 +00:00
|
|
|
envs.set('MESON_SOURCE_ROOT', meson.source_root())
|
2021-01-20 19:02:05 +00:00
|
|
|
envs.set('MESON_BUILD_ROOT', meson.build_root())
|
2019-07-03 21:39:08 +00:00
|
|
|
envs.prepend('LD_LIBRARY_PATH', join_paths(meson.build_root(), 'libfprint'))
|
2019-08-12 14:30:40 +00:00
|
|
|
|
|
|
|
# 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')
|
|
|
|
|
2019-12-13 19:34:08 +00:00
|
|
|
# Set a colon-separated list of native drivers we enable in tests
|
2021-01-05 14:59:07 +00:00
|
|
|
envs.set('FP_DRIVERS_WHITELIST', ':'.join([
|
|
|
|
'virtual_image',
|
|
|
|
'virtual_device',
|
|
|
|
'virtual_device_storage',
|
|
|
|
]))
|
2019-12-13 19:34:08 +00:00
|
|
|
|
2019-07-03 21:39:08 +00:00
|
|
|
envs.set('NO_AT_BRIDGE', '1')
|
|
|
|
|
2020-01-08 17:40:41 +00:00
|
|
|
drivers_tests = [
|
2020-09-29 08:35:48 +00:00
|
|
|
'aes3500',
|
2020-01-08 17:40:41 +00:00
|
|
|
'elan',
|
2021-06-21 19:28:21 +00:00
|
|
|
'elanspi',
|
2020-01-08 17:40:41 +00:00
|
|
|
'synaptics',
|
2020-05-13 15:30:43 +00:00
|
|
|
'vfs0050',
|
2020-11-05 14:55:09 +00:00
|
|
|
'vfs301',
|
2020-05-13 15:30:43 +00:00
|
|
|
'vfs5011',
|
2021-03-01 14:32:47 +00:00
|
|
|
'vfs7552',
|
2020-06-08 14:17:32 +00:00
|
|
|
'goodixmoc',
|
2021-04-04 23:19:46 +00:00
|
|
|
'nb1010',
|
2020-01-08 17:40:41 +00:00
|
|
|
]
|
|
|
|
|
2019-11-18 20:17:43 +00:00
|
|
|
if get_option('introspection')
|
2019-12-05 13:39:45 +00:00
|
|
|
envs.prepend('GI_TYPELIB_PATH', join_paths(meson.build_root(), 'libfprint'))
|
2021-01-05 15:23:18 +00:00
|
|
|
virtual_devices_tests = [
|
|
|
|
'virtual-image',
|
|
|
|
'virtual-device',
|
|
|
|
]
|
2019-12-05 13:39:45 +00:00
|
|
|
|
2021-01-05 15:23:18 +00:00
|
|
|
unittest_inspector = find_program('unittest_inspector.py')
|
2020-02-08 11:57:07 +00:00
|
|
|
|
2021-01-05 15:23:18 +00:00
|
|
|
foreach vdtest: virtual_devices_tests
|
|
|
|
driver_name = '_'.join(vdtest.split('-'))
|
|
|
|
if driver_name in drivers
|
|
|
|
python3 = find_program('python3')
|
|
|
|
base_args = files(vdtest + '.py')
|
|
|
|
suite = ['virtual-driver']
|
2020-02-08 11:57:07 +00:00
|
|
|
|
2021-01-05 15:23:18 +00:00
|
|
|
r = run_command(unittest_inspector, files(vdtest + '.py'))
|
|
|
|
unit_tests = r.stdout().strip().split('\n')
|
2020-02-08 11:57:07 +00:00
|
|
|
|
2021-01-05 15:23:18 +00:00
|
|
|
if r.returncode() == 0 and unit_tests.length() > 0
|
|
|
|
suite += vdtest
|
|
|
|
else
|
|
|
|
unit_tests = [vdtest]
|
2020-02-08 11:57:07 +00:00
|
|
|
endif
|
2021-01-05 15:23:18 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
else
|
|
|
|
test(vdtest,
|
|
|
|
find_program('sh'),
|
|
|
|
args: ['-c', 'exit 77']
|
2020-02-08 11:57:07 +00:00
|
|
|
)
|
2021-01-05 15:23:18 +00:00
|
|
|
endif
|
|
|
|
endforeach
|
2019-07-03 21:39:08 +00:00
|
|
|
|
2019-11-26 19:59:09 +00:00
|
|
|
foreach driver_test: drivers_tests
|
2020-12-04 15:40:18 +00:00
|
|
|
if driver_test.contains('-')
|
|
|
|
driver_name = driver_test.split('-')[0]
|
|
|
|
else
|
|
|
|
driver_name = driver_test
|
|
|
|
endif
|
2019-12-13 19:34:08 +00:00
|
|
|
driver_envs = envs
|
2020-12-04 15:40:18 +00:00
|
|
|
driver_envs.set('FP_DRIVERS_WHITELIST', driver_name)
|
2019-12-13 19:34:08 +00:00
|
|
|
|
2020-12-04 15:40:18 +00:00
|
|
|
if (driver_name in supported_drivers and
|
2020-12-10 19:22:54 +00:00
|
|
|
gusb_dep.version().version_compare('>= 0.3.0'))
|
2020-01-08 17:40:41 +00:00
|
|
|
test(driver_test,
|
|
|
|
find_program('umockdev-test.py'),
|
|
|
|
args: join_paths(meson.current_source_dir(), driver_test),
|
|
|
|
env: driver_envs,
|
|
|
|
suite: ['drivers'],
|
2021-06-25 08:32:14 +00:00
|
|
|
timeout: 15,
|
2020-01-08 17:40:41 +00:00
|
|
|
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
|
2019-11-26 19:59:09 +00:00
|
|
|
test(driver_test,
|
2020-01-08 17:40:41 +00:00
|
|
|
find_program('sh'),
|
|
|
|
args: ['-c', 'exit 77']
|
2019-11-18 20:17:43 +00:00
|
|
|
)
|
2019-11-26 19:59:09 +00:00
|
|
|
endforeach
|
2019-11-18 20:17:43 +00:00
|
|
|
endif
|
2019-11-26 17:45:31 +00:00
|
|
|
|
2019-12-11 20:09:02 +00:00
|
|
|
test_utils = static_library('fprint-test-utils',
|
|
|
|
sources: [
|
|
|
|
'test-utils.c',
|
|
|
|
'test-device-fake.c',
|
|
|
|
],
|
|
|
|
dependencies: libfprint_private_dep,
|
|
|
|
install: false)
|
|
|
|
|
2019-12-06 16:21:38 +00:00
|
|
|
unit_tests = [
|
|
|
|
'fpi-device',
|
2019-12-12 17:42:46 +00:00
|
|
|
'fpi-ssm',
|
2019-12-09 10:52:05 +00:00
|
|
|
'fpi-assembling',
|
2019-12-06 16:21:38 +00:00
|
|
|
]
|
2019-12-05 13:38:41 +00:00
|
|
|
|
2019-12-11 20:09:02 +00:00
|
|
|
if 'virtual_image' in drivers
|
|
|
|
unit_tests += [
|
2019-12-05 13:38:41 +00:00
|
|
|
'fp-context',
|
2019-12-05 16:05:21 +00:00
|
|
|
'fp-device',
|
2019-12-05 13:38:41 +00:00
|
|
|
]
|
|
|
|
endif
|
|
|
|
|
2019-12-09 10:52:05 +00:00
|
|
|
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)
|
|
|
|
|
2019-12-11 20:09:02 +00:00
|
|
|
foreach test_name: unit_tests
|
2019-12-09 10:52:05 +00:00
|
|
|
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
|
|
|
|
|
2019-12-11 20:09:02 +00:00
|
|
|
basename = 'test-' + test_name
|
|
|
|
test_exe = executable(basename,
|
2019-12-09 10:52:05 +00:00
|
|
|
sources: [basename + '.c', test_config_h],
|
|
|
|
dependencies: [ libfprint_private_dep ] + extra_deps,
|
2019-12-11 20:09:02 +00:00
|
|
|
c_args: common_cflags,
|
|
|
|
link_with: test_utils,
|
|
|
|
)
|
|
|
|
test(test_name,
|
2021-04-13 15:04:01 +00:00
|
|
|
test_exe,
|
2019-12-11 20:09:02 +00:00
|
|
|
suite: ['unit-tests'],
|
|
|
|
env: envs,
|
|
|
|
)
|
|
|
|
endforeach
|
|
|
|
|
2021-01-19 12:38:08 +00:00
|
|
|
# Run udev rule generator with fatal warnings
|
2021-01-20 19:02:05 +00:00
|
|
|
envs.set('UDEV_HWDB', udev_hwdb.full_path())
|
|
|
|
envs.set('UDEV_HWDB_CHECK_CONTENTS', default_drivers_are_enabled ? '1' : '0')
|
2021-01-19 13:13:03 +00:00
|
|
|
test('udev-hwdb',
|
2021-01-20 19:02:05 +00:00
|
|
|
find_program('test-generated-hwdb.sh'),
|
2021-01-19 12:38:08 +00:00
|
|
|
env: envs)
|
|
|
|
|
2019-11-26 17:45:31 +00:00
|
|
|
gdb = find_program('gdb', required: false)
|
|
|
|
if gdb.found()
|
2021-04-13 15:04:01 +00:00
|
|
|
libfprint_wrapper = [
|
|
|
|
gdb.path(),
|
|
|
|
'-batch',
|
|
|
|
'-ex', 'run',
|
|
|
|
'--args',
|
|
|
|
]
|
2019-11-26 17:45:31 +00:00
|
|
|
add_test_setup('gdb',
|
|
|
|
timeout_multiplier: 1000,
|
2021-04-13 15:04:01 +00:00
|
|
|
exe_wrapper: libfprint_wrapper,
|
2019-11-26 17:45:31 +00:00
|
|
|
env: [
|
2021-04-13 15:04:01 +00:00
|
|
|
'LIBFPRINT_TEST_WRAPPER=' + ' '.join(libfprint_wrapper),
|
2019-11-26 17:45:31 +00:00
|
|
|
])
|
|
|
|
endif
|
2019-11-26 17:50:18 +00:00
|
|
|
|
|
|
|
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])
|
2021-04-13 15:04:01 +00:00
|
|
|
libfprint_wrapper = [
|
|
|
|
valgrind.path(),
|
|
|
|
'--tool=memcheck',
|
|
|
|
'--leak-check=full',
|
|
|
|
'--suppressions=' + glib_suppressions,
|
|
|
|
'--suppressions=' + python_suppressions,
|
|
|
|
]
|
2019-11-26 17:50:18 +00:00
|
|
|
add_test_setup('valgrind',
|
|
|
|
timeout_multiplier: 10,
|
2021-04-13 15:04:01 +00:00
|
|
|
exe_wrapper: libfprint_wrapper,
|
2019-11-26 17:50:18 +00:00
|
|
|
env: [
|
|
|
|
'G_SLICE=always-malloc',
|
2021-01-26 04:17:48 +00:00
|
|
|
'UNDER_VALGRIND=1',
|
2021-04-13 15:04:01 +00:00
|
|
|
'LIBFPRINT_TEST_WRAPPER=' + ' '.join(libfprint_wrapper),
|
2019-11-26 17:50:18 +00:00
|
|
|
])
|
|
|
|
endif
|