-
Notifications
You must be signed in to change notification settings - Fork 473
[test] Tests for custom sections #1341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The reference interpreter does not currently deal with the contents of custom sections, since they are outside the scope of the actual specification, by definition. No custom section is required to be recognised or handled by any implementation of Wasm, nor are they allowed to reject a module due to a malformed custom section. So respective tests can't be part of the mandatory test suite. We could introduce some sort of "custom" test suite. Not sure how much benefit there would be in using the reference interpreter for that, though. We could teach it to decode custom sections mentioned in the non-normative spec appendix. I wouldn't be opposed to that, but from first glance, that would be almost entirely orthogonal to everything else it does, so could probably just as well be run by a separate tool. |
If a custom section test can't be part of the mandatory test suite, and the reference interpreter in your opinion is not the best place to implement the decoding of custom sections, how should I interpret the phase 3 entry requirements for the Branch Hinting proposal (and I suppose the Instrument Tracing proposal as well)?
If, let's say, I add a "custom" directory to the tests with a bunch of modules with valid and invalid branchHints sections, and add branch hinting validation to On this matter, @dschuff said in the CG meeting that "having no test is another answer". Is that really an option? |
Good question. Not all criteria are applicable to all features or proposals -- e.g., the reference interpreter doesn't apply to JS API features. In general, the CG needs to decide what to request in such cases. Personally, I think it would be good to have |
I think that it would be better to use an existing tool than to rewrite a wasm binary parser from scratch just for validating custom sections. To get more familiar with the Wabt codebase and evaluate the possibility of using it for validating the custom section tests, I added support for the branch hints section to it (see PR). I will also start writing some tests in the wast format under I am not sure what the best way to write a script to run the above tests with wabt is: assume that the wabt tools are available somewhere or clone the repo, compile the tools and use them. |
Hm, you shouldn't need anything close to a full Wasm binary parser for a syntactic check of custom sections -- it only needs to recognise the section structure, which is fairly trivial. Unless you also want to have semantic checks, which may include checking the well-formedness relative to the module proper. It's not clear from the above if you also plan on doing that? In the latter case, it's indeed probably easiest to put it into the reference interpreter -- it seems a bit undesirable to create more dependencies on external tools, especially since that will lose the ability to do holistic PRs that ensure consistency of both tool and tests. Either way, it would be great if this infrastructure was pluggable somehow, i.e., custom sections can be added in a modular manner. But I don't have a concrete idea how to do that exactly. I'll try to think about that. |
Yeah sorry, it is unclear to me too if I am supposed to add semantic checks or not. For Branch Hinting in particular it may end up that the semantic checks are not really meaningful: While we figure out the best way to proceed (and I will bring up this issue again in a CG meeting) I will add the tests in the proposal repo under For phase 3 it may even be enough already(?) since the tests just need to exist and be able to pass on some implementation (V8, but it does not report errors, and soon wabt). |
I am the champion of the Branch Hinting proposal, and I am thinking about the requirement of adding tests for entering phase 3.
There is currently no infrastructure in the reference interpreter (or any other Wasm engine I think) to validate the parsing of custom section payloads. Not even for the
names
section (I was hoping I could take inspiration from how that is handled, but all the tests for the name section are about the names themselves, not the binary format).The Instrument Tracing proposal is also going to use a custom section, so this discussion should be relevant for it too.
I am not familiar with OCaml, nor the interpreter codebase specifically, but I think that a solution could be to add new "commands" to the extended wast syntax used in the tests:
assert_custom_valid <custom section content>
: assert given well-known custom section parses successfullyassert_custom_invalid <custom section content>
: assert given well-known custom section parses unsuccessfullyThis would allow to add tests for the names section binary format, in addition to the Branch Hinting and Instrument Tracing proposals (of course for each of these, we will need to write the validation logic in the interpreter).
Before trying to experiment with this idea I would like to hear what people think about it, and if there are alternatives.
As added context, here is an extract from the CG-06-08 meeting where we briefly talked about this:
The text was updated successfully, but these errors were encountered: