Compare commits

..

50 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
135a015b6a Release 1.94.6 2023-08-17 05:08:04 +02:00
swbgdx
96645eaa7a goodixmoc: Add PID 0x633C and 0x6304 2023-08-17 01:37:56 +00:00
hermanlin
d37b255a11 elanmoc: add PID 0x0C99 2023-07-10 11:17:27 +08:00
Marco Trevisan (Treviño)
903ee43b2d ci: Do not force-rebuild if an image with such tag exists 2023-06-28 16:35:16 +02:00
Marco Trevisan (Treviño)
8562f8a964 ci: Use meson commands only to setup, compile and install
Old ones are semi-deprecated, so let's adjust to what upstream suggests
2023-06-28 16:35:16 +02:00
Marco Trevisan (Treviño)
5ff794c105 ci: Run installed tests 2023-06-28 16:35:16 +02:00
Marco Trevisan (Treviño)
f68e0972c2 ci: Auto-Retry jobs on infrastructure failures 2023-06-28 16:35:16 +02:00
Marco Trevisan (Treviño)
ba3cc04e84 tests: Add support for installed tests
They allow distrubtions to check whether libfprint continues working as
expected, in different contexts.
2023-06-28 16:35:16 +02:00
Marco Trevisan (Treviño)
3d4cf44f9b ci: Add gnome-desktop-testing to the image
It can be used to run the installed tests.
2023-06-28 16:23:45 +02:00
Marco Trevisan (Treviño)
8e702012fd ci: Use debuginfo-install to install debug symbols
dnf doesn't seem to handle the plugin well in rawhide:

  bash-5.2# dnf -y debuginfo-install glib2
    Unknown argument "debuginfo-install" for command "dnf5".
    Add "--help" for more information about the arguments.
2023-06-28 15:58:48 +02:00
Marco Trevisan (Treviño)
f49879b522 tests/virtual-image: Support passing specific FP_PRINTS_PATH env variable 2023-06-24 00:28:04 +02:00
Marco Trevisan (Treviño)
5e0bf2446b meson: Bump requirements to 0.56 and adapt deprecated functions 2023-06-24 00:28:04 +02:00
Marco Trevisan (Treviño)
4d96a3efaa tests/virtual-device: Check that removed devices are not in context anymore 2023-06-23 18:20:04 +02:00
Marco Trevisan (Treviño)
c27d72e3a1 tests/virtual-device: Do not preserve context on unplug tests
The unplug tests assume that the device is removed from the context once
they run, however we may have left the device around in a removed state
causing other tests to fail.

So isolate them in a new class where we create context and device
instances every time we run a test case.
2023-06-22 06:59:00 +02:00
Marco Trevisan (Treviño)
0819df6988 virtual-device: Reset transient parameters on deinit
Tests may change some options so we need to reset these values, even
though some may need not to be reserved when not in keep-alive mode.
2023-06-22 06:55:44 +02:00
Marco Trevisan (Treviño)
28579239a6 tests/virtual-device: Reset keep alive status when test is done
We don't want this to be preserved across tests, since it's meant to be
used inside a single test case.
2023-06-22 06:55:44 +02:00
Marco Trevisan (Treviño)
e48d2b467a tests/virtual-device: Restore default enroll steps on tearDown
When running the tests as a single script we may leave the device in an
inconsistent state, so reset the enroll steps when done.
2023-06-22 06:55:44 +02:00
Marco Trevisan (Treviño)
1c589336a2 meson: Remove duplicate gnome imports 2023-06-22 06:55:44 +02:00
Egor Ignatov
9546659c15 goodixmoc: add PID 0x60A4
Signed-off-by: Egor Ignatov <egori@altlinux.org>
2023-06-21 19:28:38 +03:00
haoweilo
c782298ae4 fpcmoc: Ensure the current SSM is never overwritten 2023-06-21 15:09:00 +00:00
Elytscha Smith
682fce6a5b goodixmoc: add PID 0x60BC 2023-03-28 15:59:48 +00:00
swbgdx
6ed1b707d5 goodixmoc: Add PID 0x6092 2023-03-15 15:45:56 +00:00
Marco Trevisan (Treviño)
9fd2ccff29 virtual-device-listener: Always return task even if we got zero bytes
See: https://gitlab.gnome.org/GNOME/glib/-/issues/1346
2023-03-15 15:26:37 +00:00
Marco Trevisan (Treviño)
b6223a9d0a test-fpi-device: Only push pragma -wdanging-pointer in newer GCC versions
It may not be supported and warn otherwise
2023-03-15 15:23:17 +00:00
Marco Trevisan (Treviño)
5e98f10011 ci: Do not require coverage to always happen
meson coverage could be broken in some cases, so let's ignore the error
for now if it happens.
2023-03-15 16:18:17 +01:00
Marco Trevisan (Treviño)
e7ca05e1bf ci: Use proper name for valgrind junit file 2023-03-15 16:18:17 +01:00
Marco Trevisan (Treviño)
677c50fc51 fprint-list-supported-devices: Do not double-free usb_list
We were leaking the spi_list instead.
2023-03-15 14:50:41 +01:00
Bastien Nocera
bb5feeca77 ci: Use detached pipelines
See https://gitlab.freedesktop.org/freedesktop/freedesktop/-/issues/438#what-it-means-for-me-a-maintainer-of-a-project-part-of-gitlabfreedesktoporg
2023-03-15 13:33:52 +01:00
wagner.oliveira
22683ec490 Fix AES4000 wrong IDs (swapped pid/vid) 2023-01-27 18:23:55 -05:00
Enrik Berkhan
0bf7d58c5e goodixmoc: cleanup enroll state machine
As suggested by @benzea, the following cleanup actions have been
performed:

  - let case order match enroll states enum

  - remove FP_ENROLL_IDENTIFY that is no longer used

  - finally use fpi_ssm_next_state instead of explicitly jumping to
    FP_ENROLL_CREATE

Additionally, all types/functions/variables referring to "enroll_init"
used for FP_ENROLL_CREATE have been renamed to match "enroll_create".
All other states use similar name matching.

Signed-off-by: Enrik Berkhan <Enrik.Berkhan@inka.de>
2023-01-19 20:30:05 +01:00
Enrik Berkhan
86566e8d0b goodixmoc: Fix missing "enroll create" state
After the driver internal duplicate check had been removed in
46669e9f53, all templates were saved with
an all-zeroes template ID.

By going through FP_ENROLL_CREATE before starting to capture, the
template ID returned from the device is taken into account again.

Signed-off-by: Enrik Berkhan <Enrik.Berkhan@inka.de>
2023-01-19 20:28:33 +01:00
Zoltán Böszörményi
7080a5ff8b Abort initialization if unknown sensor dimensions are reported
Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
2023-01-17 19:50:21 +00:00
Zoltán Böszörményi
5e52ad2ad1 upektc_img: Add new unit test for the TCS1s chip variant 2023-01-17 19:50:21 +00:00
Zoltán Böszörményi
bfaa9a9241 upektc_img: Fix asynchronous problem in init_read_data_cb() 2023-01-17 19:50:21 +00:00
Zoltán Böszörményi
9c900789de upektc_img: Add asserts for expected height reported by the device 2023-01-17 19:50:21 +00:00
Zoltán Böszörményi
29a24ba67f upektc_img: Add finger status changes 2023-01-17 19:50:21 +00:00
Zoltán Böszörményi
987f23698e upektc_img: Deduce sensor type from the information packet 2023-01-17 19:50:21 +00:00
Toni
cda4e6136c upektc_img: Fix protocol for area sensors 2023-01-17 19:50:21 +00:00
Toni
522b481297 upektc_img: Add sensor chip detection
Move setting up sensor type and image dimensions to
activation time.
2023-01-17 19:50:21 +00:00
Toni
fafe70f985 upektc_img: Fix CRC for upek2020_init_capture. 2023-01-17 19:50:21 +00:00
Vasily Khoruzhick
62818b9407 fpcmoc: fix use-after free in multiple callbacks
Drop if statement that retrieves internal ssm->error.
"error" is already a copied ssm->error, so it makes no sense to return
internal copy which will be freed when ssm is marked as done.

Fixes #526
2023-01-10 11:22:22 -08:00
Vasily Khoruzhick
db2fa81358 tests: valgrind: update python and libfprint suppressions list 2023-01-10 11:15:17 -08:00
Vasily Khoruzhick
d492901c3e tests: valgrind: generate suppressions list for new tests-suppress-new-valgrind-errors-in-python
That will help with updating suppresions lists in future
2023-01-10 11:14:51 -08:00
Vasily Khoruzhick
a5d52eb853 Fix indentation issues with uncrustify-0.76.0
Apparently older version didn't find this indentation issues
2023-01-08 23:36:18 -08:00
Bastien Nocera
89509c76f4 build: Print the list of enabled drivers
This saves us from having to figure out which drivers were enabled
during a build in some other way.
2022-11-02 12:04:34 +01:00
Marco Trevisan (Treviño)
6395dda012 fp-image: Remove config.h inclusion in fpi-header
And also avoid defining a function we expose depending on it's presency.
2022-10-13 20:35:52 +00:00
Marco Trevisan (Treviño)
54bb0c12e6 fpi-image: Check for PIXMAN presency using #ifdef
That's a defined variable that may be there or not, and currently we
warn with:
 - fpi-image.c:29:5: warning: "HAVE_PIXMAN" is not defined, evaluates to 0
