{"data":{"slug":"discovered-dd69aa9b4cc56b5872486d0bdff2252696d3428303d3c4a3","title":"Test Case Porting Guide (mbedTLS v3 to v4)","summary":"Port test cases from mbedTLS v3 to v4 by identifying missing tests, copying helper functions, migrating API types, and updating the test runner. Deliverable includes a checklist for ensuring compatibility and completeness.","url":"https:\/\/skillshunter.net\/skills\/discovered-dd69aa9b4cc56b5872486d0bdff2252696d3428303d3c4a3","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-dd69aa9b4cc56b5872486d0bdff2252696d3428303d3c4a3","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-dd69aa9b4cc56b5872486d0bdff2252696d3428303d3c4a3.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-dd69aa9b4cc56b5872486d0bdff2252696d3428303d3c4a3\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Ensure that the `diff` and `wc -l` commands are run on sorted `TEST(` names. Before copying helpers, use `grep -n \"^psa_status_t <name>\"` to locate and copy both declarations and definitions. The first deliverable is a checklist confirming all tests and helpers are ported and the runner is updated.","instructions":"---\nname: test-case-porting-checklist\ndescription: Checklist for porting test cases between mbedTLS v3 and v4 (helper functions, API type changes, runner updates). Use when a ported test fails to link or is missing from the runner.\nmetadata:\n  type: feedback\n  compacted: 2026-11-01\n---\n\n# Test case porting checklist (v3 <-> v4)\n\n## Steps\n1. **Find missing tests.** Compare the TG files with `diff` on the sorted `TEST(` names. Check `wc -l` for both sides.\n2. **Copy helpers, not just `TEST()`.** Tests call helpers such as `cipher_example_*`. Find them with `grep -n \"^psa_status_t <name>\"` and copy the declaration and the definition. Put them before the tests that use them. Search by name, never by position.\n3. **Migrate API types while copying:**\n\n| v3 | v4 |\n|---|---|\n| `psa_key_handle_t` | `psa_key_id_t` |\n| `PSA_KEY_LIFETIME_IS_PERSISTENT(l)` | `(!PSA_KEY_LIFETIME_IS_VOLATILE(l))` |\n| `psa_open_key()` | `psa_get_key_attributes()` (error `PSA_ERROR_INVALID_HANDLE`) |\n| `mbedtls_pk_parse_key()` 7 args | 5 args (drop `f_rng`, `p_rng`) |\n\n4. **Update the runner.** Add `RUN_TEST_CASE()` in `psa_crypto_tests_runner.c` after the related tests, in the file's existing order.\n5. **Verify.** Count `TEST(PSA_CRYPTO_TG` and `RUN_TEST_CASE` on both sides. Check that every `^psa_status_t` helper exists.\n\n## Pitfalls\n- Copying only `TEST()` leaves link errors (missing helpers).\n- Position-based searches miss tests. Search by name.\n- Forgetting the type migration compiles but can fail at runtime.\n- A test without a runner entry never runs, and nobody notices.\n\n## Reference case\nTG2 GCM: v3 had 25 AES tests and v4 had 23. The two missing were `TC_API_AESEncryptDecryptGCM_MultiPart` and `_ShortenedTag`. Their helpers were `cipher_example_encrypt_decrypt_aes_gcm_multipart_known_result` and the shortened-tag equivalent.\n","use_cases":["Porting test cases between mbedTLS v3 and v4","Identifying and resolving missing helper functions during test migration","Updating test runners to include new test cases","Verifying test case completeness and compatibility after migration"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/minhnguyenyf\/skills\/blob\/7213d81500a27f3a96028144f5342ccfe4efbe4a\/psa\/test-case-porting-guide\/SKILL.md","source_commit":"7213d81500a27f3a96028144f5342ccfe4efbe4a","license":null,"version":null,"listing_approved_at":"2026-11-30","created_at":"2026-11-29T11:12:22.000000Z","updated_at":"2026-11-30T06:52:26.000000Z","seo_title":"Test Case Porting Guide for mbedTLS v3 to v4","seo_description":"A detailed guide for porting test cases from mbedTLS v3 to v4, including steps for finding missing tests, copying helper functions, migrating API types, and updating the\u8dd1","seo_keywords":["mbedTLS test case porting","test case migration checklist","mbedTLS v3 to v4","test helper function copying","API type migration","test runner update"]}}