// SPDX-License-Identifier: MIT //! Run Acid5200 standalone tests (a5200-python's `acid.py` `main`, at cf82d44). //! //! a5200-acid [TEST-OR-PREFIX...] [--dir D] [--frames N] [--text] [--fault NAME]... //! [--switch NAME=0|1]... [--full] //! //! The ROMs are read in place from `--dir`, else `$ACID5200_DIR`, else the reference checkout's //! fetched copies beside this repository. Board switches: `nmi_lost_on_p_push`, //! `gtia_at_d000`; faults: `drop_dummy_read`, `steal_one_short`. use std::path::PathBuf; use a5200::acid::{all_tests, default_dir, run_full, run_test}; use a5200::Console; fn main() { let args: Vec = std::env::args().skip(1).collect(); let mut tests = Vec::new(); let mut dir: PathBuf = default_dir(); let mut frames = 1500u64; let mut text = false; let mut faults: Vec = Vec::new(); let mut switches: Vec = Vec::new(); let mut full = false; let mut i = 0; while i < args.len() { let a = args[i].as_str(); let mut value = || { i += 1; args[i].clone() }; match a { "--dir" => dir = value().into(), "--frames" => frames = value().parse().unwrap(), "--text" => text = true, "--fault" => faults.push(value()), "--switch" => switches.push(value()), "--full" => full = true, _ => tests.push(a.to_string()), } i += 1; } if full { let (screen, frames) = run_full(&dir, 6000).unwrap(); println!("{screen}"); println!("[{frames} frames]"); std::process::exit(if screen.contains("Failed: 0") { 0 } else { 1 }); } let mut names = all_tests(&dir); if !tests.is_empty() { names.retain(|n| tests.iter().any(|t| n == t || n.starts_with(t.as_str()))); } let mut hook = |console: &mut Console| { let board = console.board_mut(); for fault in &faults { match fault.as_str() { "drop_dummy_read" => board.faults.insert("drop_dummy_read"), "steal_one_short" => board.faults.insert("steal_one_short"), other => panic!("no board fault {other:?}"), }; } for item in &switches { let (name, value) = item.split_once('=').unwrap_or((item, "1")); let on = value.parse::().unwrap_or(1) != 0; match name { "nmi_lost_on_p_push" => board.nmi_lost_on_p_push = on, "gtia_at_d000" => board.gtia_at_d000 = on, other => { eprintln!("no board switch {other:?}"); std::process::exit(2) } } } }; let mut passed = 0; for name in &names { let result = run_test(name, &dir, frames, Some(&mut hook)).unwrap(); passed += (result.verdict == "pass") as usize; println!("{result} [{:.2}s]", result.seconds); if text { println!("{}", result.text); } } println!("{passed}/{} pass", names.len()); std::process::exit(if passed == names.len() { 0 } else { 1 }); }