2022-10-13 20:35:52 +00:00
Marco Trevisan (Treviño)
1f1ed80dbf test-device-fake: Add more logging showing the current device action 2022-10-13 20:31:28 +00:00
Marco Trevisan (Treviño)
36bcb24b3a fp-device: Move FpDevice private functions to public library
This these functions are not really needed by anything else than
FpDevice, so move them back to the cpp file, so that we don't expose
them in the private library, given that we don't need them
2022-10-13 20:31:28 +00:00
Marco Trevisan (Treviño)
ddacf07e3b meson: Actually bump the version to 1.94.5 2022-10-13 20:31:28 +00:00
52 changed files with 1135 additions and 388 deletions

View File

@@ -6,6 +6,16 @@ include:
file: '/templates/fedora.yml'
- remote: 'https://gitlab.gnome.org/GNOME/citemplates/-/raw/master/flatpak/flatpak_ci_initiative.yml'
default:
# Auto-retry jobs in case of infra failures
retry:
max: 1
when:
- 'runner_system_failure'
- 'stuck_or_timeout_failure'
- 'scheduler_failure'
- 'api_failure'
variables:
extends: .libfprint_common_variables
FDO_DISTRIBUTION_TAG: $LIBFPRINT_IMAGE_TAG
@@ -15,6 +25,11 @@ variables:
BUNDLE: "org.freedesktop.libfprint.Demo.flatpak"
LAST_ABI_BREAK: "056ea541ddc97f5806cffbd99a12dc87e4da3546"
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'
stages:
- image-build
- check-source
@@ -27,16 +42,16 @@ image: $FEDORA_IMAGE
.build_one_driver_template: &build_one_driver
script:
# Build with a driver that doesn't need imaging, or nss
- meson --werror -Ddrivers=$driver . _build
- ninja -C _build
- meson setup _build --werror -Ddrivers=$driver
- meson compile -C _build
- rm -rf _build/
.build_template: &build
script:
# And build with everything
- meson --werror -Ddrivers=all . _build
- ninja -C _build
- ninja -C _build install
- meson setup _build --werror -Ddrivers=all
- meson compile -C _build
- meson install -C _build
.build_template: &check_abi
script:
@@ -65,11 +80,10 @@ test:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
script:
- meson --werror -Ddrivers=all -Db_coverage=true . _build
- ninja -C _build
- meson setup _build --werror -Ddrivers=all -Db_coverage=true
- meson test -C _build --print-errorlogs --no-stdsplit --timeout-multiplier 3
- ninja -C _build coverage
- cat _build/meson-logs/coverage.txt
- cat _build/meson-logs/coverage.txt || true
artifacts:
reports:
junit: "_build/meson-logs/testlog.junit.xml"
@@ -90,12 +104,12 @@ test_valgrind:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
script:
- meson -Ddrivers=all . _build
- ninja -C _build
- meson setup _build -Ddrivers=all
- meson compile -C _build
- meson test -C _build --print-errorlogs --no-stdsplit --setup=valgrind
artifacts:
reports:
junit: "_build/meson-logs/testlog.junit.xml"
junit: "_build/meson-logs/testlog-valgrind.junit.xml"
expose_as: 'Valgrind test logs'
when: always
paths:
@@ -103,6 +117,27 @@ test_valgrind:
- _build/meson-logs/testlog-valgrind.txt
expire_in: 1 week
test_installed:
stage: test
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
script:
- meson setup _build --prefix=/usr -Ddrivers=all
- meson install -C _build
- gnome-desktop-testing-runner --list libfprint-2
- gnome-desktop-testing-runner libfprint-2
--report-directory=_build/installed-tests-report/failed/
--log-directory=_build/installed-tests-report/logs/
--parallel=0
artifacts:
expose_as: 'GNOME Tests Runner logs'
when: always
paths:
- _build/meson-logs
- _build/installed-tests-report
expire_in: 1 week
test_scan_build:
stage: test
@@ -111,9 +146,10 @@ test_scan_build:
- $CI_PIPELINE_SOURCE == "schedule"
allow_failure: true
script:
- meson -Ddrivers=all . _build
- meson setup _build -Ddrivers=all
# Wrapper to add --status-bugs and disable malloc checker
- SCANBUILD=$CI_PROJECT_DIR/.gitlab-ci/scan-build ninja -C _build scan-build
- SCANBUILD=$CI_PROJECT_DIR/.gitlab-ci/scan-build
ninja -C _build scan-build
artifacts:
paths:
- _build/meson-logs
@@ -171,7 +207,6 @@ flatpak:
- $CI_PIPELINE_SOURCE == "never"
variables:
GIT_STRATEGY: none # no need to pull the whole tree for rebuilding the image
FDO_FORCE_REBUILD: 1
# a list of packages to install
FDO_DISTRIBUTION_PACKAGES:
$LIBFPRINT_DEPENDENCIES
@@ -181,14 +216,22 @@ flatpak:
FDO_DISTRIBUTION_EXEC: |
$LIBFPRINT_EXEC
.container_fedora_build_forced:
variables:
FDO_FORCE_REBUILD: 1
container_fedora_build_schedule:
extends: .container_fedora_build_base
extends:
- .container_fedora_build_base
- .container_fedora_build_forced
only:
variables:
- $CI_PIPELINE_SOURCE == "schedule" && $CRON_TASK == "BUILD_CI_IMAGES"
container_fedora_build_manual:
extends: .container_fedora_build_base
extends:
- .container_fedora_build_base
- .container_fedora_build_forced
only:
variables:
- $LIBFPRINT_CI_ACTION == "build-image"

View File

@@ -1,2 +1,2 @@
variables:
LIBFPRINT_IMAGE_TAG: v2
LIBFPRINT_IMAGE_TAG: v3

View File

@@ -13,6 +13,7 @@
glib2-devel
glibc-devel
gobject-introspection-devel
gnome-desktop-testing
gtk-doc
gtk3-devel
libabigail
@@ -33,7 +34,8 @@
diffutils
LIBFPRINT_EXEC: |
dnf debuginfo-install -y \
dnf -y install dnf-utils
debuginfo-install -y \
glib2 \
glibc \
libgusb \

15
NEWS
View File

@@ -1,6 +1,21 @@
This file lists notable changes in each release. For the full history of all
changes, see ChangeLog.
2023-08-17: v1.94.6 release
Highlights:
* goodixmoc: New PIDs 0x60A4, 0x60BC, 0x6092, 0x633C and 0x6304.
* goodixmoc: Fix missing "enroll create" state.
* elanmoc: New PID 0x0C99.
* upektc: Improve compatibility with sensors 147e:2016.
* aes4000: Actually support 08FF:5501 devices.
* virtual-device-listener: Fix failing tests with GLib 2.76
* tests: Add installed tests
Bugs fixed:
* #526 libfprint: fpcmoc: use after free if enrollment or identification is
cancelled (Vasily Khoruzhick)
2022-10-13: v1.94.5 release
Highlights:

View File

@@ -67,7 +67,7 @@ usb:v08FFp5731*
ID_PERSIST=0
# Supported by libfprint driver aes4000
usb:v5501p08FF*
usb:v08FFp5501*
ID_AUTOSUSPEND=1
ID_PERSIST=0
@@ -149,6 +149,7 @@ usb:v04F3p0C82*
usb:v04F3p0C88*
usb:v04F3p0C8C*
usb:v04F3p0C8D*
usb:v04F3p0C99*
ID_AUTOSUSPEND=1
ID_PERSIST=0
@@ -169,10 +170,15 @@ usb:v10A5pD205*
# Supported by libfprint driver goodixmoc
usb:v27C6p5840*
usb:v27C6p6014*
usb:v27C6p6092*
usb:v27C6p6094*
usb:v27C6p609C*
usb:v27C6p60A2*
usb:v27C6p60A4*
usb:v27C6p60BC*
usb:v27C6p6304*
usb:v27C6p631C*
usb:v27C6p633C*
usb:v27C6p634C*
usb:v27C6p6384*
usb:v27C6p639C*

View File

