Commit 91ebdde
committed
tests: riscv: pmp: Make permission change tests dynamic
The existing PMP permission tests relied on hardcoded region indices
(e.g., index 0 or 2). This makes the tests fragile and dependent
on the exact memory attribute region setup.
This change refactors the tests to dynamically determine region counts
and indices based on the output of `mem_attr_get_regions()`:
- `test_pmp_change_perm_invalid_permission`: Uses the last valid
region index to test invalid permission flags.
- `test_pmp_change_perm_invalid_region_index`: Uses the total number
of regions as the out-of-bounds index.
- `test_successful_permission_change`: Locates the index of the
target test region (`dt_regions[0]`) by matching its base address
and size. The test now also inverts the X bit of the current
permissions to ensure a change is applied and verified.
These changes make the tests more robust and less dependent on a
specific static configuration.
Signed-off-by: Firas Sammoura <[email protected]>1 parent 8f0df40 commit 91ebdde
1 file changed
+35
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
130 | 134 | | |
131 | | - | |
| 135 | + | |
132 | 136 | | |
133 | 137 | | |
134 | 138 | | |
135 | 139 | | |
136 | 140 | | |
137 | | - | |
138 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
139 | 144 | | |
140 | | - | |
| 145 | + | |
141 | 146 | | |
142 | 147 | | |
143 | 148 | | |
144 | 149 | | |
145 | 150 | | |
146 | | - | |
147 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
148 | 162 | | |
149 | | - | |
150 | | - | |
| 163 | + | |
| 164 | + | |
151 | 165 | | |
152 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
153 | 169 | | |
154 | | - | |
| 170 | + | |
| 171 | + | |
155 | 172 | | |
156 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
157 | 177 | | |
158 | 178 | | |
159 | 179 | | |
| |||
192 | 212 | | |
193 | 213 | | |
194 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
195 | 219 | | |
196 | 220 | | |
197 | 221 | | |
0 commit comments