Allow aml_tester to continue after an interpreter panic#277
Allow aml_tester to continue after an interpreter panic#277IsaacWoods merged 4 commits intorust-osdev:mainfrom
aml_tester to continue after an interpreter panic#277Conversation
|
The exit code change already showing its value by breaking the checks it seems! Not sure why yet, I'll fix and update the PR - it works for me on my machine 👀 |
|
Well I can see WSL Ubuntu I'm not sure where to go from there really. |
|
Alright, I've figured out the problem. So I've added the This requires a minor fix to |
IsaacWoods
left a comment
There was a problem hiding this comment.
Thanks! This is a nice addition - one of my next goals with the library is to effectively eliminate panics, as a nice guarantee to users would be that the interpreter will never panic a kernel, but in the medium-term it would be nice to be able to recover from them in tests.
I've left a few comments with some refactoring nits, but otherwise this looks good. I'm fine with including the ToInteger changes here - thanks for working on that! It didn't occur to me that iasl would be applying optimisations (maybe when I looked it didn't do them if there have been changes in the last couple years?).
History wise, would it be possible to rebase to merge the first four commits into one? I think that makes intentions clearer with the intermediary changes eliminated.
|
|
||
| /// The result of a call to [`run_test`]. This is a bit of a combination - it contains the actual | ||
| /// result of the test, but also the interpreter - if it is still valid. | ||
| pub enum RunTestResult<T> |
There was a problem hiding this comment.
Having these two enums split is a little confusing I think. I wonder if it would be cleaner to have a return type of (TestResult, Option<Interpreter>) from the relevant functions to replace RunTestResult??
We could then optionally merge TestFailureReason into this too (i.e. have multiple FailedX variants in here. We could always have a TestResult::is_failure method if needed. I do like including the AmlError if applicable though.
There was a problem hiding this comment.
The reason I didn't go for the tuple approach is that the combined enum enforces the correct handling of the Interpreter. That is, it's not possible to get a (TestResult::Pass, None) or (TestResult::Panicked, Some(...)) result, so no code is needed to deal with it - not even an unwrap().
Just a personal style thing I guess - I'm a big fan of type-based enforcement of things - so if you prefer I'll take it out. Let me know if my argument sways you or not 😄
I don't feel too strongly about merging TestFailure reason into the enum - I guess if RunTestResult stays then it reduces duplication... I'll play it by ear based on what you say.
There was a problem hiding this comment.
That seems fair enough on second look - I think this is fine!
tools/aml_test_tools/src/lib.rs
Outdated
| Object::Integer(other) => { | ||
| error!("Test _MAIN returned non-zero exit code: {}", other); | ||
| // TODO: wrong error - this should probs return a more complex err type | ||
| Err(AmlError::NoCurrentOp) |
There was a problem hiding this comment.
I am not sure what we should use for this, but I feel leaving it like this could be confusing. I wonder if we should introduce an AmlError::HostError(String) (bikeshedding of name welcome) for this + errors that occur during handler operations?
There was a problem hiding this comment.
Yes - good shout. As you can see from the comment, totally meant to do something like this! My original thought was something more complex, but I think you've got a good solution.
tools/aml_test_tools/src/lib.rs
Outdated
| _ => { | ||
| error!("Test _MAIN returned unexpected object type: {}", *result); | ||
| // TODO: wrong error | ||
| Err(AmlError::NoCurrentOp) |
|
Cheers Isaac. Let me know about
Good plan, that'd be a nice guarantee to have - I guess most of the O/T really, but some good news: from a play with the uACPI tests and a not-yet-ready update to aml_tester it only looks like there's a couple of |
Fix accidentally broken tests Exit with a failure code if needed This makes it easier for any user to see if a test has failed. Which may be useful for example in CI environments. Remove AML filename replacement `resolve_and_compile` relies on the current `iasl` way of naming its output, there's no need to duplicate that in `create_script_file`
This was masking some bugs in `ToHexString` and `ToInteger` because those calls were being folded out by the iasl optimizer.
2a1f120 to
92db67c
Compare
|
Cheers Isaac. First 4 commits squashed, so should be good to go 🤞 |
The motivation here is to allow testing of large numbers of AML files - before this PR, a panic (probably from the Interpreter) would stop testing of all remaining files as
aml_testerwould exit.It has evolved into a slightly larger PR than that, with a grab-bag of other minor updates listed below.
The main bit of this PR all flows from changes to
run_test:catch_unwind.run_testsneeds to take ownership of the interpreter so it can enforce this ruleThis leads to a variety of parameter and return type changes throughout. (And explains why there's a bunch of new
enums in the code)Then I made a few other changes to improve consistency:
resolve_and_compiledoesn't returnio::Resultany more - that level of detail isn't needed by the callerFinally, because they were looking a bit messy:
%FN%interpolation - actuallyresolve_and_compilealready relied on theiaslfile-naming behaviour, so the only valid thing that could go in%FN%was whatresolve_and_compilewould already need. So it added no real value.aml_tester::mainnow returns an exit code, so that if there are any test failures the user can see it reflected there. This might be useful for CI pipelines etc and reflects other testing tools (e.g.cargo test)