use super::*;
#[test]
fn encap_stop() {
let mut decoder = Builder::new().decoder(b"\x00\x00\x00\x00");
for _ in 0..4 {
assert_eq!(
decoder.decode_encap_packet(),
Ok(encap::Packet::NullIdle { flow: 0 }),
);
}
assert_eq!(decoder.bytes_left(), 0, "Not at end of buffer");
assert_eq!(
decoder.decode_encap_packet(),
Err(Error::InsufficientData(NonZeroUsize::MIN)),
);
}
bitstream_test!(
normal_support,
b"\xC9\x31\x8D\x73\x00\x00\x00\x00\x19\x41\x00\x08",
encap::Packet::from(
encap::Normal::new(
2,
0x31,
payload::Payload::InstructionTrace(
sync::Start {
branch: true,
ctx: sync::Context {
privilege: types::Privilege::Machine,
time: None,
context: 0,
},
address: 536937572
}
.into()
)
)
.with_timestamp(0x8D)
),
params(&PARAMS_32),
timestamp_width(1),
hart_index_width(8)
);
bitstream_test!(
normal_support_small_srcid,
b"\xCA\xD3\x38\x07\x00\x00\x00\x90\x11\x04\x80\x00",
encap::Packet::from(
encap::Normal::new(
2,
3,
payload::Payload::InstructionTrace(
sync::Start {
branch: true,
ctx: sync::Context {
privilege: types::Privilege::Machine,
time: None,
context: 0,
},
address: 536937572
}
.into()
)
)
.with_timestamp(0x8D)
),
params(&PARAMS_32),
timestamp_width(1),
hart_index_width(4)
);
bitstream_test!(
null_idle,
b"\x20",
encap::Packet::<payload::Payload>::NullIdle { flow: 1 },
params(&PARAMS_32),
hart_index_width(8)
);
bitstream_test!(
null_align,
b"\xE0",
encap::Packet::<payload::Payload>::NullAlign { flow: 3 },
params(&PARAMS_32),
timestamp_width(1)
);