Skip to content

Commit a093eb8

Browse files
committed
riscv: add basic sip unit tests
Adds basic unit tests for the `sip` CSR.
1 parent 0701ac8 commit a093eb8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

riscv/src/register/sip.rs

+17
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,20 @@ clear!(0x144);
3030
set_clear_csr!(
3131
/// Supervisor Software Interrupt Pending
3232
, set_ssoft, clear_ssoft, 1 << 1);
33+
34+
#[cfg(test)]
35+
mod tests {
36+
use super::*;
37+
38+
#[test]
39+
fn test_sip() {
40+
let mut sip = Sip::from_bits(0);
41+
42+
test_csr_field!(sip, ssoft);
43+
assert!(!sip.stimer());
44+
assert!(!sip.sext());
45+
46+
assert!(Sip::from_bits(1 << 5).stimer());
47+
assert!(Sip::from_bits(1 << 9).sext());
48+
}
49+
}

0 commit comments

Comments
 (0)