@@ -25,7 +25,7 @@ docpath = join_paths(get_option('datadir'), 'gtk-doc', 'html')
gnome.gtkdoc(versioned_libname,
main_xml: 'libfprint-docs.xml',
src_dir: join_paths(meson.source_root(), 'libfprint'),
src_dir: join_paths(meson.project_source_root(), 'libfprint'),
include_directories: include_directories('../libfprint'),
dependencies: libfprint_dep,
content_files: content_files,

View File

@@ -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

View File

@@ -124,7 +124,7 @@ G_DEFINE_TYPE (FpiDeviceAes4000, fpi_device_aes4000, FPI_TYPE_DEVICE_AES3K);
static const FpIdEntry id_table[] = {
{ .pid = 0x08ff, .vid = 0x5501 },
{ .vid = 0x08ff, .pid = 0x5501 },
{ .vid = 0, .pid = 0, .driver_data = 0 },
};

View File

@@ -31,6 +31,7 @@ static const FpIdEntry id_table[] = {
{ .vid = 0x04f3, .pid = 0x0c88, },
{ .vid = 0x04f3, .pid = 0x0c8c, },
{ .vid = 0x04f3, .pid = 0x0c8d, },
{ .vid = 0x04f3, .pid = 0x0c99, },
{ .vid = 0, .pid = 0, .driver_data = 0 }, /* terminating entry */
};
@@ -1086,6 +1087,10 @@ elanmoc_open (FpDevice *device)
self->max_moc_enroll_time = 11;
break;
case 0x0c99:
self->max_moc_enroll_time = 14;
break;
case 0x0c8d:
self->max_moc_enroll_time = 17;
break;

View File

@@ -132,7 +132,11 @@ fpc_cmd_receive_cb (FpiUsbTransfer *transfer,
}
ssm_state = fpi_ssm_get_cur_state (transfer->ssm);
fp_dbg ("%s current ssm state: %d", G_STRFUNC, ssm_state);
fp_dbg ("%s current ssm request: %d state: %d", G_STRFUNC, data->request, ssm_state);
/* clean cmd_ssm except capture command for suspend/resume case */
if (ssm_state != FP_CMD_SEND || data->request != FPC_CMD_ARM)
self->cmd_ssm = NULL;
if (data->cmdtype == FPC_CMDTYPE_TO_DEVICE)
{
@@ -358,6 +362,7 @@ fpc_sensor_cmd (FpiDeviceFpcMoc *self,
g_clear_object (&self->interrupt_cancellable);
}
g_assert (self->cmd_ssm == NULL);
self->cmd_ssm = fpi_ssm_new (FP_DEVICE (self),
fpc_cmd_run_state,
FP_CMD_NUM_STATES);
@@ -1149,12 +1154,9 @@ fpc_enroll_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
fp_info ("Enrollment complete!");
if (fpi_ssm_get_error (ssm))
error = fpi_ssm_get_error (ssm);
if (error)
{
fpi_device_enroll_complete (dev, NULL, error);
fpi_device_enroll_complete (dev, NULL, g_steal_pointer (&error));
self->task_ssm = NULL;
return;
}
@@ -1336,9 +1338,6 @@ fpc_verify_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
fp_info ("Verify_identify complete!");
if (fpi_ssm_get_error (ssm))
error = fpi_ssm_get_error (ssm);
if (error && error->domain == FP_DEVICE_RETRY)
{
if (fpi_device_get_current_action (dev) == FPI_DEVICE_ACTION_VERIFY)
@@ -1348,9 +1347,9 @@ fpc_verify_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
}
if (fpi_device_get_current_action (dev) == FPI_DEVICE_ACTION_VERIFY)
fpi_device_verify_complete (dev, error);
fpi_device_verify_complete (dev, g_steal_pointer (&error));
else
fpi_device_identify_complete (dev, error);
fpi_device_identify_complete (dev, g_steal_pointer (&error));
self->task_ssm = NULL;
}
@@ -1448,10 +1447,7 @@ fpc_clear_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
fp_info ("Clear Storage complete!");
if (fpi_ssm_get_error (ssm))
error = fpi_ssm_get_error (ssm);
fpi_device_clear_storage_complete (dev, error);
fpi_device_clear_storage_complete (dev, g_steal_pointer (&error));
self->task_ssm = NULL;
}
@@ -1555,10 +1551,7 @@ fpc_init_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpiDeviceFpcMoc *self = FPI_DEVICE_FPCMOC (dev);
if (fpi_ssm_get_error (ssm))
error = fpi_ssm_get_error (ssm);
fpi_device_open_complete (dev, error);
fpi_device_open_complete (dev, g_steal_pointer (&error));
self->task_ssm = NULL;
}

View File

