Merge tag 'v1.90.6' into tod

Tag 1.90.6

Git-EVTag-v0-SHA512: 1cca84a89332a674d822476e587e1d9f30dc11bfff13724548ec0be66ab32f910fb5e7a7c9403c9a813538fdd9e86661105af8e2a4865b0b30d301601c7bddab
This commit is contained in:
Marco Trevisan (Treviño)
2020-12-10 16:10:39 +01:00
14 changed files with 186 additions and 91 deletions
+10
View File
@@ -0,0 +1,10 @@
# The commits that did automated reformatting. You can ignore them
# during git-blame with `--ignore-rev` or `--ignore-revs-file`.
#
# $ git config --add 'blame.ignoreRevsFile' '.git-blame-ignore-revs'
#
d1fb1e26f3b79e54febc94496c1184763cf2af3d
e4f9935706be4c0e3253afe251c182019ff7ccef
65e602d8c72baa7020efb62d10bf28e621feb05d
4115ae7ced77d392ee11ea55212206d9404356f0
+18
View File
@@ -1,6 +1,24 @@
This file lists notable changes in each release. For the full history of all This file lists notable changes in each release. For the full history of all
changes, see ChangeLog. changes, see ChangeLog.
2020-12-01: v1.90.6 release
This release is primarily a bugfix release for some older issues.
The major change is that fp_print_deserialize will now correctly return a
sunken reference rather than a floating one. Most API users will have
assumed this was true, and issues could happen at a later point.
If any API user worked around this libfprint bug, they will now leak the
returned print.
Highlights:
* Object reference management fixes for FpPrint and identify
* Fixed issues that caused problem on non-x86 machines (#236)
* Fix building with older GLib versions
* synaptics: Support PID 00e7
* goodix: Fix issue with long USB packages
2020-12-01: v1.90.5 release 2020-12-01: v1.90.5 release
The 1.90.4 release caused a major regression, as it included a USB hub in The 1.90.4 release caused a major regression, as it included a USB hub in
-2
View File
@@ -91,8 +91,6 @@ FP_TYPE_PRINT
FpFinger FpFinger
FpPrint FpPrint
fp_print_new fp_print_new
fp_print_new_from_data
fp_print_to_data
fp_print_get_driver fp_print_get_driver
fp_print_get_device_id fp_print_get_device_id
fp_print_get_device_stored fp_print_get_device_stored
+4 -5
View File
@@ -350,9 +350,9 @@ fp_verify_cb (FpiDeviceGoodixMoc *self,
gxfp_cmd_response_t *resp, gxfp_cmd_response_t *resp,
GError *error) GError *error)
{ {
g_autoptr(GPtrArray) templates = NULL;
FpDevice *device = FP_DEVICE (self); FpDevice *device = FP_DEVICE (self);
FpPrint *print = NULL; FpPrint *print = NULL;
GPtrArray *templates = NULL;
gint cnt = 0; gint cnt = 0;
gboolean find = false; gboolean find = false;
@@ -365,15 +365,14 @@ fp_verify_cb (FpiDeviceGoodixMoc *self,
{ {
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_VERIFY) if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_VERIFY)
{ {
templates = g_ptr_array_sized_new (1);
templates = g_ptr_array_new_with_free_func (g_object_unref);
fpi_device_get_verify_data (device, &print); fpi_device_get_verify_data (device, &print);
g_ptr_array_add (templates, g_object_ref_sink (print)); g_ptr_array_add (templates, print);
} }
else else
{ {
fpi_device_get_identify_data (device, &templates); fpi_device_get_identify_data (device, &templates);
g_ptr_array_ref (templates);
} }
for (cnt = 0; cnt < templates->len; cnt++) for (cnt = 0; cnt < templates->len; cnt++)
{ {
+1 -1
View File
@@ -229,7 +229,7 @@ gx_proto_parse_header (
memcpy (pheader, buffer, sizeof (pack_header)); memcpy (pheader, buffer, sizeof (pack_header));
pheader->len = GUINT16_FROM_LE (*(buffer + 4)); pheader->len = GUINT16_FROM_LE ( *(uint16_t *) (buffer + 4));
pheader->len -= PACKAGE_CRC_SIZE; pheader->len -= PACKAGE_CRC_SIZE;
return 0; return 0;
+8 -1
View File
@@ -1018,6 +1018,7 @@ fp_device_identify (FpDevice *device,
g_autoptr(GTask) task = NULL; g_autoptr(GTask) task = NULL;
FpDevicePrivate *priv = fp_device_get_instance_private (device); FpDevicePrivate *priv = fp_device_get_instance_private (device);
FpMatchData *data; FpMatchData *data;
int i;
task = g_task_new (device, cancellable, callback, user_data); task = g_task_new (device, cancellable, callback, user_data);
if (g_task_return_error_if_cancelled (task)) if (g_task_return_error_if_cancelled (task))
@@ -1042,7 +1043,13 @@ fp_device_identify (FpDevice *device,
maybe_cancel_on_cancelled (device, cancellable); maybe_cancel_on_cancelled (device, cancellable);
data = g_new0 (FpMatchData, 1); data = g_new0 (FpMatchData, 1);
data->gallery = g_ptr_array_ref (prints); /* We cannot store the gallery directly, because the ptr array may not own
* a reference to each print. Also, the caller could in principle modify the
* GPtrArray afterwards.
*/
data->gallery = g_ptr_array_new_full (prints->len, g_object_unref);
for (i = 0; i < prints->len; i++)
g_ptr_array_add (data->gallery, g_object_ref (g_ptr_array_index (prints, i)));
data->match_cb = match_cb; data->match_cb = match_cb;
data->match_data = match_data; data->match_data = match_data;
data->match_destroy = match_destroy; data->match_destroy = match_destroy;
+1 -1
View File
@@ -282,7 +282,7 @@ fp_image_detect_minutiae_thread_func (GTask *task,
gint map_w, map_h; gint map_w, map_h;
gint bw, bh, bd; gint bw, bh, bd;
gint r; gint r;
g_autofree LFSPARMS *lfsparms; g_autofree LFSPARMS *lfsparms = NULL;
/* Normalize the image first */ /* Normalize the image first */
if (data->flags & FPI_IMAGE_H_FLIPPED) if (data->flags & FPI_IMAGE_H_FLIPPED)
+4 -3
View File
@@ -808,6 +808,7 @@ fp_print_deserialize (const guchar *data,
"device-id", device_id, "device-id", device_id,
"device-stored", device_stored, "device-stored", device_stored,
NULL); NULL);
g_object_ref_sink (result);
fpi_print_set_type (result, FPI_PRINT_NBIS); fpi_print_set_type (result, FPI_PRINT_NBIS);
for (i = 0; i < g_variant_n_children (prints); i++) for (i = 0; i < g_variant_n_children (prints); i++)
{ {
@@ -857,6 +858,7 @@ fp_print_deserialize (const guchar *data,
"device-stored", device_stored, "device-stored", device_stored,
"fpi-data", fp_data, "fpi-data", fp_data,
NULL); NULL);
g_object_ref_sink (result);
} }
else else
{ {
@@ -875,8 +877,7 @@ fp_print_deserialize (const guchar *data,
return g_steal_pointer (&result); return g_steal_pointer (&result);
invalid_format: invalid_format:
*error = g_error_new_literal (G_IO_ERROR, g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
G_IO_ERROR_INVALID_DATA,
"Data could not be parsed"); "Data could not be parsed");
return FALSE; return NULL;
} }
-5
View File
@@ -80,11 +80,6 @@ typedef enum {
FpPrint *fp_print_new (FpDevice *device); FpPrint *fp_print_new (FpDevice *device);
FpPrint *fp_print_new_from_data (guchar *data,
gsize length);
gboolean fp_print_to_data (guchar **data,
gsize length);
const gchar *fp_print_get_driver (FpPrint *print); const gchar *fp_print_get_driver (FpPrint *print);
const gchar *fp_print_get_device_id (FpPrint *print); const gchar *fp_print_get_device_id (FpPrint *print);
FpImage *fp_print_get_image (FpPrint *print); FpImage *fp_print_get_image (FpPrint *print);
+1
View File
@@ -23,6 +23,7 @@
#if !GLIB_CHECK_VERSION (2, 57, 0) #if !GLIB_CHECK_VERSION (2, 57, 0)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GTypeClass, g_type_class_unref); G_DEFINE_AUTOPTR_CLEANUP_FUNC (GTypeClass, g_type_class_unref);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GEnumClass, g_type_class_unref); G_DEFINE_AUTOPTR_CLEANUP_FUNC (GEnumClass, g_type_class_unref);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GFlagsClass, g_type_class_unref);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GParamSpec, g_param_spec_unref); G_DEFINE_AUTOPTR_CLEANUP_FUNC (GParamSpec, g_param_spec_unref);
#else #else
/* Re-define G_SOURCE_FUNC as we are technically not allowed to use it with /* Re-define G_SOURCE_FUNC as we are technically not allowed to use it with
+1 -1
View File
@@ -1,5 +1,5 @@
project('libfprint', [ 'c', 'cpp' ], project('libfprint', [ 'c', 'cpp' ],
version: '1.90.5+tod1', version: '1.90.6+tod1',
license: 'LGPLv2.1+', license: 'LGPLv2.1+',
default_options: [ default_options: [
'buildtype=debugoptimized', 'buildtype=debugoptimized',
+23 -4
View File
@@ -22,6 +22,13 @@ template = FPrint.Print.new(d)
def enroll_progress(*args): def enroll_progress(*args):
print('enroll progress: ' + str(args)) print('enroll progress: ' + str(args))
def identify_done(dev, res):
global identified
identified = True
identify_match, identify_print = dev.identify_finish(res)
print('indentification_done: ', identify_match, identify_print)
assert identify_match.equal(identify_print)
# List, enroll, list, verify, identify, delete # List, enroll, list, verify, identify, delete
print("enrolling") print("enrolling")
p = d.enroll_sync(template, None, enroll_progress, None) p = d.enroll_sync(template, None, enroll_progress, None)
@@ -35,15 +42,27 @@ assert stored[0].equal(p)
print("verifying") print("verifying")
verify_res, verify_print = d.verify_sync(p) verify_res, verify_print = d.verify_sync(p)
print("verify done") print("verify done")
del p
assert verify_res == True assert verify_res == True
print("identifying")
identify_match, identify_print = d.identify_sync(stored) identified = False
print("identify done") deserialized_prints = []
assert identify_match.equal(identify_print) for p in stored:
deserialized_prints.append(FPrint.Print.deserialize(p.serialize()))
assert deserialized_prints[-1].equal(p)
del stored
print('async identifying')
d.identify(deserialized_prints, callback=identify_done)
del deserialized_prints
while not identified:
ctx.iteration(True)
print("deleting") print("deleting")
d.delete_print_sync(p) d.delete_print_sync(p)
print("delete done") print("delete done")
d.close_sync() d.close_sync()
del d del d
+107 -61
View File
@@ -109,6 +109,29 @@ auto_reset_device_class_cleanup (FpAutoResetClass *dev_class)
} }
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FpAutoResetClass, auto_reset_device_class_cleanup) G_DEFINE_AUTOPTR_CLEANUP_FUNC (FpAutoResetClass, auto_reset_device_class_cleanup)
static void
assert_equal_galleries (GPtrArray *g1,
GPtrArray *g2)
{
unsigned i;
g_assert ((g1 && g2) || (!g1 || !g1));
if (g1 == g2)
return;
g_assert_cmpuint (g1->len, ==, g2->len);
for (i = 0; i < g1->len; i++)
{
FpPrint *print = g_ptr_array_index (g1, i);
g_assert_true (g_ptr_array_find_with_equal_func (g2, print, (GEqualFunc)
fp_print_equal, NULL));
}
}
static void static void
on_device_notify (FpDevice *device, GParamSpec *spec, gpointer user_data) on_device_notify (FpDevice *device, GParamSpec *spec, gpointer user_data)
{ {
@@ -118,6 +141,43 @@ on_device_notify (FpDevice *device, GParamSpec *spec, gpointer user_data)
fake_dev->user_data = g_param_spec_ref (spec); fake_dev->user_data = g_param_spec_ref (spec);
} }
static FpPrint *
make_fake_print (FpDevice *device,
GVariant *print_data)
{
FpPrint *enrolled_print = fp_print_new (device);
fpi_print_set_type (enrolled_print, FPI_PRINT_RAW);
if (!print_data)
print_data = g_variant_new_string ("Test print private data");
g_object_set (G_OBJECT (enrolled_print), "fpi-data", print_data, NULL);
return enrolled_print;
}
static FpPrint *
make_fake_print_reffed (FpDevice *device,
GVariant *print_data)
{
return g_object_ref_sink (make_fake_print (device, print_data));
}
static GPtrArray *
make_fake_prints_gallery (FpDevice *device,
size_t size)
{
GPtrArray *array;
size_t i;
array = g_ptr_array_new_full (size, g_object_unref);
for (i = 0; i < size; i++)
g_ptr_array_add (array, make_fake_print_reffed (device, g_variant_new_uint64 (i)));
return array;
}
/* Tests */ /* Tests */
static void static void
@@ -703,7 +763,7 @@ test_driver_enroll_error_no_print (void)
"*Driver passed an error but also provided a print, returning error*"); "*Driver passed an error but also provided a print, returning error*");
fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); fake_dev->ret_error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL);
fake_dev->ret_print = fp_print_new (device); fake_dev->ret_print = make_fake_print_reffed (device, NULL);
g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print), g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print),
(gpointer) (&fake_dev->ret_print)); (gpointer) (&fake_dev->ret_print));
out_print = out_print =
@@ -794,7 +854,8 @@ test_driver_enroll_progress_vfunc (FpDevice *device)
expected_data->completed_stages = expected_data->completed_stages =
g_random_int_range (fp_device_get_nr_enroll_stages (device), G_MAXINT32); g_random_int_range (fp_device_get_nr_enroll_stages (device), G_MAXINT32);
expected_data->print = fp_print_new (device); expected_data->print = make_fake_print_reffed (device,
g_variant_new_int32 (expected_data->completed_stages));
expected_data->error = NULL; expected_data->error = NULL;
error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL); error = fpi_device_error_new (FP_DEVICE_ERROR_GENERAL);
@@ -855,6 +916,7 @@ typedef struct
gboolean called; gboolean called;
FpPrint *match; FpPrint *match;
FpPrint *print; FpPrint *print;
GPtrArray *gallery;
GError *error; GError *error;
} MatchCbData; } MatchCbData;
@@ -898,6 +960,14 @@ test_driver_match_cb (FpDevice *device,
if (match) if (match)
g_assert_no_error (error); g_assert_no_error (error);
/* Compar gallery if this is an identify operation */
if (data->gallery)
{
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
g_assert_false (fake_dev->action_data == data->gallery);
assert_equal_galleries (fake_dev->action_data, data->gallery);
}
} }
static void static void
@@ -905,7 +975,7 @@ test_driver_verify (void)
{ {
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
g_autoptr(FpPrint) enrolled_print = g_object_ref_sink (fp_print_new (device)); g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
g_autoptr(FpPrint) out_print = NULL; g_autoptr(FpPrint) out_print = NULL;
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
@@ -935,13 +1005,14 @@ test_driver_verify_fail (void)
{ {
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
g_autoptr(FpPrint) enrolled_print = g_object_ref_sink (fp_print_new (device)); g_autoptr(FpPrint) enrolled_print = NULL;
g_autoptr(FpPrint) out_print = NULL; g_autoptr(FpPrint) out_print = NULL;
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
gboolean match; gboolean match;
enrolled_print = make_fake_print_reffed (device, g_variant_new_uint64 (3));
fake_dev->ret_result = FPI_MATCH_FAIL; fake_dev->ret_result = FPI_MATCH_FAIL;
g_assert_true (fp_device_verify_sync (device, enrolled_print, NULL, g_assert_true (fp_device_verify_sync (device, enrolled_print, NULL,
test_driver_match_cb, match_data, test_driver_match_cb, match_data,
@@ -964,7 +1035,7 @@ test_driver_verify_retry (void)
{ {
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
g_autoptr(FpPrint) enrolled_print = g_object_ref_sink (fp_print_new (device)); g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
g_autoptr(FpPrint) out_print = NULL; g_autoptr(FpPrint) out_print = NULL;
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
@@ -992,7 +1063,7 @@ test_driver_verify_error (void)
{ {
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
g_autoptr(FpPrint) enrolled_print = g_object_ref_sink (fp_print_new (device)); g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
g_autoptr(FpPrint) out_print = NULL; g_autoptr(FpPrint) out_print = NULL;
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
@@ -1031,7 +1102,7 @@ test_driver_verify_not_reported (void)
dev_class->verify = fake_device_verify_immediate_complete; dev_class->verify = fake_device_verify_immediate_complete;
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
enrolled_print = g_object_ref_sink (fp_print_new (device)); enrolled_print = make_fake_print_reffed (device, NULL);
g_assert_true (fp_device_open_sync (device, NULL, NULL)); g_assert_true (fp_device_open_sync (device, NULL, NULL));
@@ -1074,7 +1145,7 @@ test_driver_verify_report_no_callback (void)
dev_class->verify = fake_device_verify_complete_error; dev_class->verify = fake_device_verify_complete_error;
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
fake_dev = FPI_DEVICE_FAKE (device); fake_dev = FPI_DEVICE_FAKE (device);
enrolled_print = g_object_ref_sink (fp_print_new (device)); enrolled_print = make_fake_print_reffed (device, NULL);
g_assert_true (fp_device_open_sync (device, NULL, NULL)); g_assert_true (fp_device_open_sync (device, NULL, NULL));
@@ -1114,7 +1185,7 @@ test_driver_verify_complete_retry (void)
dev_class->verify = fake_device_verify_complete_error; dev_class->verify = fake_device_verify_complete_error;
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
fake_dev = FPI_DEVICE_FAKE (device); fake_dev = FPI_DEVICE_FAKE (device);
enrolled_print = g_object_ref_sink (fp_print_new (device)); enrolled_print = make_fake_print_reffed (device, NULL);
g_assert_true (fp_device_open_sync (device, NULL, NULL)); g_assert_true (fp_device_open_sync (device, NULL, NULL));
@@ -1207,7 +1278,7 @@ test_driver_verify_complete_retry (void)
test_driver_match_data_clear (match_data); test_driver_match_data_clear (match_data);
fake_dev->ret_result = FPI_MATCH_ERROR; fake_dev->ret_result = FPI_MATCH_ERROR;
fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_TOO_SHORT); fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_TOO_SHORT);
fake_dev->ret_print = fp_print_new (device); fake_dev->ret_print = make_fake_print (device, NULL);
g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print), g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print),
(gpointer) (&fake_dev->ret_print)); (gpointer) (&fake_dev->ret_print));
@@ -1261,22 +1332,20 @@ test_driver_identify (void)
g_autoptr(FpPrint) print = NULL; g_autoptr(FpPrint) print = NULL;
g_autoptr(FpPrint) matched_print = NULL; g_autoptr(FpPrint) matched_print = NULL;
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref); g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 500);
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
FpPrint *expected_matched; FpPrint *expected_matched;
unsigned int i;
for (i = 0; i < 500; ++i)
g_ptr_array_add (prints, g_object_ref_sink (fp_print_new (device)));
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499)); expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
fp_print_set_description (expected_matched, "fake-verified"); fp_print_set_description (expected_matched, "fake-verified");
g_assert_true (fp_device_supports_identify (device)); g_assert_true (fp_device_supports_identify (device));
fake_dev->ret_print = fp_print_new (device); match_data->gallery = prints;
fake_dev->ret_print = make_fake_print (device, NULL);
g_assert_true (fp_device_identify_sync (device, prints, NULL, g_assert_true (fp_device_identify_sync (device, prints, NULL,
test_driver_match_cb, match_data, test_driver_match_cb, match_data,
&matched_print, &print, &error)); &matched_print, &print, &error));
@@ -1287,7 +1356,6 @@ test_driver_identify (void)
g_assert_true (match_data->print == print); g_assert_true (match_data->print == print);
g_assert (fake_dev->last_called_function == dev_class->identify); g_assert (fake_dev->last_called_function == dev_class->identify);
g_assert (fake_dev->action_data == prints);
g_assert_no_error (error); g_assert_no_error (error);
g_assert (print != NULL && print == fake_dev->ret_print); g_assert (print != NULL && print == fake_dev->ret_print);
@@ -1301,18 +1369,14 @@ test_driver_identify_fail (void)
g_autoptr(FpPrint) print = NULL; g_autoptr(FpPrint) print = NULL;
g_autoptr(FpPrint) matched_print = NULL; g_autoptr(FpPrint) matched_print = NULL;
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref); g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 500);
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
unsigned int i;
for (i = 0; i < 500; ++i)
g_ptr_array_add (prints, g_object_ref_sink (fp_print_new (device)));
g_assert_true (fp_device_supports_identify (device)); g_assert_true (fp_device_supports_identify (device));
fake_dev->ret_print = fp_print_new (device); fake_dev->ret_print = make_fake_print (device, NULL);
g_assert_true (fp_device_identify_sync (device, prints, NULL, g_assert_true (fp_device_identify_sync (device, prints, NULL,
test_driver_match_cb, match_data, test_driver_match_cb, match_data,
&matched_print, &print, &error)); &matched_print, &print, &error));
@@ -1337,15 +1401,11 @@ test_driver_identify_retry (void)
g_autoptr(FpPrint) print = NULL; g_autoptr(FpPrint) print = NULL;
g_autoptr(FpPrint) matched_print = NULL; g_autoptr(FpPrint) matched_print = NULL;
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref); g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 500);
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
FpPrint *expected_matched; FpPrint *expected_matched;
unsigned int i;
for (i = 0; i < 500; ++i)
g_ptr_array_add (prints, g_object_ref_sink (fp_print_new (device)));
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499)); expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
fp_print_set_description (expected_matched, "fake-verified"); fp_print_set_description (expected_matched, "fake-verified");
@@ -1375,15 +1435,11 @@ test_driver_identify_error (void)
g_autoptr(FpPrint) print = NULL; g_autoptr(FpPrint) print = NULL;
g_autoptr(FpPrint) matched_print = NULL; g_autoptr(FpPrint) matched_print = NULL;
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref); g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 500);
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
FpPrint *expected_matched; FpPrint *expected_matched;
unsigned int i;
for (i = 0; i < 500; ++i)
g_ptr_array_add (prints, g_object_ref_sink (fp_print_new (device)));
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499)); expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
fp_print_set_description (expected_matched, "fake-verified"); fp_print_set_description (expected_matched, "fake-verified");
@@ -1417,15 +1473,12 @@ test_driver_identify_not_reported (void)
{ {
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
g_autoptr(FpAutoCloseDevice) device = NULL; g_autoptr(FpAutoCloseDevice) device = NULL;
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref); g_autoptr(GPtrArray) prints = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
unsigned int i;
dev_class->identify = fake_device_identify_immediate_complete; dev_class->identify = fake_device_identify_immediate_complete;
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
prints = make_fake_prints_gallery (device, 500);
for (i = 0; i < 500; ++i)
g_ptr_array_add (prints, g_object_ref_sink (fp_print_new (device)));
g_assert_true (fp_device_open_sync (device, NULL, NULL)); g_assert_true (fp_device_open_sync (device, NULL, NULL));
@@ -1457,21 +1510,18 @@ static void
test_driver_identify_complete_retry (void) test_driver_identify_complete_retry (void)
{ {
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref); g_autoptr(GPtrArray) prints = NULL;
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
g_autoptr(FpAutoCloseDevice) device = NULL; g_autoptr(FpAutoCloseDevice) device = NULL;
g_autoptr(FpPrint) print = NULL; g_autoptr(FpPrint) print = NULL;
g_autoptr(FpPrint) match = NULL; g_autoptr(FpPrint) match = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
FpiDeviceFake *fake_dev; FpiDeviceFake *fake_dev;
int i;
dev_class->identify = fake_device_identify_complete_error; dev_class->identify = fake_device_identify_complete_error;
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
fake_dev = FPI_DEVICE_FAKE (device); fake_dev = FPI_DEVICE_FAKE (device);
prints = make_fake_prints_gallery (device, 500);
for (i = 0; i < 500; ++i)
g_ptr_array_add (prints, g_object_ref_sink (fp_print_new (device)));
g_assert_true (fp_device_open_sync (device, NULL, NULL)); g_assert_true (fp_device_open_sync (device, NULL, NULL));
@@ -1501,7 +1551,7 @@ test_driver_identify_complete_retry (void)
"*Driver reported a match to a print that was not in the gallery*"); "*Driver reported a match to a print that was not in the gallery*");
test_driver_match_data_clear (match_data); test_driver_match_data_clear (match_data);
fake_dev->ret_match = fp_print_new (device); fake_dev->ret_match = make_fake_print_reffed (device, NULL);
g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_match), g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_match),
(gpointer) (&fake_dev->ret_match)); (gpointer) (&fake_dev->ret_match));
g_assert_true (fp_device_identify_sync (device, prints, NULL, g_assert_true (fp_device_identify_sync (device, prints, NULL,
@@ -1525,7 +1575,7 @@ test_driver_identify_complete_retry (void)
test_driver_match_data_clear (match_data); test_driver_match_data_clear (match_data);
fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_REMOVE_FINGER); fake_dev->ret_error = fpi_device_retry_new (FP_DEVICE_RETRY_REMOVE_FINGER);
fake_dev->ret_match = prints->pdata[0]; fake_dev->ret_match = prints->pdata[0];
fake_dev->ret_print = fp_print_new (device); fake_dev->ret_print = make_fake_print (device, NULL);
g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print), g_object_add_weak_pointer (G_OBJECT (fake_dev->ret_print),
(gpointer) (&fake_dev->ret_print)); (gpointer) (&fake_dev->ret_print));
g_assert_false (fp_device_identify_sync (device, prints, NULL, g_assert_false (fp_device_identify_sync (device, prints, NULL,
@@ -1548,7 +1598,7 @@ test_driver_identify_report_no_callback (void)
{ {
g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class ();
g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1); g_autoptr(MatchCbData) match_data = g_new0 (MatchCbData, 1);
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref); g_autoptr(GPtrArray) prints = NULL;
g_autoptr(FpAutoCloseDevice) device = NULL; g_autoptr(FpAutoCloseDevice) device = NULL;
G_GNUC_UNUSED g_autoptr(FpPrint) enrolled_print = NULL; G_GNUC_UNUSED g_autoptr(FpPrint) enrolled_print = NULL;
g_autoptr(FpPrint) print = NULL; g_autoptr(FpPrint) print = NULL;
@@ -1559,7 +1609,8 @@ test_driver_identify_report_no_callback (void)
dev_class->identify = fake_device_identify_complete_error; dev_class->identify = fake_device_identify_complete_error;
device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
fake_dev = FPI_DEVICE_FAKE (device); fake_dev = FPI_DEVICE_FAKE (device);
enrolled_print = g_object_ref_sink (fp_print_new (device)); prints = make_fake_prints_gallery (device, 0);
enrolled_print = make_fake_print_reffed (device, NULL);
g_assert_true (fp_device_open_sync (device, NULL, NULL)); g_assert_true (fp_device_open_sync (device, NULL, NULL));
@@ -1686,15 +1737,10 @@ test_driver_list (void)
{ {
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 500);
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
unsigned int i;
for (i = 0; i < 500; ++i)
g_ptr_array_add (prints, fp_print_new (device));
fake_dev->ret_list = g_steal_pointer (&prints); fake_dev->ret_list = g_steal_pointer (&prints);
prints = fp_device_list_prints_sync (device, NULL, &error); prints = fp_device_list_prints_sync (device, NULL, &error);
@@ -1747,7 +1793,7 @@ test_driver_delete (void)
{ {
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
g_autoptr(FpPrint) enrolled_print = fp_print_new (device); g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
gboolean ret; gboolean ret;
@@ -1764,7 +1810,7 @@ test_driver_delete_error (void)
{ {
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
g_autoptr(FpPrint) enrolled_print = fp_print_new (device); g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
gboolean ret; gboolean ret;
@@ -1832,7 +1878,7 @@ test_driver_cancel (void)
device = auto_close_fake_device_new (); device = auto_close_fake_device_new ();
fake_dev = FPI_DEVICE_FAKE (device); fake_dev = FPI_DEVICE_FAKE (device);
cancellable = g_cancellable_new (); cancellable = g_cancellable_new ();
enrolled_print = fp_print_new (device); enrolled_print = make_fake_print_reffed (device, NULL);
fp_device_delete_print (device, enrolled_print, cancellable, fp_device_delete_print (device, enrolled_print, cancellable,
on_driver_cancel_delete, &completed); on_driver_cancel_delete, &completed);
@@ -1850,7 +1896,7 @@ test_driver_cancel_fail (void)
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new (); g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
g_autoptr(GCancellable) cancellable = g_cancellable_new (); g_autoptr(GCancellable) cancellable = g_cancellable_new ();
g_autoptr(FpPrint) enrolled_print = fp_print_new (device); g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device); FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
@@ -2084,8 +2130,8 @@ static void
test_driver_action_error_all (void) test_driver_action_error_all (void)
{ {
g_autoptr(FpAutoCloseDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); g_autoptr(FpAutoCloseDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
g_autoptr(FpPrint) enrolled_print = g_object_ref_sink (fp_print_new (device)); g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref); g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 0);
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
FpiDeviceFake *fake_dev; FpiDeviceFake *fake_dev;
@@ -2156,8 +2202,8 @@ static void
test_driver_action_error_fallback_all (void) test_driver_action_error_fallback_all (void)
{ {
g_autoptr(FpAutoCloseDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); g_autoptr(FpAutoCloseDevice) device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL);
g_autoptr(FpPrint) enrolled_print = g_object_ref_sink (fp_print_new (device)); g_autoptr(FpPrint) enrolled_print = make_fake_print_reffed (device, NULL);
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref); g_autoptr(GPtrArray) prints = make_fake_prints_gallery (device, 0);
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device); FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
FpiDeviceFake *fake_dev; FpiDeviceFake *fake_dev;
Executable → Regular
+3 -2
View File
@@ -87,10 +87,11 @@ try:
if os.path.exists(os.path.join(ddir, "custom.ioctl")): if os.path.exists(os.path.join(ddir, "custom.ioctl")):
custom() custom()
except: except Exception as e:
# Store created output files for inspection (in the build directory) # Store created output files for inspection (in the build directory)
outdir = os.path.join('errors', os.path.basename(ddir)) outdir = os.path.join('errors', os.path.basename(ddir))
shutil.copytree(tmpdir, outdir) shutil.copytree(tmpdir, outdir, dirs_exist_ok=True)
raise e
finally: finally:
shutil.rmtree(tmpdir) shutil.rmtree(tmpdir)