From c4a99245e3a435dd39b77c0934bab70ce5fadce9 Mon Sep 17 00:00:00 2001 From: transistor Date: Sun, 11 Sep 2022 18:52:19 -0700 Subject: [PATCH] Added option to exclude or only run tests that involve an exception --- tests/harte_tests/src/main.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/harte_tests/src/main.rs b/tests/harte_tests/src/main.rs index db14e70..e86c66f 100644 --- a/tests/harte_tests/src/main.rs +++ b/tests/harte_tests/src/main.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; use std::time::SystemTime; use std::fs::{self, File}; -use clap::Parser; +use clap::{Parser, ArgEnum}; use flate2::read::GzDecoder; use serde_derive::Deserialize; @@ -19,6 +19,13 @@ use moa::devices::{Address, Addressable, Steppable, wrap_transmutable}; use moa::cpus::m68k::{M68k, M68kType}; use moa::cpus::m68k::state::Status; +#[derive(Copy, Clone, PartialEq, Eq, ArgEnum)] +enum Selection { + Include, + Exclude, + Only, +} + #[derive(Parser)] struct Args { /// Filter the tests by gzip file name @@ -38,6 +45,8 @@ struct Args { /// Directory to the test suite to run #[clap(long, default_value = DEFAULT_HART_TESTS)] testsuite: String, + #[clap(long, short, arg_enum, default_value_t = Selection::Include)] + exceptions: Selection, } fn main() { @@ -116,6 +125,11 @@ impl TestCase { self.final_state.dump(); println!("cycles: {}", self.length); } + + pub fn is_exception_case(&self) -> bool { + // If the supervisor stack changes by 6 or more bytes, then it's likely expected to be caused by an exception + self.initial_state.ssp.saturating_sub(self.final_state.ssp) >= 6 + } } @@ -281,6 +295,13 @@ fn test_json_file(path: PathBuf, args: &Args) -> (usize, usize, String) { } } + // Only run the test if it's selected by the exceptions flag + if case.is_exception_case() && args.exceptions == Selection::Exclude { + continue; + } else if !case.is_exception_case() && args.exceptions == Selection::Only { + continue; + } + // Sort the ram memory for debugging help if args.debug { case.initial_state.ram.sort_by_key(|(addr, _)| *addr);