Skip to content

Conversation

@fsammoura1980
Copy link
Contributor

This commit introduces a suite of unit tests for the pmp_decode_region function using the Ztest framework. The tests validate the correct calculation of start and end addresses for various RISC-V PMP (Physical Memory Protection) entry configurations.

The following scenarios are covered:

  • TOR (Top of Range) mode for index 0.
  • TOR (Top of Range) mode for index > 0.
  • NA4 (Naturally Aligned Four-byte) mode.
  • NAPOT (Naturally Aligned Power-of-Two) mode.
  • Default behavior for a disabled PMP entry.

These tests ensure the PMP region decoding logic is accurate across different addressing modes.

@zephyrbot zephyrbot added area: Tests Issues related to a particular existing or missing test area: RISCV RISCV Architecture (32-bit & 64-bit) labels Nov 17, 2025
PMP_R | PMP_W | PMP_X, result);
}

ZTEST(riscv_pmp_memattr_entries, test_pmp_tor_index_0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the tests! They don't seem to be related to the mem-attr property per se, so I'd prefer them to be moved to a separate test under tests/arch/riscv/pmp.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

This commit introduces a suite of unit tests for the `pmp_decode_region`
function using the Ztest framework. The tests validate the correct
calculation of start and end addresses for various RISC-V PMP
(Physical Memory Protection) entry configurations.

The following scenarios are covered:
- TOR (Top of Range) mode for index 0.
- TOR (Top of Range) mode for index > 0.
- NA4 (Naturally Aligned Four-byte) mode.
- NAPOT (Naturally Aligned Power-of-Two) mode.
- Default behavior for a disabled PMP entry.

These tests ensure the PMP region decoding logic is accurate across
different addressing modes.

Signed-off-by: Firas Sammoura <[email protected]>
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: RISCV RISCV Architecture (32-bit & 64-bit) area: Tests Issues related to a particular existing or missing test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants