Skip to content

Allow aml_tester to continue after an interpreter panic#277

Open
martin-hughes wants to merge 6 commits intorust-osdev:mainfrom
martin-hughes:aml-tester-tolerate-panic
Open

Allow aml_tester to continue after an interpreter panic#277
martin-hughes wants to merge 6 commits intorust-osdev:mainfrom
martin-hughes:aml-tester-tolerate-panic

Conversation

@martin-hughes
Copy link
Contributor

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_tester would 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:

  • To allow testing to continue after a panic, I use catch_unwind.
  • If an unwind is caught, the Interpreter will not necessarily be in a valid state
  • We therefore don't want to re-use it for future tests
  • run_tests needs to take ownership of the interpreter so it can enforce this rule

This 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_compile doesn't return io::Result any more - that level of detail isn't needed by the caller
  • This helped neaten up the output if there was a compilation error

Finally, because they were looking a bit messy:

  • I removed the %FN% interpolation - actually resolve_and_compile already relied on the iasl file-naming behaviour, so the only valid thing that could go in %FN% was what resolve_and_compile would already need. So it added no real value.
  • aml_tester::main now 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)

This makes it easier for any user to see if a test has failed. Which may
be useful for example in CI environments.
`resolve_and_compile` relies on the current `iasl` way of naming its
output, there's no need to duplicate that in `create_script_file`
@martin-hughes
Copy link
Contributor Author

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 👀

@martin-hughes
Copy link
Contributor Author

Well I can see to_x.asl actually silently fails on at least PR #274 (CI tests are green despite test failure) - some testing with WSL suggests it's a difference in the output from different iasl versions.

WSL Ubuntu apt install acpica-tools version: 20200925 - generates to_x.aml that fails when run in aml_tester
Windows reasonably recent version directly downloaded: 20251212 - generates to_x.aml that succeeds.

I'm not sure where to go from there really.

This was masking some bugs in `ToHexString` and `ToInteger` because
those calls were being folded out by the iasl optimizer.
@martin-hughes
Copy link
Contributor Author

Alright, I've figured out the problem. iasl was folding out the calls to ToHexString in the optimizer, and different versions of iasl produced different results for that - the new one produces (e.g.) "0x7b" whereas the old one produces "0000007b".

So I've added the -oa flag to the call to iasl and now it doesn't do that folding - I think this is the correct flag, just in case any optimisation hides the test we're trying to do. (Not just the constant folding optimisations)

This requires a minor fix to ToHexString to match the expected upper case, but it has exposed a bug in ToInteger that I've raised #278 rather than fixing here.

@martin-hughes
Copy link
Contributor Author

I've added the fix for #278 here to simplify testing it, let me know if you'd prefer it as a separate PR - I know this has a lot going on now... (Would close #278 if merged)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant