(u: &mut Unstructured)
| 42 | |
| 43 | impl Arbitrary<'_> for TestCase { |
| 44 | fn arbitrary(u: &mut Unstructured) -> Result<Self> { |
| 45 | // Ensure the logger is initialized. |
| 46 | let _ = pretty_env_logger::try_init(); |
| 47 | |
| 48 | let example_reginfos = EXAMPLE_REGINFOS.get_or_init(|| { |
| 49 | let aarch64 = |
| 50 | GenericRegInfo::parse(include_str!("../../example_reginfo/aarch64.reginfo")) |
| 51 | .unwrap(); |
| 52 | let riscv = |
| 53 | GenericRegInfo::parse(include_str!("../../example_reginfo/riscv.reginfo")).unwrap(); |
| 54 | debug_utils::validate_reginfo(&aarch64).unwrap(); |
| 55 | debug_utils::validate_reginfo(&riscv).unwrap(); |
| 56 | vec![ |
| 57 | ("example_reginfo/aarch64.reginfo", aarch64), |
| 58 | ("example_reginfo/riscv.reginfo", riscv), |
| 59 | ] |
| 60 | }); |
| 61 | let options = u.arbitrary()?; |
| 62 | log::trace!("Options: {options:?}"); |
| 63 | let reginfo = if u.arbitrary()? { |
| 64 | let (path, reginfo) = u.choose(example_reginfos)?; |
| 65 | log::trace!("Using example reginfo: {path}"); |
| 66 | TestCaseRegInfo::Example { path, reginfo } |
| 67 | } else { |
| 68 | let reginfo = u.arbitrary()?; |
| 69 | log::trace!("Using arbitrary reginfo:\n{reginfo}"); |
| 70 | TestCaseRegInfo::Arbitrary { reginfo } |
| 71 | }; |
| 72 | let func = GenericFunction::arbitrary_with_config(reginfo.get(), u, Default::default())?; |
| 73 | Ok(TestCase { |
| 74 | reginfo, |
| 75 | func, |
| 76 | options, |
| 77 | }) |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | impl fmt::Debug for TestCase { |
nothing calls this directly
no test coverage detected