Skip to content

Commit

Permalink
riscv: add basic sip unit tests
Browse files Browse the repository at this point in the history
Adds basic unit tests for the `sip` CSR.
  • Loading branch information
rmsyn committed Feb 11, 2025
1 parent 0701ac8 commit a093eb8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions riscv/src/register/sip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,20 @@ clear!(0x144);
set_clear_csr!(
/// Supervisor Software Interrupt Pending
, set_ssoft, clear_ssoft, 1 << 1);

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

#[test]
fn test_sip() {
let mut sip = Sip::from_bits(0);

test_csr_field!(sip, ssoft);
assert!(!sip.stimer());
assert!(!sip.sext());

assert!(Sip::from_bits(1 << 5).stimer());
assert!(Sip::from_bits(1 << 9).sext());
}
}

0 comments on commit a093eb8

Please sign in to comment.