@@ -631,11 +631,11 @@ fp_enroll_enum_cb (FpiDeviceGoodixMoc *self,
return;
}
fpi_ssm_jump_to_state (self->task_ssm, FP_ENROLL_CAPTURE);
fpi_ssm_next_state (self->task_ssm);
}
static void
fp_enroll_init_cb (FpiDeviceGoodixMoc *self,
fp_enroll_create_cb (FpiDeviceGoodixMoc *self,
gxfp_cmd_response_t *resp,
GError *error)
{
@@ -644,7 +644,7 @@ fp_enroll_init_cb (FpiDeviceGoodixMoc *self,
fpi_ssm_mark_failed (self->task_ssm, error);
return;
}
memcpy (self->template_id, resp->enroll_init.tid, TEMPLATE_ID_SIZE);
memcpy (self->template_id, resp->enroll_create.tid, TEMPLATE_ID_SIZE);
fpi_ssm_next_state (self->task_ssm);
}
@@ -837,16 +837,6 @@ fp_enroll_sm_run_state (FpiSsm *ssm, FpDevice *device)
switch (fpi_ssm_get_cur_state (ssm))
{
case FP_ENROLL_ENUM:
{
goodix_sensor_cmd (self, MOC_CMD0_GETFINGERLIST, MOC_CMD1_DEFAULT,
false,
(const guint8 *) &dummy,
1,
fp_enroll_enum_cb);
}
break;
case FP_ENROLL_PWR_BTN_SHIELD_ON:
{
goodix_sensor_cmd (self, MOC_CMD0_PWR_BTN_SHIELD, MOC_CMD1_PWR_BTN_SHIELD_ON,
@@ -857,13 +847,23 @@ fp_enroll_sm_run_state (FpiSsm *ssm, FpDevice *device)
}
break;
case FP_ENROLL_ENUM:
{
goodix_sensor_cmd (self, MOC_CMD0_GETFINGERLIST, MOC_CMD1_DEFAULT,
false,
(const guint8 *) &dummy,
1,
fp_enroll_enum_cb);
}
break;
case FP_ENROLL_CREATE:
{
goodix_sensor_cmd (self, MOC_CMD0_ENROLL_INIT, MOC_CMD1_DEFAULT,
false,
(const guint8 *) &dummy,
1,
fp_enroll_init_cb);
fp_enroll_create_cb);
}
break;
@@ -1359,10 +1359,15 @@ gx_fp_probe (FpDevice *device)
{
case 0x6496:
case 0x60A2:
case 0x60A4:
case 0x6014:
case 0x6092:
case 0x6094:
case 0x609C:
case 0x60BC:
case 0x6304:
case 0x631C:
case 0x633C:
case 0x634C:
case 0x6384:
case 0x639C:
@@ -1602,10 +1607,15 @@ fpi_device_goodixmoc_init (FpiDeviceGoodixMoc *self)
static const FpIdEntry id_table[] = {
{ .vid = 0x27c6, .pid = 0x5840, },
{ .vid = 0x27c6, .pid = 0x6014, },
{ .vid = 0x27c6, .pid = 0x6092, },
{ .vid = 0x27c6, .pid = 0x6094, },
{ .vid = 0x27c6, .pid = 0x609C, },
{ .vid = 0x27c6, .pid = 0x60A2, },
{ .vid = 0x27c6, .pid = 0x60A4, },
{ .vid = 0x27c6, .pid = 0x60BC, },
{ .vid = 0x27c6, .pid = 0x6304, },
{ .vid = 0x27c6, .pid = 0x631C, },
{ .vid = 0x27c6, .pid = 0x633C, },
{ .vid = 0x27c6, .pid = 0x634C, },
{ .vid = 0x27c6, .pid = 0x6384, },
{ .vid = 0x27c6, .pid = 0x639C, },

View File

@@ -44,7 +44,6 @@ typedef enum {
typedef enum {
FP_ENROLL_PWR_BTN_SHIELD_ON = 0,
FP_ENROLL_ENUM,
FP_ENROLL_IDENTIFY,
FP_ENROLL_CREATE,
FP_ENROLL_CAPTURE,
FP_ENROLL_UPDATE,

View File

@@ -343,10 +343,10 @@ gx_proto_parse_body (uint16_t cmd, uint8_t *buffer, uint16_t buffer_len, pgxfp_c
break;
case MOC_CMD0_ENROLL_INIT:
if (buffer_len < sizeof (gxfp_enroll_init_t) + 1)
if (buffer_len < sizeof (gxfp_enroll_create_t) + 1)
return -1;
if (presp->result == GX_SUCCESS)
memcpy (&presp->enroll_init.tid, &buffer[1], TEMPLATE_ID_SIZE);
memcpy (&presp->enroll_create.tid, &buffer[1], TEMPLATE_ID_SIZE);
break;
case MOC_CMD0_ENROLL:

View File

@@ -105,10 +105,10 @@ typedef struct _gxfp_parse_msg
} gxfp_parse_msg_t, *pgxfp_parse_msg_t;
typedef struct _gxfp_enroll_init
typedef struct _gxfp_enroll_create
{
uint8_t tid[TEMPLATE_ID_SIZE];
} gxfp_enroll_init_t, *pgxfp_enroll_init_t;
} gxfp_enroll_create_t, *pgxfp_enroll_create_t;
#pragma pack(push, 1)
typedef struct _template_format
@@ -192,7 +192,7 @@ typedef struct _fp_cmd_response
{
gxfp_parse_msg_t parse_msg;
gxfp_verify_t verify;
gxfp_enroll_init_t enroll_init;
gxfp_enroll_create_t enroll_create;
gxfp_capturedata_t capture_data_resp;
gxfp_check_duplicate_t check_duplicate_resp;
gxfp_enroll_commit_t enroll_commit;

View File

@@ -31,10 +31,6 @@ static void start_deactivation (FpImageDevice *dev);
#define CTRL_TIMEOUT 4000
#define BULK_TIMEOUT 4000
#define IMAGE_WIDTH 144
#define IMAGE_HEIGHT 384
#define IMAGE_SIZE (IMAGE_WIDTH * IMAGE_HEIGHT)
#define MAX_CMD_SIZE 64
#define MAX_RESPONSE_SIZE 2052
#define SHORT_RESPONSE_SIZE 64
@@ -47,8 +43,10 @@ struct _FpiDeviceUpektcImg
unsigned char response[MAX_RESPONSE_SIZE];
unsigned char *image_bits;
unsigned char seq;
size_t expected_image_size;
size_t image_size;
size_t response_rest;
gboolean area_sensor;
gboolean deactivating;
};
G_DECLARE_FINAL_TYPE (FpiDeviceUpektcImg, fpi_device_upektc_img, FPI,
@@ -180,6 +178,7 @@ capture_read_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
gpointer user_data, GError *error)
{
FpImageDevice *dev = FP_IMAGE_DEVICE (device);
FpImageDeviceClass *img_class = FP_IMAGE_DEVICE_GET_CLASS (dev);
FpiDeviceUpektcImg *self = FPI_DEVICE_UPEKTC_IMG (dev);
unsigned char *data = self->response;
FpImage *img;
@@ -247,8 +246,30 @@ capture_read_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
CAPTURE_ACK_00_28);
break;
case 0x13:
/* finger is present keep your finger on reader */
fpi_device_report_finger_status_changes (device,
FP_FINGER_STATUS_NEEDED,
FP_FINGER_STATUS_NONE);
fpi_ssm_jump_to_state (transfer->ssm,
self->area_sensor ?
CAPTURE_ACK_00_28 : CAPTURE_ACK_00_28_TERM);
break;
case 0x00:
/* finger is present! */
fpi_device_report_finger_status_changes (device,
FP_FINGER_STATUS_PRESENT,
FP_FINGER_STATUS_NONE);
fpi_ssm_jump_to_state (transfer->ssm,
CAPTURE_ACK_00_28);
break;
case 0x01:
/* no finger! */
fpi_device_report_finger_status_changes (device,
FP_FINGER_STATUS_NONE,
FP_FINGER_STATUS_PRESENT);
fpi_ssm_jump_to_state (transfer->ssm,
CAPTURE_ACK_00_28);
break;
@@ -261,18 +282,20 @@ capture_read_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
fpi_image_device_report_finger_status (dev,
FALSE);
fpi_ssm_jump_to_state (transfer->ssm,
CAPTURE_ACK_00_28_TERM);
self->area_sensor ?
CAPTURE_ACK_00_28 : CAPTURE_ACK_00_28_TERM);
break;
case 0x1d:
/* too much horisontal movement */
fp_err ("too much horisontal movement, aborting");
/* too much horizontal movement */
fp_err ("too much horizontal movement, aborting");
fpi_image_device_retry_scan (dev,
FP_DEVICE_RETRY_CENTER_FINGER);
fpi_image_device_report_finger_status (dev,
FALSE);
fpi_ssm_jump_to_state (transfer->ssm,
CAPTURE_ACK_00_28_TERM);
self->area_sensor ?
CAPTURE_ACK_00_28 : CAPTURE_ACK_00_28_TERM);
break;
default:
@@ -283,7 +306,8 @@ capture_read_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
fpi_image_device_report_finger_status (dev,
FALSE);
fpi_ssm_jump_to_state (transfer->ssm,
CAPTURE_ACK_00_28_TERM);
self->area_sensor ?
CAPTURE_ACK_00_28 : CAPTURE_ACK_00_28_TERM);
break;
}
break;
@@ -307,13 +331,13 @@ capture_read_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
self->image_size +=
upektc_img_process_image_frame (self->image_bits + self->image_size,
data);
BUG_ON (self->image_size != IMAGE_SIZE);
BUG_ON (self->image_size != self->expected_image_size);
fp_dbg ("Image size is %lu",
(gulong) self->image_size);
img = fp_image_new (IMAGE_WIDTH, IMAGE_HEIGHT);
img = fp_image_new (img_class->img_width, img_class->img_height);
img->flags |= FPI_IMAGE_PARTIAL;
memcpy (img->data, self->image_bits,
IMAGE_SIZE);
self->image_size);
fpi_image_device_image_captured (dev, img);
fpi_image_device_report_finger_status (dev,
FALSE);
@@ -346,6 +370,10 @@ capture_run_state (FpiSsm *ssm, FpDevice *_dev)
switch (fpi_ssm_get_cur_state (ssm))
{
case CAPTURE_INIT_CAPTURE:
if (self->area_sensor)
upektc_img_submit_req (ssm, dev, upek2020_init_capture_press, sizeof (upek2020_init_capture_press),
self->seq, capture_reqs_cb);
else
upektc_img_submit_req (ssm, dev, upek2020_init_capture, sizeof (upek2020_init_capture),
self->seq, capture_reqs_cb);
self->seq++;
@@ -513,15 +541,81 @@ init_reqs_cb (FpiUsbTransfer *transfer, FpDevice *device,
fpi_ssm_mark_failed (transfer->ssm, error);
}
/* TODO: process response properly */
static void
init_read_data_cb (FpiUsbTransfer *transfer, FpDevice *device,
gpointer user_data, GError *error)
{
if (!error)
fpi_ssm_next_state (transfer->ssm);
else
FpImageDevice *dev = FP_IMAGE_DEVICE (device);
FpiDeviceUpektcImg *self = FPI_DEVICE_UPEKTC_IMG (dev);
unsigned char *data = self->response;
if (error)
{
fpi_ssm_mark_failed (transfer->ssm, error);
return;
}
if (data[12] == 0x06 && data[13] == 0x14) /* if get_info */
{
FpImageDeviceClass *img_class = FP_IMAGE_DEVICE_GET_CLASS (dev);
uint16_t width = (data[51] << 8) | data[50];
uint16_t height = (data[53] << 8) | data[52];
self->area_sensor = !(data[49] & 0x80);
switch (width)
{
case 256:
fp_dbg ("Sensor type : TCS1x, width x height: %hu x %hu", width, height); /* 360x256 --- 270x192 must be set */
BUG_ON (height != 360);
img_class->img_width = 192;
img_class->img_height = 270;
break;
case 208:
fp_dbg ("Sensor type : TCS2, width x height: %hu x %hu", width, height); /* 288x208 --- 216x156 must be set */
BUG_ON (height != 288);
img_class->img_width = 156;
img_class->img_height = 216;
break;
case 248:
fp_dbg ("Sensor type : TCS3, width x height: %hu x %hu", width, height); /* 360x248 --- 270x186 must be set */
BUG_ON (height != 360);
img_class->img_width = 186;
img_class->img_height = 270;
break;
case 192:
fp_dbg ("Sensor type : TCS4x, width x height: %hu x %hu", width, height); /* 512x192 --- 384x144 must be set */
BUG_ON (height != 512);
img_class->img_width = 144;
img_class->img_height = 384;
break;
case 144:
fp_dbg ("Sensor type : TCS5x, width x height: %hu x %hu", width, height); /* 512x144 --- 384x108 must be set */
BUG_ON (height != 512);
img_class->img_width = 108;
img_class->img_height = 384;
break;
default:
fp_dbg ("Sensor type : Unknown");
fpi_ssm_mark_failed (transfer->ssm,
fpi_device_error_new_msg (FP_DEVICE_ERROR_PROTO,
"Unknown sensor type (reported size %dx%d)",
width, height));
return;
}
self->expected_image_size = img_class->img_width * img_class->img_height;
self->image_bits = g_malloc0 (self->expected_image_size * 2);
}
fpi_ssm_next_state (transfer->ssm);
}
static void
@@ -616,7 +710,6 @@ dev_deactivate (FpImageDevice *dev)
static void
dev_init (FpImageDevice *dev)
{
FpiDeviceUpektcImg *self = FPI_DEVICE_UPEKTC_IMG (dev);
GError *error = NULL;
/* TODO check that device has endpoints we're using */
@@ -627,7 +720,6 @@ dev_init (FpImageDevice *dev)
return;
}
self->image_bits = g_malloc0 (IMAGE_SIZE * 2);
fpi_image_device_open_complete (dev, NULL);
}
@@ -687,6 +779,6 @@ fpi_device_upektc_img_class_init (FpiDeviceUpektcImgClass *klass)
img_class->bz3_threshold = 20;
img_class->img_width = IMAGE_WIDTH;
img_class->img_height = IMAGE_HEIGHT;
img_class->img_width = -1;
img_class->img_height = -1;
}

View File

@@ -75,6 +75,22 @@ static const unsigned char upek2020_init_capture[] = {
0x02,
0x00, /* Wait for acceptable finger */
0x02,
0x25, 0xa9 /* CRC */
};
static const unsigned char upek2020_init_capture_press[] = {
'C', 'i', 'a', 'o',
0x00,
0x00, 0x0e, /* Seq = 7, len = 0x00e */
0x28, /* CMD = 0x28 */
0x0b, 0x00, /* Inner len = 0x000b */
0x00, 0x00,
0x0e, /* SUBCMD = 0x0e */
0x02,
0xfe, 0xff, 0xff, 0xff, /* timeout = -2 = 0xfffffffe = infinite time */
0x02,
0x01, /* Wait for finger */
0x02,
0x14, 0x9a /* CRC */
};

View File

@@ -273,7 +273,8 @@ on_stream_read_cb (GObject *source_object,
}
else
{
// g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_INVALID_DATA, "Got empty data");
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
"Got empty data");
return;
}
}

View File

@@ -733,7 +733,13 @@ dev_deinit (FpDevice *dev)
}
if (!self->keep_alive)
{
stop_listener (self);
self->supports_cancellation = TRUE;
}
self->enroll_stages_passed = 0;
self->match_reported = FALSE;
fpi_device_close_complete (dev, NULL);
}

View File

@@ -111,8 +111,6 @@ typedef struct
GDestroyNotify enroll_progress_destroy;
} FpEnrollData;
void enroll_data_free (FpEnrollData *enroll_data);
typedef struct
{
FpPrint *enrolled_print; /* verify */
@@ -128,7 +126,6 @@ typedef struct
GDestroyNotify match_destroy;
} FpMatchData;
void match_data_free (FpMatchData *match_data);
void fpi_device_suspend (FpDevice *device);
void fpi_device_resume (FpDevice *device);

View File

