Skip to content

Commit

Permalink
riscv: add basic unit tests for mstatush
Browse files Browse the repository at this point in the history
Adds a basic unit-tests for the `mstatush` CSR.
  • Loading branch information
rmsyn committed Dec 18, 2024
1 parent 25511f7 commit ed2a9ea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions riscv/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Use CSR helper macros to define `misa` register
- Use CSR helper macros to define `mip` register
- Use CSR helper macros to define `mstatus` register
- Use CSR helper macros to define `mstatush` register

## [v0.12.1] - 2024-10-20

Expand Down
17 changes: 17 additions & 0 deletions riscv/src/register/mstatush.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,20 @@ pub unsafe fn set_mbe(endianness: Endianness) {
Endianness::LittleEndian => _clear(1 << 5),
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_mstatush() {
let mut m = Mstatush::from_bits(0);

[Endianness::LittleEndian, Endianness::BigEndian]
.into_iter()
.for_each(|endianness| {
test_csr_field!(m, sbe: endianness);
test_csr_field!(m, mbe: endianness);
});
}
}

0 comments on commit ed2a9ea

Please sign in to comment.