Intrepid/Prometeu/Runtime/pipeline/head This commit looks good
Confirm loaded PBX identity, emit bounded fault envelopes and retain the primary crash report through teardown. Start background IO before audio initialization and update native protocol and process fixtures.
57 lines
2.3 KiB
Rust
57 lines
2.3 KiB
Rust
use prometeu_host_desktop_winit::studio::wire::*;
|
|
|
|
#[test]
|
|
fn rgba_fixture_pins_channel_order_and_metadata() {
|
|
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
|
.join("../../../devtools/studio-protocol/fixtures/rgba.hex");
|
|
let bytes: Vec<u8> = std::fs::read_to_string(path)
|
|
.unwrap()
|
|
.split_whitespace()
|
|
.map(|s| u8::from_str_radix(s, 16).unwrap())
|
|
.collect();
|
|
let m = Reader::new(bytes.as_slice()).receive().unwrap();
|
|
assert_eq!(m.header.kind, FRAME);
|
|
assert_eq!(m.header.length, 56);
|
|
assert_eq!(&m.payload[..16], &(0u8..16).collect::<Vec<_>>());
|
|
assert_eq!(
|
|
&m.payload[48..],
|
|
&[0xff0000ffu32.to_be_bytes(), 0x0000ff80u32.to_be_bytes()].concat()
|
|
);
|
|
assert_eq!(frame_bytes(2, 1, 2).unwrap() + FRAME_METADATA_BYTES, m.payload.len());
|
|
}
|
|
|
|
#[test]
|
|
fn bootstrap_rejects_wrong_roles_lengths_and_ports() {
|
|
let mut p = vec![0; 85];
|
|
p[48..50].copy_from_slice(&1234u16.to_le_bytes());
|
|
p[50..52].copy_from_slice(&1235u16.to_le_bytes());
|
|
p[52] = 1;
|
|
p[53..85].fill(0xab);
|
|
let mut bytes = Vec::new();
|
|
Writer::new(&mut bytes).send(BOOTSTRAP, 0, &p).unwrap();
|
|
let boot = Bootstrap::read(bytes.as_slice()).unwrap();
|
|
assert!(boot.disposable);
|
|
assert_eq!(boot.program_sha256, [0xab; 32]);
|
|
assert_eq!(boot.hello(1).len(), 49);
|
|
p[50..52].copy_from_slice(&1234u16.to_le_bytes());
|
|
bytes.clear();
|
|
Writer::new(&mut bytes).send(BOOTSTRAP, 0, &p).unwrap();
|
|
assert!(Bootstrap::read(bytes.as_slice()).is_err());
|
|
}
|
|
|
|
#[test]
|
|
fn v2_fault_fixture_preserves_unsigned_pc_span_and_unicode() {
|
|
let hex = include_str!("../../../../devtools/studio-protocol/fixtures/fault.hex");
|
|
let bytes: Vec<_> =
|
|
hex.split_whitespace().map(|s| u8::from_str_radix(s, 16).unwrap()).collect();
|
|
let m = Reader::new(bytes.as_slice()).receive_control().unwrap();
|
|
assert_eq!(m.header.kind, FAULT);
|
|
let value: serde_json::Value = serde_json::from_slice(&m.payload).unwrap();
|
|
assert_eq!(value["fault"]["pc"], u32::MAX);
|
|
assert_eq!(value["fault"]["trap"]["span"]["file_id"], 7);
|
|
assert!(value["fault"]["summary"].as_str().unwrap().contains("ação"));
|
|
let mut old: [u8; 32] = bytes[..32].try_into().unwrap();
|
|
old[4] = 1;
|
|
assert!(Header::decode(&old).unwrap_err().to_string().contains("required 2.0"));
|
|
}
|