@@ -1088,6 +1088,15 @@ fp_device_resume_finish (FpDevice *device,
return g_task_propagate_boolean (G_TASK (result), error);
}
static void
enroll_data_free (FpEnrollData *data)
{
if (data->enroll_progress_destroy)
data->enroll_progress_destroy (data->enroll_progress_data);
data->enroll_progress_data = NULL;
g_clear_object (&data->print);
g_free (data);
}
/**
* fp_device_enroll:
@@ -1217,6 +1226,23 @@ fp_device_enroll_finish (FpDevice *device,
return g_task_propagate_pointer (G_TASK (result), error);
}
static void
match_data_free (FpMatchData *data)
{
g_clear_object (&data->print);
g_clear_object (&data->match);
g_clear_error (&data->error);
if (data->match_destroy)
data->match_destroy (data->match_data);
data->match_data = NULL;
g_clear_object (&data->enrolled_print);
g_clear_pointer (&data->gallery, g_ptr_array_unref);
g_free (data);
}
/**
* fp_device_verify:
* @device: a #FpDevice

View File

@@ -24,6 +24,7 @@
#include "fpi-image.h"
#include "fpi-log.h"
#include <config.h>
#include <nbis.h>
/**

View File

@@ -522,33 +522,6 @@ fpi_device_get_driver_data (FpDevice *device)
return priv->driver_data;
}
void
enroll_data_free (FpEnrollData *data)
{
if (data->enroll_progress_destroy)
data->enroll_progress_destroy (data->enroll_progress_data);
data->enroll_progress_data = NULL;
g_clear_object (&data->print);
g_free (data);
}
void
match_data_free (FpMatchData *data)
{
g_clear_object (&data->print);
g_clear_object (&data->match);
g_clear_error (&data->error);
if (data->match_destroy)
data->match_destroy (data->match_data);
data->match_data = NULL;
g_clear_object (&data->enrolled_print);
g_clear_pointer (&data->gallery, g_ptr_array_unref);
g_free (data);
}
/**
* fpi_device_get_enroll_data:
* @device: The #FpDevice

View File

@@ -24,8 +24,9 @@
#include "fpi-log.h"
#include <nbis.h>
#include <config.h>
#if HAVE_PIXMAN
#ifdef HAVE_PIXMAN
#include <pixman.h>
#endif
@@ -107,12 +108,12 @@ fpi_mean_sq_diff_norm (const guint8 *buf1,
return res / size;
}
#if HAVE_PIXMAN
FpImage *
fpi_image_resize (FpImage *orig_img,
guint w_factor,
guint h_factor)
{
#ifdef HAVE_PIXMAN
int new_width = orig_img->width * w_factor;
int new_height = orig_img->height * h_factor;
pixman_image_t *orig, *resized;
@@ -145,5 +146,9 @@ fpi_image_resize (FpImage *orig_img,
pixman_image_unref (resized);
return newimg;
}
#else
fp_err ("Libfprint compiled without pixman support, impossible to resize");
return g_object_ref (orig_img);
#endif
}

View File

@@ -20,7 +20,6 @@
#pragma once
#include <config.h>
#include "fp-image.h"
/**
@@ -77,8 +76,6 @@ gint fpi_mean_sq_diff_norm (const guint8 *buf1,
const guint8 *buf2,
gint size);
#if HAVE_PIXMAN
FpImage *fpi_image_resize (FpImage *orig,
guint w_factor,
guint h_factor);
#endif

View File

@@ -132,7 +132,7 @@ main (int argc, char **argv)
g_print ("%s", (char *) l->data);
g_print ("\n");
g_list_free_full (usb_list, g_free);
g_list_free_full (g_steal_pointer (&usb_list), g_free);
g_print ("## SPI devices\n");
g_print ("\n");
@@ -146,7 +146,7 @@ main (int argc, char **argv)
g_print ("%s", (char *) l->data);
g_print ("\n");
g_list_free_full (usb_list, g_free);
g_list_free_full (g_steal_pointer (&spi_list), g_free);
g_hash_table_destroy (printed);

View File

@@ -263,7 +263,7 @@ libfprint_drivers = static_library('fprint-drivers',
install: false)
mapfile = files('libfprint.ver')
vflag = '-Wl,--version-script,@0@/@1@'.format(meson.source_root(), mapfile[0])
vflag = '-Wl,--version-script,@0@/@1@'.format(meson.project_source_root(), mapfile[0])
libfprint = shared_library(versioned_libname.split('lib')[1],
sources: [
@@ -339,7 +339,7 @@ sync_udev_udb = custom_target('sync-udev-hwdb',
command: [
'cp', '-v',
udev_hwdb_generator.full_path(),
meson.source_root() / 'data'
meson.project_source_root() / 'data'
]
)

View File

@@ -1,18 +1,23 @@
project('libfprint', [ 'c', 'cpp' ],
version: '1.94.4',
version: '1.94.6',
license: 'LGPLv2.1+',
default_options: [
'buildtype=debugoptimized',
'warning_level=1',
'c_std=gnu99',
],
meson_version: '>= 0.49.0')
meson_version: '>= 0.56.0')
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()
@@ -286,8 +291,6 @@ else
endif
if get_option('gtk-examples')
gnome = import('gnome')
gtk_dep = dependency('gtk+-3.0', required: false)
if not gtk_dep.found()
error('GTK+ 3.x is required for GTK+ examples')
@@ -299,9 +302,7 @@ subdir('libfprint')
configure_file(output: 'config.h', configuration: libfprint_conf)
subdir('examples')
if get_option('doc')
gnome = import('gnome')
subdir('doc')
endif
if get_option('gtk-examples')
@@ -311,6 +312,8 @@ endif
subdir('data')
subdir('tests')
subdir('examples')
pkgconfig = import('pkgconfig')
pkgconfig.generate(
name: versioned_libname,
@@ -321,3 +324,5 @@ pkgconfig.generate(
subdirs: versioned_libname,
filebase: versioned_libname,
)
summary({'Drivers': drivers, }, section: 'Drivers')

View File

@@ -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
View 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@

Binary file not shown.

View File

@@ -1,31 +1,30 @@
P: /devices/pci0000:00/0000:00:14.0/usb1/1-3
N: bus/usb/001/023=12010002EF000040C627966400010102030109022000010103A0320904000002FF0000040705830240000007050102400000
E: DEVNAME=/dev/bus/usb/001/023
P: /devices/pci0000:00/0000:00:14.0/usb3/3-9
N: bus/usb/003/004=12010002EF000040C627AC6300010102030109022000010103A0320904000002FF0000040705830240000007050102400000
E: DEVNAME=/dev/bus/usb/003/004
E: DEVTYPE=usb_device
E: DRIVER=usb
E: PRODUCT=27c6/6496/100
E: PRODUCT=27c6/63ac/100
E: TYPE=239/0/0
E: BUSNUM=001
E: DEVNUM=023
E: BUSNUM=003
E: DEVNUM=004
E: MAJOR=189
E: MINOR=22
E: MINOR=259
E: SUBSYSTEM=usb
E: ID_VENDOR=Goodix_Technology_Co.__Ltd.
E: ID_VENDOR_ENC=Goodix\x20Technology\x20Co.\x2c\x20Ltd.
E: ID_VENDOR_ID=27c6
E: ID_MODEL=Goodix_USB2.0_MISC
E: ID_MODEL_ENC=Goodix\x20USB2.0\x20MISC
E: ID_MODEL_ID=6496
E: ID_MODEL_ID=63ac
E: ID_REVISION=0100
E: ID_SERIAL=Goodix_Technology_Co.__Ltd._Goodix_USB2.0_MISC_XXXX_MOC_B0
E: ID_SERIAL_SHORT=XXXX_MOC_B0
E: ID_SERIAL=Goodix_Technology_Co.__Ltd._Goodix_USB2.0_MISC_UID4C77C784_XXXX_MOC_B0
E: ID_SERIAL_SHORT=UID4C77C784_XXXX_MOC_B0
E: ID_BUS=usb
E: ID_USB_INTERFACES=:ff0000:
E: ID_VENDOR_FROM_DATABASE=Shenzhen Goodix Technology Co.,Ltd.
E: ID_AUTOSUSPEND=1
E: ID_PERSIST=0
E: ID_PATH=pci-0000:00:14.0-usb-0:3
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_3
E: ID_PATH=pci-0000:00:14.0-usb-0:9
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_9
A: authorized=1\n
A: avoid_reset_quirk=0\n
A: bConfigurationValue=1\n
@@ -38,30 +37,34 @@ A: bNumConfigurations=1\n
A: bNumInterfaces= 1\n
A: bcdDevice=0100\n
A: bmAttributes=a0\n
A: busnum=1\n
A: configuration=XXXX_MOC_B0\n
H: descriptors=12010002EF000040C627966400010102030109022000010103A0320904000002FF0000040705830240000007050102400000
A: dev=189:22\n
A: devnum=23\n
A: devpath=3\n
A: busnum=3\n
A: configuration=UID4C77C784_XXXX_MOC_B0\n
H: descriptors=12010002EF000040C627AC6300010102030109022000010103A0320904000002FF0000040705830240000007050102400000
A: dev=189:259\n
A: devnum=4\n
A: devpath=9\n
L: driver=../../../../../bus/usb/drivers/usb
L: firmware_node=../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/device:1d/device:20
A: idProduct=6496\n
L: firmware_node=../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:13/device:14/device:1f
A: idProduct=63ac\n
A: idVendor=27c6\n
A: ltm_capable=no\n
A: manufacturer=Goodix Technology Co., Ltd.\n
A: maxchild=0\n
L: port=../1-0:1.0/usb1-port3
A: power/active_duration=22667\n
L: port=../3-0:1.0/usb3-port9
A: power/active_duration=702588\n
A: power/async=enabled\n
A: power/autosuspend=2\n
A: power/autosuspend_delay_ms=2000\n
A: power/connected_duration=917616\n
A: power/connected_duration=78973756\n
A: power/control=auto\n
A: power/level=auto\n
A: power/persist=1\n
A: power/runtime_active_time=22809\n
A: power/runtime_active_kids=0\n
A: power/runtime_active_time=707156\n
A: power/runtime_enabled=enabled\n
A: power/runtime_status=active\n
A: power/runtime_suspended_time=894564\n
A: power/runtime_suspended_time=78265226\n
A: power/runtime_usage=0\n
A: power/wakeup=disabled\n
A: power/wakeup_abort_count=\n
A: power/wakeup_active=\n
@@ -73,34 +76,34 @@ A: power/wakeup_max_time_ms=\n
A: power/wakeup_total_time_ms=\n
A: product=Goodix USB2.0 MISC\n
A: quirks=0x0\n
A: removable=removable\n
A: removable=fixed\n
A: rx_lanes=1\n
A: serial=XXXX_MOC_B0\n
A: serial=UID4C77C784_XXXX_MOC_B0\n
A: speed=12\n
A: tx_lanes=1\n
A: urbnum=298\n
A: urbnum=5759\n
A: version= 2.00\n
P: /devices/pci0000:00/0000:00:14.0/usb1
N: bus/usb/001/001=12010002090001406B1D020017050302010109021900010100E0000904000001090000000705810304000C
E: DEVNAME=/dev/bus/usb/001/001
P: /devices/pci0000:00/0000:00:14.0/usb3
N: bus/usb/003/001=12010002090001406B1D020015050302010109021900010100E0000904000001090000000705810304000C
E: DEVNAME=/dev/bus/usb/003/001
E: DEVTYPE=usb_device
E: DRIVER=usb
E: PRODUCT=1d6b/2/517
E: PRODUCT=1d6b/2/515
E: TYPE=9/0/1
E: BUSNUM=001
E: BUSNUM=003
E: DEVNUM=001
E: MAJOR=189
E: MINOR=0
E: MINOR=256
E: SUBSYSTEM=usb
E: ID_VENDOR=Linux_5.17.12-300.fc36.x86_64_xhci-hcd
E: ID_VENDOR_ENC=Linux\x205.17.12-300.fc36.x86_64\x20xhci-hcd
E: ID_VENDOR=Linux_5.15.0-57-generic_xhci-hcd
E: ID_VENDOR_ENC=Linux\x205.15.0-57-generic\x20xhci-hcd
E: ID_VENDOR_ID=1d6b
E: ID_MODEL=xHCI_Host_Controller
E: ID_MODEL_ENC=xHCI\x20Host\x20Controller
E: ID_MODEL_ID=0002
E: ID_REVISION=0517
E: ID_SERIAL=Linux_5.17.12-300.fc36.x86_64_xhci-hcd_xHCI_Host_Controller_0000:00:14.0
E: ID_REVISION=0515
E: ID_SERIAL=Linux_5.15.0-57-generic_xhci-hcd_xHCI_Host_Controller_0000:00:14.0
E: ID_SERIAL_SHORT=0000:00:14.0
E: ID_BUS=usb
E: ID_USB_INTERFACES=:090000:
@@ -123,31 +126,35 @@ A: bMaxPacketSize0=64\n
A: bMaxPower=0mA\n
A: bNumConfigurations=1\n
A: bNumInterfaces= 1\n
A: bcdDevice=0517\n
A: bcdDevice=0515\n
A: bmAttributes=e0\n
A: busnum=1\n
A: configuration=\n
H: descriptors=12010002090001406B1D020017050302010109021900010100E0000904000001090000000705810304000C
A: dev=189:0\n
A: busnum=3\n
A: configuration=
H: descriptors=12010002090001406B1D020015050302010109021900010100E0000904000001090000000705810304000C
A: dev=189:256\n
A: devnum=1\n
A: devpath=0\n
L: driver=../../../../bus/usb/drivers/usb
L: firmware_node=../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c/device:1d
L: firmware_node=../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:13/device:14
A: idProduct=0002\n
A: idVendor=1d6b\n
A: interface_authorized_default=1\n
A: ltm_capable=no\n
A: manufacturer=Linux 5.17.12-300.fc36.x86_64 xhci-hcd\n
A: manufacturer=Linux 5.15.0-57-generic xhci-hcd\n
A: maxchild=12\n
A: power/active_duration=164289796\n
A: power/active_duration=78971960\n
A: power/async=enabled\n
A: power/autosuspend=0\n
A: power/autosuspend_delay_ms=0\n
A: power/connected_duration=164360220\n
A: power/connected_duration=78974992\n
A: power/control=auto\n
A: power/level=auto\n
A: power/runtime_active_time=164331876\n
A: power/runtime_active_kids=2\n
A: power/runtime_active_time=78973899\n
A: power/runtime_enabled=enabled\n
A: power/runtime_status=active\n
A: power/runtime_suspended_time=0\n
A: power/runtime_usage=0\n
A: power/wakeup=disabled\n
A: power/wakeup_abort_count=\n
A: power/wakeup_active=\n
@@ -164,48 +171,52 @@ A: rx_lanes=1\n
A: serial=0000:00:14.0\n
A: speed=480\n
A: tx_lanes=1\n
A: urbnum=2097\n
A: urbnum=1824\n
A: version= 2.00\n
P: /devices/pci0000:00/0000:00:14.0
E: DRIVER=xhci_hcd
E: PCI_CLASS=C0330
E: PCI_ID=8086:9DED
E: PCI_SUBSYS_ID=17AA:2292
E: PCI_ID=8086:51ED
E: PCI_SUBSYS_ID=1028:0B00
E: PCI_SLOT_NAME=0000:00:14.0
E: MODALIAS=pci:v00008086d00009DEDsv000017AAsd00002292bc0Csc03i30
E: MODALIAS=pci:v00008086d000051EDsv00001028sd00000B00bc0Csc03i30
E: SUBSYSTEM=pci
E: ID_PCI_CLASS_FROM_DATABASE=Serial bus controller
E: ID_PCI_SUBCLASS_FROM_DATABASE=USB controller
E: ID_PCI_INTERFACE_FROM_DATABASE=XHCI
E: ID_VENDOR_FROM_DATABASE=Intel Corporation
E: ID_AUTOSUSPEND=1
E: ID_MODEL_FROM_DATABASE=Cannon Point-LP USB 3.1 xHCI Controller
A: ari_enabled=0\n
A: broken_parity_status=0\n
A: class=0x0c0330\n
H: config=8680ED9D060490021130030C00008000040022EA000000000000000000000000000000000000000000000000AA179222000000007000000000000000FF010000FD0134808FC6FF8300000000000000007F6DDC0F00000000F507312600000000316000000000000000000000000000000180C2C1080000000000000000000000059087001803E0FE0000000000000000090014F01000400100000000C10A080000080E00001800008F40020000010000000000000000000008000000040000000000000000000000000000000000000000000000000000000800000004000000000000000000000000000000000000000000000000000000B50F320112000000
H: config=8680ED51060490020130030C0000800004002A8F6200000000000000000000000000000000000000000000002810000B000000007000000000000000FF010000FD0134A089C27F8000000000000000003F6DD80F000000000000000000000000316000000000000000000000000000000180C2C1080000000000000000000000059087003808E0FE000000000000000009B014F01000400100000000C10A080000080E00001800008F50020000010000090000018680C00009001014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B50F100112000000
A: consistent_dma_mask_bits=64\n
A: d3cold_allowed=1\n
A: dbc=disabled\n
A: device=0x9ded\n
A: device=0x51ed\n
A: dma_mask_bits=64\n
L: driver=../../../bus/pci/drivers/xhci_hcd
A: driver_override=(null)\n
A: enable=1\n
L: firmware_node=../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1c
A: irq=128\n
A: local_cpulist=0-7\n
A: local_cpus=ff\n
A: modalias=pci:v00008086d00009DEDsv000017AAsd00002292bc0Csc03i30\n
L: firmware_node=../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:13
L: iommu=../../virtual/iommu/dmar1
L: iommu_group=../../../kernel/iommu_groups/13
A: irq=167\n
A: local_cpulist=0-19\n
A: local_cpus=fffff\n
A: modalias=pci:v00008086d000051EDsv00001028sd00000B00bc0Csc03i30\n
A: msi_bus=1\n
A: msi_irqs/128=msi\n
A: msi_irqs/167=msi\n
A: numa_node=-1\n
A: pools=poolinfo - 0.1\nbuffer-2048 0 0 2048 0\nbuffer-512 0 0 512 0\nbuffer-128 0 0 128 0\nbuffer-32 0 0 32 0\nxHCI 1KB stream ctx arrays 0 0 1024 0\nxHCI 256 byte stream ctx arrays 0 0 256 0\nxHCI input/output contexts 11 12 2112 12\nxHCI ring segments 46 50 4096 50\nbuffer-2048 0 0 2048 0\nbuffer-512 0 0 512 0\nbuffer-128 6 32 128 1\nbuffer-32 0 0 32 0\n
A: pools=poolinfo - 0.1\nxHCI 1KB stream ctx arrays 0 0 1024 0\nxHCI 256 byte stream ctx arrays 0 0 256 0\nxHCI input/output contexts 13 14 2112 14\nxHCI ring segments 38 42 4096 42\nbuffer-2048 0 0 2048 0\nbuffer-512 0 0 512 0\nbuffer-128 0 0 128 0\nbuffer-32 0 0 32 0\nbuffer-2048 0 0 2048 0\nbuffer-512 0 0 512 0\nbuffer-128 3 32 128 1\nbuffer-32 0 0 32 0\n
A: power/async=enabled\n
A: power/control=auto\n
A: power/runtime_active_time=164332777\n
A: power/runtime_active_kids=1\n
A: power/runtime_active_time=78974886\n
A: power/runtime_enabled=enabled\n
A: power/runtime_status=active\n
A: power/runtime_suspended_time=0\n
A: power/runtime_usage=0\n
A: power/wakeup=enabled\n
A: power/wakeup_abort_count=0\n
A: power/wakeup_active=0\n
@@ -216,9 +227,9 @@ A: power/wakeup_last_time_ms=0\n
A: power/wakeup_max_time_ms=0\n
A: power/wakeup_total_time_ms=0\n
A: power_state=D0\n
A: resource=0x00000000ea220000 0x00000000ea22ffff 0x0000000000140204\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n
A: revision=0x11\n
A: subsystem_device=0x2292\n
A: subsystem_vendor=0x17aa\n
A: resource=0x000000628f2a0000 0x000000628f2affff 0x0000000000140204\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n
A: revision=0x01\n
A: subsystem_device=0x0b00\n
A: subsystem_vendor=0x1028\n
A: vendor=0x8086\n

View File

@@ -17,3 +17,10 @@
...
}
{
<ignore-g-thread-new-leak>
Memcheck:Leak
fun:calloc
...
fun:g_thread_new
}

View File

@@ -4,9 +4,9 @@ envs.set('G_DEBUG', 'fatal-warnings')
envs.set('G_MESSAGES_DEBUG', 'all')
# Setup paths
envs.set('MESON_SOURCE_ROOT', meson.source_root())
envs.set('MESON_BUILD_ROOT', meson.build_root())
envs.prepend('LD_LIBRARY_PATH', join_paths(meson.build_root(), 'libfprint'))
envs.set('MESON_SOURCE_ROOT', meson.project_source_root())
envs.set('MESON_BUILD_ROOT', meson.project_build_root())
envs.prepend('LD_LIBRARY_PATH', meson.project_build_root() / 'libfprint')
# Set FP_DEVICE_EMULATION so that drivers can adapt (e.g. to use fixed
# random numbers rather than proper ones)
@@ -19,8 +19,17 @@ envs.set('FP_DRIVERS_WHITELIST', ':'.join([
'virtual_device_storage',
]))
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',
@@ -30,6 +39,7 @@ drivers_tests = [
'elanspi',
'synaptics',
'upektc_img',
'upektc_img-tcs1s',
'uru4000-msv2',
'uru4000-4500',
'vfs0050',
@@ -44,23 +54,33 @@ drivers_tests = [
if get_option('introspection')
conf = configuration_data()
conf.set('SRCDIR', meson.source_root())
conf.set('BUILDDIR', meson.build_root())
conf.set('SRCDIR', meson.project_source_root())
conf.set('BUILDDIR', meson.project_build_root())
configure_file(configuration: conf,
input: 'create-driver-test.py.in',
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', join_paths(meson.build_root(), 'libfprint'))
envs.prepend('GI_TYPELIB_PATH', meson.project_build_root() / 'libfprint')
virtual_devices_tests = [
'virtual-image',
'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('-'))
@@ -92,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'),
@@ -100,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
@@ -107,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: [
@@ -118,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'),
@@ -125,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',
@@ -164,7 +248,7 @@ endif
unit_tests_deps = { 'fpi-assembling' : [cairo_dep] }
test_config = configuration_data()
test_config.set_quoted('SOURCE_ROOT', meson.source_root())
test_config.set_quoted('SOURCE_ROOT', meson.project_source_root())
test_config_h = configure_file(output: 'test-config.h', configuration: test_config)
foreach test_name: unit_tests
@@ -197,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
@@ -217,7 +316,7 @@ test('udev-hwdb',
gdb = find_program('gdb', required: false)
if gdb.found()
libfprint_wrapper = [
gdb.path(),
gdb.full_path(),
'-batch',
'-ex', 'run',
'--args',
@@ -234,12 +333,12 @@ 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'
libfprint_suppressions = '@0@/@1@'.format(meson.source_root(),
libfprint_suppressions = '@0@/@1@'.format(meson.project_source_root(),
files('libfprint.supp')[0])
python_suppressions = '@0@/@1@'.format(meson.source_root(),
python_suppressions = '@0@/@1@'.format(meson.project_source_root(),
files('valgrind-python.supp')[0])
libfprint_wrapper = [
valgrind.path(),
valgrind.full_path(),
'--tool=memcheck',
'--leak-check=full',
'--leak-resolution=high',
@@ -248,6 +347,7 @@ if valgrind.found()
'--track-origins=yes',
'--show-leak-kinds=definite,possible',
'--show-error-list=yes',
'--gen-suppressions=all',
'--suppressions=' + libfprint_suppressions,
'--suppressions=' + glib_suppressions,
'--suppressions=' + python_suppressions,

View File

@@ -20,6 +20,7 @@
#define FP_COMPONENT "fake_test_dev"
#include "fpi-log.h"
#include "test-device-fake.h"
G_DEFINE_TYPE (FpiDeviceFake, fpi_device_fake, FP_TYPE_DEVICE)
@@ -29,12 +30,28 @@ static const FpIdEntry driver_ids[] = {
{ .virtual_envvar = NULL }
};
static void
(debug_action) (FpDevice * device,
const gchar *func)
{
g_autofree char *action_str = NULL;
action_str = g_enum_to_string (FPI_TYPE_DEVICE_ACTION,
fpi_device_get_current_action (device));
fp_dbg ("%s: Device %s in action %s\n",
func, fp_device_get_name (device), action_str);
}
#define debug_action(d) (debug_action) ((d), G_STRFUNC)
static void
fpi_device_fake_probe (FpDevice *device)
{
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
debug_action (device);
fake_dev->last_called_function = fpi_device_fake_probe;
g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_PROBE);
@@ -55,6 +72,7 @@ fpi_device_fake_open (FpDevice *device)
{
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
debug_action (device);
fake_dev->last_called_function = fpi_device_fake_open;
g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_OPEN);
@@ -72,6 +90,7 @@ fpi_device_fake_close (FpDevice *device)
{
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
debug_action (device);
fake_dev->last_called_function = fpi_device_fake_close;
g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_CLOSE);
@@ -90,6 +109,7 @@ fpi_device_fake_enroll (FpDevice *device)
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
FpPrint *print = fake_dev->ret_print;
debug_action (device);
fake_dev->last_called_function = fpi_device_fake_enroll;
g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_ENROLL);
@@ -118,6 +138,7 @@ fpi_device_fake_verify (FpDevice *device)
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
FpPrint *print = fake_dev->ret_print;
debug_action (device);
fake_dev->last_called_function = fpi_device_fake_verify;
g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_VERIFY);
@@ -149,6 +170,7 @@ fpi_device_fake_identify (FpDevice *device)
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
FpPrint *match = fake_dev->ret_match;
debug_action (device);
fake_dev->last_called_function = fpi_device_fake_identify;
g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_IDENTIFY);
@@ -197,6 +219,7 @@ fpi_device_fake_capture (FpDevice *device)
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
gboolean wait_for_finger;
debug_action (device);
fake_dev->last_called_function = fpi_device_fake_capture;
g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_CAPTURE);
@@ -216,6 +239,7 @@ fpi_device_fake_list (FpDevice *device)
{
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
debug_action (device);
fake_dev->last_called_function = fpi_device_fake_list;
g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_LIST);
@@ -233,6 +257,7 @@ fpi_device_fake_delete (FpDevice *device)
{
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
debug_action (device);
fake_dev->last_called_function = fpi_device_fake_delete;
g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_DELETE);
@@ -251,6 +276,7 @@ fpi_device_fake_clear_storage (FpDevice *device)
{
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
debug_action (device);
fake_dev->last_called_function = fpi_device_fake_clear_storage;
g_assert_cmpuint (fpi_device_get_current_action (device), ==, FPI_DEVICE_ACTION_CLEAR_STORAGE);
@@ -268,6 +294,7 @@ fpi_device_fake_cancel (FpDevice *device)
{
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
debug_action (device);
fake_dev->last_called_function = fpi_device_fake_cancel;
g_assert_cmpuint (fpi_device_get_current_action (device), !=, FPI_DEVICE_ACTION_NONE);
}
@@ -277,6 +304,7 @@ fpi_device_fake_suspend (FpDevice *device)
{
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
debug_action (device);
fake_dev->last_called_function = fpi_device_fake_suspend;
fpi_device_suspend_complete (device, g_steal_pointer (&fake_dev->ret_suspend));
@@ -287,6 +315,7 @@ fpi_device_fake_resume (FpDevice *device)
{
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
debug_action (device);
fake_dev->last_called_function = fpi_device_fake_resume;
fpi_device_resume_complete (device, g_steal_pointer (&fake_dev->ret_resume));

View File

@@ -30,8 +30,10 @@
#include "fp-print-private.h"
/* gcc 12.0.1 is complaining about dangling pointers in the auto_close* functions */
#if G_GNUC_CHECK_VERSION (12, 0)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-pointer"
#endif
/* Utility functions */
@@ -69,7 +71,9 @@ auto_close_fake_device_free (FpAutoCloseDevice *device)
}
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FpAutoCloseDevice, auto_close_fake_device_free)
#if G_GNUC_CHECK_VERSION (12, 0)
#pragma GCC diagnostic pop
#endif
typedef FpDeviceClass FpAutoResetClass;
static FpAutoResetClass default_fake_dev_class = {0};

