From 78fcfd3cd4c0cabe339e6e7d501d033ebfb3fe12 Mon Sep 17 00:00:00 2001 From: Leonardo Francisco Date: Sun, 12 Apr 2026 22:51:49 -0400 Subject: [PATCH] =?UTF-8?q?tests:=20revise=20comments=20=E2=80=94=20remove?= =?UTF-8?q?=20debug-finding=20language=20and=20issue=20tracking?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop 'Regression: Issue #N' / 'Bug #N' numbering, 'dead while loop', 'the old code', 'This catches the bug where' and similar changelog-style language from test comments. Keep concise descriptions of what each test validates. Also simplify data-loader test headers and the verify interrupt comment. --- libfprint/drivers/validity/validity_verify.c | 7 +- tests/test-validity.c | 142 +++++++------------ 2 files changed, 55 insertions(+), 94 deletions(-) diff --git a/libfprint/drivers/validity/validity_verify.c b/libfprint/drivers/validity/validity_verify.c index 0adf6506..e083645e 100644 --- a/libfprint/drivers/validity/validity_verify.c +++ b/libfprint/drivers/validity/validity_verify.c @@ -98,10 +98,9 @@ verify_interrupt_cb (FpiUsbTransfer *transfer, int_type, transfer->actual_length); } - /* During match wait, type 3 = match found, anything else = no match. - * python-validity treats any interrupt type != 3 as "finger not recognized" - * and skips cmd 0x60 (get_match_result), going straight to cleanup. - * The sensor only sends one interrupt, so waiting for another hangs. */ + /* Match result: type 3 = match found, anything else = no match. + * On no-match, skip cmd 0x60 (get_match_result) and go to cleanup; + * the sensor only sends one interrupt per match attempt. */ if (fpi_ssm_get_cur_state (ssm) == VERIFY_WAIT_MATCH_INT) { if (int_type == 3) diff --git a/tests/test-validity.c b/tests/test-validity.c index 91650c16..a8026edd 100644 --- a/tests/test-validity.c +++ b/tests/test-validity.c @@ -1377,7 +1377,7 @@ test_reboot_cmd_format (void) } /* ================================================================ - * Regression: fwext_file_clear on already-cleared struct + * fwext_file_clear on already-cleared struct * * Double-free guard. * ================================================================ */ @@ -2149,9 +2149,8 @@ build_match_payload (guint32 user_dbid, /* ================================================================ * R1: parse_match_result with valid TLV data * - * Regression: Issue #1 — dead while loop would never extract fields. * Verifies that user_dbid, subtype, and hash are correctly parsed - * from a TLV dictionary matching python-validity's parse_dict() format. + * from a TLV dictionary. * ================================================================ */ static void test_parse_match_result_valid (void) @@ -2176,11 +2175,10 @@ test_parse_match_result_valid (void) } /* ================================================================ - * R1b: parse_match_result iterates ALL TLV entries + * R1b: parse_match_result iterates all TLV entries * - * Regression: The dead while loop would break after first entry. - * Build a dict with tag 3 (subtype) BEFORE tag 1 (user_dbid) to - * ensure the parser doesn't stop after the first entry. + * Tags appear in non-sequential order (tag 3 before tag 1) to + * verify the parser processes every entry, not just the first. * ================================================================ */ static void test_parse_match_result_multi_tags (void) @@ -2223,7 +2221,7 @@ test_parse_match_result_multi_tags (void) /* ================================================================ * R1c: parse_match_result with empty dict (no match) * - * Regression: A no-match scenario should return ok=TRUE but matched=FALSE. + * A no-match scenario should return ok=TRUE but matched=FALSE. * ================================================================ */ static void test_parse_match_result_empty (void) @@ -2304,11 +2302,10 @@ test_parse_match_result_unknown_tags (void) } /* ================================================================ - * R2: validity_db_build_identity rejects NULL + * R2: validity_db_build_identity rejects NULL user_id * - * Regression: Issue #2 — NULL user_id was passed to build_identity - * which would then be passed to g_variant_new_string(NULL) → crash. - * The guard should return NULL. + * A NULL user_id must return NULL instead of crashing in + * g_variant_new_string(). * ================================================================ */ static void test_build_identity_null (void) @@ -2331,8 +2328,8 @@ test_build_identity_null (void) /* ================================================================ * R2b: validity_db_build_identity with valid UUID * - * Regression: Ensures UUID → identity bytes works correctly - * (complementary to the NULL test above). + * UUID → identity bytes round-trip (complementary to the NULL + * test above). * ================================================================ */ static void test_build_identity_valid_uuid (void) @@ -2357,8 +2354,8 @@ test_build_identity_valid_uuid (void) /* ================================================================ * R3: Gallery matching by subtype * - * Regression: Issue #3 — identify always returned first gallery print - * regardless of actual subtype. Now it should match by finger subtype. + * Identify must match by finger subtype, not just return the + * first gallery entry. * ================================================================ */ static void test_gallery_match_by_subtype (void) @@ -2432,10 +2429,9 @@ test_gallery_match_empty (void) } /* ================================================================ - * R4: enroll_user_dbid field exists separately from delete_storage_dbid + * R4: enroll_user_dbid and delete_storage_dbid are separate fields * - * Regression: Issue #4 — delete_storage_dbid was abused for enrollment. - * This compile-time test verifies both fields exist independently. + * Both fields must exist independently in the device struct. * ================================================================ */ static void test_struct_separate_fields (void) @@ -2458,10 +2454,7 @@ test_struct_separate_fields (void) /* ================================================================ * R5: del_record command format * - * Regression: Issue #5 — delete SSM never sent del_record cmd. * Verify cmd 0x48 produces correct format: 0x48 | dbid(2LE). - * (This already exists in test-validity-db.c but we double-check - * the format critical for delete functionality.) * ================================================================ */ static void test_del_record_format (void) @@ -2476,10 +2469,9 @@ test_del_record_format (void) } /* ================================================================ - * R6: match_finger command is exactly 13 bytes (single allocation) + * R6: match_finger command is exactly 13 bytes * - * Regression: Issue #6 — build_cmd_match_finger allocated 12 bytes, - * freed, then re-allocated 13 bytes. Now single allocation. + * build_cmd_match_finger must produce a single 13-byte buffer. * ================================================================ */ static void test_match_finger_size (void) @@ -2504,8 +2496,7 @@ test_match_finger_size (void) /* ================================================================ * R7: Clear storage SSM states exist * - * Regression: Issue #7 — clear_storage was a stub returning NOT_SUPPORTED. - * Verify the CLEAR_* enum states exist (compile-time regression test). + * CLEAR_* enum states must be defined for clear_storage to work. * ================================================================ */ static void test_clear_storage_states_exist (void) @@ -2968,12 +2959,10 @@ test_unwrap_invalid (void) } /* ================================================================ - * Regression: Bug #1 — Flash parse requires PSK for private key + * Flash parse requires PSK before private key decryption * - * Private key block (ID 4) is encrypted with PSK. Calling parse_flash - * without first deriving PSK must fail (HMAC mismatch), proving the - * ordering dependency. This catches the bug where flash_read SSM - * parsed flash data BEFORE PSK derivation had occurred. + * Private key block (ID 4) is encrypted with PSK. parse_flash + * without prior PSK derivation must fail (HMAC mismatch). * ================================================================ */ static void test_flash_parse_needs_psk (void) @@ -2996,11 +2985,11 @@ test_flash_parse_needs_psk (void) * We use a minimal cert (just 16 bytes of dummy data) and a privkey block * that's encrypted with the proper PSK. */ - /* Step 1: Build a cert body */ + /* Build a cert body */ guint8 cert_body[16]; memset (cert_body, 0xAA, sizeof (cert_body)); - /* Step 2: Build a private-key body encrypted with PSK */ + /* Build a private-key body encrypted with PSK */ guint8 priv_plaintext[96]; /* d(32) + pad for block alignment */ memset (priv_plaintext, 0xBB, sizeof (priv_plaintext)); @@ -3085,12 +3074,10 @@ test_flash_parse_needs_psk (void) } /* ================================================================ - * Regression: Bug #2 — READ_FLASH command format + * READ_FLASH command format * - * The READ_FLASH command must be exactly 13 bytes matching - * python-validity: pack('