mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
tests: Add support for installed tests
They allow distrubtions to check whether libfprint continues working as expected, in different contexts.
This commit is contained in:
@@ -21,3 +21,8 @@ executable('cpp-test',
|
||||
'cpp-test.cpp',
|
||||
dependencies: libfprint_dep,
|
||||
)
|
||||
|
||||
if installed_tests
|
||||
install_subdir('prints',
|
||||
install_dir: installed_tests_testdir)
|
||||
endif
|
||||
|
||||
@@ -13,6 +13,11 @@ gnome = import('gnome')
|
||||
libfprint_conf = configuration_data()
|
||||
libfprint_conf.set_quoted('LIBFPRINT_VERSION', meson.project_version())
|
||||
|
||||
prefix = get_option('prefix')
|
||||
libdir = prefix / get_option('libdir')
|
||||
libexecdir = prefix / get_option('libexecdir')
|
||||
datadir = prefix / get_option('datadir')
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
cpp = meson.get_compiler('cpp')
|
||||
host_system = host_machine.system()
|
||||
@@ -297,7 +302,6 @@ subdir('libfprint')
|
||||
|
||||
configure_file(output: 'config.h', configuration: libfprint_conf)
|
||||
|
||||
subdir('examples')
|
||||
if get_option('doc')
|
||||
subdir('doc')
|
||||
endif
|
||||
@@ -308,6 +312,8 @@ endif
|
||||
subdir('data')
|
||||
subdir('tests')
|
||||
|
||||
subdir('examples')
|
||||
|
||||
pkgconfig = import('pkgconfig')
|
||||
pkgconfig.generate(
|
||||
name: versioned_libname,
|
||||
|
||||
@@ -30,3 +30,7 @@ option('doc',
|
||||
description: 'Whether to build the API documentation',
|
||||
type: 'boolean',
|
||||
value: true)
|
||||
option('installed-tests',
|
||||
description: 'Whether to install the installed tests',
|
||||
type: 'boolean',
|
||||
value: true)
|
||||
|
||||
5
tests/driver.test.in
Normal file
5
tests/driver.test.in
Normal file
@@ -0,0 +1,5 @@
|
||||
[Test]
|
||||
Type=session
|
||||
# We can't use TestEnvironment as per
|
||||
# https://gitlab.gnome.org/GNOME/gnome-desktop-testing/-/issues/1
|
||||
Exec=env @driver_env@ @installed_tests_execdir@/@umockdev_test_name@ @installed_tests_testdir@/@driver_test@
|
||||
@@ -23,6 +23,13 @@ envs.set('FP_PRINTS_PATH', meson.project_source_root() / 'examples' / 'prints')
|
||||
|
||||
envs.set('NO_AT_BRIDGE', '1')
|
||||
|
||||
python3 = find_program('python3')
|
||||
|
||||
installed_tests = get_option('installed-tests')
|
||||
installed_tests_execdir = libexecdir / 'installed-tests' / versioned_libname
|
||||
installed_tests_testdir = datadir / 'installed-tests' / versioned_libname
|
||||
installed_tests_libdir = libdir
|
||||
|
||||
drivers_tests = [
|
||||
'aes2501',
|
||||
'aes3500',
|
||||
@@ -54,6 +61,16 @@ if get_option('introspection')
|
||||
output: 'create-driver-test.py')
|
||||
endif
|
||||
|
||||
env_parser_cmd = '''
|
||||
import os;
|
||||
print(" ".join([f"{k}={v}" for k, v in os.environ.items()
|
||||
if k.startswith("FP_") or k.startswith("G_")]))
|
||||
'''
|
||||
|
||||
envs_str = run_command(python3, '-c', env_parser_cmd,
|
||||
env: envs,
|
||||
check: installed_tests).stdout().strip()
|
||||
|
||||
if get_option('introspection')
|
||||
envs.prepend('GI_TYPELIB_PATH', meson.project_build_root() / 'libfprint')
|
||||
virtual_devices_tests = [
|
||||
@@ -61,9 +78,9 @@ if get_option('introspection')
|
||||
'virtual-device',
|
||||
]
|
||||
|
||||
python3 = find_program('python3')
|
||||
unittest_inspector = find_program('unittest_inspector.py')
|
||||
umockdev_test = find_program('umockdev-test.py')
|
||||
umockdev_test_name = 'umockdev-test.py'
|
||||
umockdev_test = find_program(umockdev_test_name)
|
||||
|
||||
foreach vdtest: virtual_devices_tests
|
||||
driver_name = '_'.join(vdtest.split('-'))
|
||||
@@ -95,6 +112,31 @@ if get_option('introspection')
|
||||
env: envs,
|
||||
)
|
||||
endforeach
|
||||
|
||||
if installed_tests
|
||||
install_data(base_args,
|
||||
install_dir: installed_tests_execdir,
|
||||
install_mode: 'rwxr-xr-x',
|
||||
)
|
||||
|
||||
configure_file(
|
||||
input: 'test.in',
|
||||
output: vdtest + '.test',
|
||||
install_dir: installed_tests_testdir,
|
||||
configuration: {
|
||||
# FIXME: use fs.name() on meson 0.58
|
||||
'exec': installed_tests_execdir / '@0@'.format(base_args[0]).split('/')[-1],
|
||||
'env': ' '.join([
|
||||
envs_str,
|
||||
'LD_LIBRARY_PATH=' + installed_tests_libdir,
|
||||
'FP_PRINTS_PATH=' + installed_tests_testdir / 'prints',
|
||||
# FIXME: Adding this requires gnome-desktop-testing!12
|
||||
# 'GI_TYPELIB_PATH=' + installed_tests_libdir / 'girepository-1.0',
|
||||
]),
|
||||
'extra_content': '',
|
||||
},
|
||||
)
|
||||
endif
|
||||
else
|
||||
test(vdtest,
|
||||
find_program('sh'),
|
||||
@@ -103,6 +145,7 @@ if get_option('introspection')
|
||||
endif
|
||||
endforeach
|
||||
|
||||
driver_tests_enabled = false
|
||||
foreach driver_test: drivers_tests
|
||||
driver_name = driver_test.split('-')[0]
|
||||
driver_envs = envs
|
||||
@@ -110,6 +153,7 @@ if get_option('introspection')
|
||||
|
||||
if (driver_name in supported_drivers and
|
||||
gusb_dep.version().version_compare('>= 0.3.0'))
|
||||
driver_tests_enabled = true
|
||||
test(driver_test,
|
||||
python3,
|
||||
args: [
|
||||
@@ -121,6 +165,32 @@ if get_option('introspection')
|
||||
timeout: 15,
|
||||
depends: libfprint_typelib,
|
||||
)
|
||||
|
||||
if installed_tests
|
||||
driver_envs_str = run_command(python3, '-c', env_parser_cmd,
|
||||
env: driver_envs,
|
||||
check: true).stdout().strip()
|
||||
|
||||
configure_file(
|
||||
input: 'driver.test.in',
|
||||
output: 'driver-' + driver_test + '.test',
|
||||
install_dir: installed_tests_testdir,
|
||||
configuration: {
|
||||
'installed_tests_execdir': installed_tests_execdir,
|
||||
'installed_tests_testdir': installed_tests_testdir,
|
||||
'umockdev_test_name': umockdev_test_name,
|
||||
'driver_test': driver_test,
|
||||
'driver_env': ' '.join([
|
||||
driver_envs_str,
|
||||
'LD_LIBRARY_PATH=' + installed_tests_libdir,
|
||||
# FIXME: Adding this requires gnome-desktop-testing!12
|
||||
# 'GI_TYPELIB_PATH=' + installed_tests_libdir / 'girepository-1.0',
|
||||
]),
|
||||
},
|
||||
)
|
||||
|
||||
install_subdir(driver_test, install_dir: installed_tests_testdir)
|
||||
endif
|
||||
else
|
||||
test(driver_test,
|
||||
find_program('sh'),
|
||||
@@ -128,6 +198,17 @@ if get_option('introspection')
|
||||
)
|
||||
endif
|
||||
endforeach
|
||||
|
||||
if installed_tests and driver_tests_enabled
|
||||
install_data(umockdev_test.full_path(),
|
||||
install_dir: installed_tests_execdir,
|
||||
install_mode: 'rwxr-xr-x',
|
||||
)
|
||||
install_data('capture.py',
|
||||
install_dir: installed_tests_execdir,
|
||||
install_mode: 'rwxr-xr-x',
|
||||
)
|
||||
endif
|
||||
else
|
||||
warning('Skipping all driver tests as introspection bindings are missing')
|
||||
test('virtual-image',
|
||||
@@ -200,13 +281,28 @@ foreach test_name: unit_tests
|
||||
sources: [basename + '.c', test_config_h],
|
||||
dependencies: [ libfprint_private_dep ] + extra_deps,
|
||||
c_args: common_cflags,
|
||||
link_with: test_utils,
|
||||
link_whole: test_utils,
|
||||
install: installed_tests,
|
||||
install_dir: installed_tests_execdir,
|
||||
)
|
||||
test(test_name,
|
||||
test_exe,
|
||||
suite: ['unit-tests'],
|
||||
env: envs,
|
||||
)
|
||||
|
||||
configure_file(
|
||||
input: 'test.in',
|
||||
output: test_name + '.test',
|
||||
install: installed_tests,
|
||||
install_dir: installed_tests_testdir,
|
||||
configuration: {
|
||||
'exec': installed_tests_execdir / basename,
|
||||
'env': envs_str,
|
||||
'extra_content': 'TestEnvironment=LD_LIBRARY_PATH=' +
|
||||
installed_tests_libdir,
|
||||
},
|
||||
)
|
||||
endforeach
|
||||
|
||||
# Run udev rule generator with fatal warnings
|
||||
|
||||
6
tests/test.in
Normal file
6
tests/test.in
Normal file
@@ -0,0 +1,6 @@
|
||||
[Test]
|
||||
Type=session
|
||||
# We can't use TestEnvironment as per
|
||||
# https://gitlab.gnome.org/GNOME/gnome-desktop-testing/-/issues/1
|
||||
Exec=env @env@ @exec@
|
||||
@extra_content@
|
||||
Reference in New Issue
Block a user