6
tests/test.in Normal file
View 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@

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

File diff suppressed because one or more lines are too long

View File

@@ -40,6 +40,20 @@
fun:_Py*
}
{
ignore__py_addr32
Memcheck:Addr32
...
fun:_Py*
}
{
ignore__py_addr32
Memcheck:Addr32
...
fun:Py*
}
{
ignore_py_leaks
Memcheck:Leak

View File

@@ -59,6 +59,17 @@ class GLibErrorMessage:
class VirtualDeviceBase(unittest.TestCase):
DEFAULT_ENROLL_STEPS = 5
USE_CLASS_DEVICE = True
@classmethod
def get_device(cls, ctx):
for dev in ctx.get_devices():
# We might have a USB device in the test system that needs skipping
if dev.get_driver() == cls._driver_name:
return dev
return None
@classmethod
def setUpClass(cls):
unittest.TestCase.setUpClass()
@@ -73,26 +84,28 @@ class VirtualDeviceBase(unittest.TestCase):
cls.sockaddr = os.path.join(cls.tmpdir, '{}.socket'.format(sock_name))
os.environ['FP_{}'.format(driver_name.upper())] = cls.sockaddr
cls._driver_name = driver_name
if cls.USE_CLASS_DEVICE:
cls.ctx = FPrint.Context()
cls.dev = None
for dev in cls.ctx.get_devices():
# We might have a USB device in the test system that needs skipping
if dev.get_driver() == driver_name:
cls.dev = dev
break
assert cls.dev is not None, "You need to compile with {} for testing".format(driver_name)
cls.dev = cls.get_device(cls.ctx)
assert cls.dev is not None, "You need to compile with {} for testing".format(
driver_name)
@classmethod
def tearDownClass(cls):
shutil.rmtree(cls.tmpdir)
if cls.USE_CLASS_DEVICE:
del cls.dev
del cls.ctx
unittest.TestCase.tearDownClass()
def setUp(self):
super().setUp()
if not self.USE_CLASS_DEVICE:
self.ctx = FPrint.Context()
self.dev = self.get_device(self.ctx)
self.assertIsNotNone(self.dev)
self._close_on_teardown = True
self.assertFalse(self.dev.is_open())
self.dev.open_sync()
@@ -101,8 +114,13 @@ class VirtualDeviceBase(unittest.TestCase):
def tearDown(self):
if self._close_on_teardown:
self.assertTrue(self.dev.is_open())
self.set_keep_alive(False)
self.send_command('SET_ENROLL_STAGES', self.DEFAULT_ENROLL_STEPS)
self.dev.close_sync()
self.assertFalse(self.dev.is_open())
if not self.USE_CLASS_DEVICE:
del self.dev
del self.ctx
super().tearDown()
def wait_timeout(self, interval):
@@ -331,6 +349,107 @@ class VirtualDeviceBase(unittest.TestCase):
self.assertEqual(self._verify_fp.props.fpi_data.get_string(), scan_nick)
class VirtualDeviceUnplugging(VirtualDeviceBase):
driver_name = 'virtual_device'
USE_CLASS_DEVICE = False
def test_device_unplug(self):
self._close_on_teardown = False
notified_spec = None
def on_removed_notify(dev, spec):
nonlocal notified_spec
notified_spec = spec
removed = False
ctx_removed = False
def on_ctx_removed(ctx, dev):
nonlocal ctx_removed
ctx_removed = dev == self.dev
self.assertEqual(removed, ctx_removed)
def on_removed(dev):
nonlocal removed
removed = dev.props.removed
self.assertNotEqual(removed, ctx_removed)
self.assertFalse(self.dev.props.removed)
self.dev.connect('notify::removed', on_removed_notify)
self.ctx.connect('device-removed', on_ctx_removed)
self.dev.connect('removed', on_removed)
self.send_command('UNPLUG')
self.assertEqual(notified_spec.name, 'removed')
self.assertTrue(self.dev.props.removed)
self.assertIn(self.dev, self.ctx.get_devices())
self.assertTrue(removed)
with self.assertRaises(GLib.GError) as error:
self.dev.close_sync()
self.assertTrue(error.exception.matches(FPrint.DeviceError.quark(),
FPrint.DeviceError.REMOVED))
while not ctx_removed:
ctx.iteration(True)
self.assertNotIn(self.dev, self.ctx.get_devices())
def test_device_unplug_during_verify(self):
self._close_on_teardown = False
self._destroy_on_teardown = True
notified_spec = None
def on_removed_notify(dev, spec):
nonlocal notified_spec
notified_spec = spec
removed = False
ctx_removed = False
def on_ctx_removed(ctx, dev):
nonlocal ctx_removed
ctx_removed = dev == self.dev
self.assertEqual(removed, ctx_removed)
def on_removed(dev):
nonlocal removed
removed = dev.props.removed
self.assertNotEqual(removed, ctx_removed)
self.assertFalse(self.dev.props.removed)
self.dev.connect('notify::removed', on_removed_notify)
self.ctx.connect('device-removed', on_ctx_removed)
self.dev.connect('removed', on_removed)
self.start_verify(FPrint.Print.new(self.dev),
identify=self.dev.supports_identify())
self.send_command('UNPLUG')
self.assertEqual(notified_spec.name, 'removed')
self.assertTrue(self.dev.props.removed)
self.assertIn(self.dev, self.ctx.get_devices())
self.assertFalse(removed)
with self.assertRaises(GLib.GError) as error:
self.complete_verify()
self.assertTrue(error.exception.matches(FPrint.DeviceError.quark(),
FPrint.DeviceError.REMOVED))
self.assertTrue(removed)
self.assertIn(self.dev, self.ctx.get_devices())
with self.assertRaises(GLib.GError) as error:
self.dev.close_sync()
self.assertTrue(error.exception.matches(FPrint.DeviceError.quark(),
FPrint.DeviceError.REMOVED))
while not ctx_removed:
ctx.iteration(True)
self.assertNotIn(self.dev, self.ctx.get_devices())
class VirtualDevice(VirtualDeviceBase):
def test_device_properties(self):
@@ -339,7 +458,8 @@ class VirtualDevice(VirtualDeviceBase):
self.assertEqual(self.dev.get_name(), 'Virtual device for debugging')
self.assertTrue(self.dev.is_open())
self.assertEqual(self.dev.get_scan_type(), FPrint.ScanType.SWIPE)
self.assertEqual(self.dev.get_nr_enroll_stages(), 5)
self.assertEqual(self.dev.get_nr_enroll_stages(),
self.DEFAULT_ENROLL_STEPS)
self.assertFalse(self.dev.supports_identify())
self.assertFalse(self.dev.supports_capture())
self.assertFalse(self.dev.has_storage())
@@ -700,69 +820,6 @@ class VirtualDevice(VirtualDeviceBase):
self.assertEqual(self.dev.get_scan_type(), FPrint.ScanType.SWIPE)
self.assertIsNone(notified_spec)
def test_device_unplug(self):
self._close_on_teardown = False
notified_spec = None
def on_removed_notify(dev, spec):
nonlocal notified_spec
notified_spec = spec
removed = False
def on_removed(dev):
nonlocal removed
removed = True
self.assertFalse(self.dev.props.removed)
self.dev.connect('notify::removed', on_removed_notify)
self.dev.connect('removed', on_removed)
self.send_command('UNPLUG')
self.assertEqual(notified_spec.name, 'removed')
self.assertTrue(self.dev.props.removed)
self.assertTrue(removed)
with self.assertRaises(GLib.GError) as error:
self.dev.close_sync()
self.assertTrue(error.exception.matches(FPrint.DeviceError.quark(),
FPrint.DeviceError.REMOVED))
def test_device_unplug_during_verify(self):
self._close_on_teardown = False
notified_spec = None
def on_removed_notify(dev, spec):
nonlocal notified_spec
notified_spec = spec
removed = False
def on_removed(dev):
nonlocal removed
removed = True
self.assertFalse(self.dev.props.removed)
self.dev.connect('notify::removed', on_removed_notify)
self.dev.connect('removed', on_removed)
self.start_verify(FPrint.Print.new(self.dev),
identify=self.dev.supports_identify())
self.send_command('UNPLUG')
self.assertEqual(notified_spec.name, 'removed')
self.assertTrue(self.dev.props.removed)
self.assertFalse(removed)
with self.assertRaises(GLib.GError) as error:
self.complete_verify()
self.assertTrue(error.exception.matches(FPrint.DeviceError.quark(),
FPrint.DeviceError.REMOVED))
self.assertTrue(removed)
with self.assertRaises(GLib.GError) as error:
self.dev.close_sync()
self.assertTrue(error.exception.matches(FPrint.DeviceError.quark(),
FPrint.DeviceError.REMOVED))
def test_device_sleep(self):
self.send_sleep(1500)

View File

@@ -46,12 +46,15 @@ def load_image(img):
return img
if hasattr(os.environ, 'MESON_SOURCE_ROOT'):
if 'FP_PRINTS_PATH' in os.environ:
prints_path = os.environ['FP_PRINTS_PATH']
else:
if 'MESON_SOURCE_ROOT' in os.environ:
root = os.environ['MESON_SOURCE_ROOT']
else:
root = os.path.join(os.path.dirname(__file__), '..')
imgdir = os.path.join(root, 'examples', 'prints')
prints_path = os.path.join(root, 'examples', 'prints')
ctx = GLib.main_context_default()
@@ -76,10 +79,12 @@ class VirtualImage(unittest.TestCase):
assert cls.dev is not None, "You need to compile with virtual_image for testing"
cls.prints = {}
for f in glob.glob(os.path.join(imgdir, '*.png')):
for f in glob.glob(os.path.join(prints_path, '*.png')):
n = os.path.basename(f)[:-4]
cls.prints[n] = load_image(f)
assert cls.prints, "No prints found in " + prints_path
@classmethod
def tearDownClass(cls):
shutil.rmtree(cls.tmpdir)