Skip to content

[cov] Add corner case unit tests for uncovered code #27652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: earlgrey_1.0.0
Choose a base branch
from

Conversation

sasdf
Copy link
Contributor

@sasdf sasdf commented Jul 18, 2025

This change introduces new unit tests for currently uncovered code, primarily targeting corner-case branches that are difficult to reach through standard functional tests.

Each commit is self-contained and functionally independent.
They have been grouped into a single pull request due to their small individual size
(each adding fewer than three test cases).

sasdf added 10 commits July 18, 2025 11:29
Change-Id: I54d98cea81a3a55f84490a55109b1eee23c96785
Signed-off-by: Yi-Hsuan Deng <yhdeng@google.com>
This commit adds a cc_library `dbg_print_unittest_variant`, which is a
variant of the `dbg_print` library built with `DBG_PRINT_UNIT_TEST_`
defined.

The existing `dbg_print_unittest` is modified to depend on
`dbg_print_unittest_variant` rather than directly including the source files.

This change enables coverage to be collected for the `dbg_print` module in the
unit tests, since test sources are by default uninstrumented.

Change-Id: Ifd9cdc950a6ca92bf91e84b538426436d6ce20e1
Signed-off-by: Yi-Hsuan Deng <yhdeng@google.com>
Adds test cases for the `%p` format specifier in `dbg_print` unit tests,
which were previously uncovered.

Change-Id: I55ce3151f573b251910885342f493995bbe45f0c
Signed-off-by: Yi-Hsuan Deng <yhdeng@google.com>
This commit adds two corner cases to cert unittest:
  - When the certificate is zeroed out, expect the decode size function to return 0.
  - When the buffer for `cert_x509_asn1_check_serial_number` is too small, expect `kErrorCertInvalidSize` and `kHardenedBoolFalse` to be returned.

Change-Id: If99c3fb37c96b1bdfe3a43073d7824861e8426a0
Signed-off-by: Yi-Hsuan Deng <yhdeng@google.com>
Add a unittest for `alert_configure()` and `alert_local_configure()` with
`kAlertEnableNone` option for uncovered code.

Change-Id: I949004f9355c5b7f1ecde0f731a777af583afe05
Signed-off-by: Yi-Hsuan Deng <yhdeng@google.com>
This change adds a unittest to verify that the flash controller init
routine correctly applies the `FLASH_HW_INFO_CFG_OVERRIDE` OTP setting.

It ensures that if this OTP setting is programmed to a non-zero value,
the corresponding flash_ctrl register is updated accordingly.

Change-Id: I691d417f9cc1b65d291c4d3888462820cd9764db
Signed-off-by: Yi-Hsuan Deng <yhdeng@google.com>
This change adds two new corner cases for manifest checks in `manifest_unittest.cc`:
- Checks for an invalid major version of the manifest.
- Checks if the signed region extends outside the image boundary.

Change-Id: I48ea1639e507ceac18e52e7d2ec4bcfc579fbb77
Signed-off-by: Yi-Hsuan Deng <yhdeng@google.com>
This change adds two new tests to verify `isfb_info_flash_erase_policy_get()`.

The first test `ErasePolicyOwnershipIsfbNotPreset` validates the `kErrorOwnershipISFBNotPresent` error return when ISFB is not present.

The second test `ErasePolicyDisableExpectedCheck` verifies that the function correctly sets `erase_en` to `kHardenedBoolTrue` when all expected checks are disabled.

Change-Id: Iff0fde59efe10617486d4c5ff6f51d868aefd0b9
Signed-off-by: Yi-Hsuan Deng <yhdeng@google.com>
This adds new tests for `ownership_init()` to check its behavior when the
ownership info pages are corrupted.

Change-Id: Ifd04ef920a967b5d39cb793e7d9348d0f561348b
Signed-off-by: Yi-Hsuan Deng <yhdeng@google.com>
…y_point

This change adds two new unit tests to `rom_ext_boot_policy_unittest`:
- `ManifestCheckBadSignedRegion`: Verifies that `rom_ext_boot_policy_manifest_check` correctly returns `kErrorManifestBadSignedRegion` when `signed_region_end` is out of range.
- `ManifestCheckBadEntryPoint`: Verifies that `rom_ext_boot_policy_manifest_check` correctly returns `kErrorManifestBadEntryPoint` when `entry_point` is outside the valid code region.

Change-Id: Ie83c08b5a935e9bca72cbfca6f33637d194dd1a0
Signed-off-by: Yi-Hsuan Deng <yhdeng@google.com>
@sasdf sasdf marked this pull request as ready for review July 18, 2025 09:57
@sasdf sasdf requested a review from a team as a code owner July 18, 2025 09:57
@moidx moidx removed the request for review from a team July 22, 2025 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant