Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/asm/internal/asm: add encoding tests for all architectures #18072
At tip as of Nov 28, 2016: The end-to-end tests in cmd/asm/internal/asm/testdata are much weaker than they used to be. I have vague memories of a change someone (Russ?) made there, but now for most architectures all that is tested is the parse, not the result of the parse. These tests should be verifying that the assembler produces correct output, not just that it accepts valid input.
I spoke to Rob earlier. He was remembering the fact that there used to be a golden x.out next to each x.s in the testdata directory; the x.out contained the output from 'asm -S x.s'. These proved too annoying to keep in sync, so in https://golang.org/cl/18823 I changed the test to require instead that, by default, each line found in the assembly is reprinted with exactly the same syntax. That is, the result of the parse is tested and must reprint as the original input exactly. When there are multiple equivalent forms, so that the result of parse+reprint may vary, a comment in the testdata file specifies the desired printed form. For example:
The middle operand is omitted in the input but defaults to the final one, so that's what is printed and what is expected by the test (due to the comment).
The two can be combined if needed, as in
It is true the tests are too weak: there should be hex instruction encoding tests for all architectures, not just amd64 and s390x. But this work is unplanned.