diff --git a/irp/src/build_bpf.rs b/irp/src/build_bpf.rs index b4fd867..fc4ac03 100644 --- a/irp/src/build_bpf.rs +++ b/irp/src/build_bpf.rs @@ -1042,7 +1042,7 @@ impl<'a> Builder<'a> { self.decoder_state_ty, self.decoder_state, e.offset as u32, - name, + &format!("{name}_ptr"), ) .unwrap(), e.value.unwrap(), diff --git a/irp/tests/bpf_decoding.rs b/irp/tests/bpf_decoding.rs index d938e9b..899d0aa 100644 --- a/irp/tests/bpf_decoding.rs +++ b/irp/tests/bpf_decoding.rs @@ -90,7 +90,8 @@ fn decode_all() { let mut decodes = bpf_decode(&dfa, &options, &protocol.name, &msg); - let mut ok = true; + // if nothing decoded, we fail to decode + let mut ok = !decodes.is_empty(); while let Some(code) = decodes.pop() { let mut received = code; @@ -160,7 +161,7 @@ fn decode_all() { failing_protocols.len() ); - assert!((52..=61).contains(&fails)); + assert_eq!(failing_protocols.len(), 39); } fn bpf_decode(dfa: &DFA, options: &Options, name: &str, message: &Message) -> Vec { @@ -250,7 +251,10 @@ fn bpf_decode(dfa: &DFA, options: &Options, name: &str, message: &Message) -> Ve ) }; - println!("executing {raw} {vars}"); + println!( + "executing {}{raw} {vars}", + if i.is_even() { '-' } else { '+' } + ); let ret = vm.execute_program(mbuff, &context.sample).unwrap(); assert_eq!(ret, 0); diff --git a/irp/tests/tests.rs b/irp/tests/tests.rs index b7dc68f..27df8b8 100644 --- a/irp/tests/tests.rs +++ b/irp/tests/tests.rs @@ -2,7 +2,10 @@ use irp::{Decoder, Event, InfraredData, Irp, Message, Options, Protocol, Vartabl use irptransmogrifier::{create_jvm, IrpTransmogrifierRender}; use itertools::Itertools; use rand::Rng; -use std::{collections::HashMap, path::PathBuf}; +use std::{ + collections::{HashMap, HashSet}, + path::PathBuf, +}; #[test] fn test() { @@ -423,16 +426,17 @@ fn compare_encode_to_transmogrifier() { #[test] fn decode_all() { - let protocols = Protocol::parse(&PathBuf::from( + let mut protocols = Protocol::parse(&PathBuf::from( "tests/IrpTransmogrifier/src/main/resources/IrpProtocols.xml", )) .unwrap(); let mut total_tests = 0; let mut fails = 0; + let mut failed_protocols: HashSet<&str> = HashSet::new(); let mut rng = rand::thread_rng(); - for mut protocol in protocols { + for protocol in &mut protocols { println!("trying {}", protocol.name); if protocol.name == "NEC-Shirriff" { @@ -496,6 +500,7 @@ fn decode_all() { let mut decodes = Vec::new(); for data in InfraredData::from_u32_slice(&msg.raw) { + // TODO: fix DFA decoding here decoder.nfa_input(data, &nfa, |ev, res| decodes.push((ev, res))); } @@ -538,6 +543,8 @@ fn decode_all() { if params == res { ok = true; + } else { + failed_protocols.insert(&protocol.name); } } @@ -563,6 +570,7 @@ fn decode_all() { } println!("tests: {total_tests} fails: {fails}"); + println!("Failed protocols: {failed_protocols:?}"); assert_eq!(fails, 0); }