diff mbox series

[6/6] tests/decode: Add tests for various named-field cases

Message ID 20230523120447.728365-7-peter.maydell@linaro.org
State Accepted
Headers show
Series decodetree: support named fields | expand

Commit Message

Peter Maydell May 23, 2023, 12:04 p.m. UTC
Add some tests for various cases of named-field use, both ones that
should work and ones that should be diagnosed as errors.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 tests/decode/err_field1.decode       |  2 +-
 tests/decode/err_field10.decode      |  7 +++++++
 tests/decode/err_field7.decode       |  7 +++++++
 tests/decode/err_field8.decode       |  8 ++++++++
 tests/decode/err_field9.decode       | 14 ++++++++++++++
 tests/decode/succ_named_field.decode | 19 +++++++++++++++++++
 6 files changed, 56 insertions(+), 1 deletion(-)
 create mode 100644 tests/decode/err_field10.decode
 create mode 100644 tests/decode/err_field7.decode
 create mode 100644 tests/decode/err_field8.decode
 create mode 100644 tests/decode/err_field9.decode
 create mode 100644 tests/decode/succ_named_field.decode

Comments

Richard Henderson May 23, 2023, 6:20 p.m. UTC | #1
On 5/23/23 05:04, Peter Maydell wrote:
> Add some tests for various cases of named-field use, both ones that
> should work and ones that should be diagnosed as errors.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   tests/decode/err_field1.decode       |  2 +-
>   tests/decode/err_field10.decode      |  7 +++++++
>   tests/decode/err_field7.decode       |  7 +++++++
>   tests/decode/err_field8.decode       |  8 ++++++++
>   tests/decode/err_field9.decode       | 14 ++++++++++++++
>   tests/decode/succ_named_field.decode | 19 +++++++++++++++++++
>   6 files changed, 56 insertions(+), 1 deletion(-)
>   create mode 100644 tests/decode/err_field10.decode
>   create mode 100644 tests/decode/err_field7.decode
>   create mode 100644 tests/decode/err_field8.decode
>   create mode 100644 tests/decode/err_field9.decode
>   create mode 100644 tests/decode/succ_named_field.decode

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Peter Maydell May 24, 2023, 10:26 a.m. UTC | #2
On Tue, 23 May 2023 at 13:04, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> Add some tests for various cases of named-field use, both ones that
> should work and ones that should be diagnosed as errors.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  tests/decode/err_field1.decode       |  2 +-
>  tests/decode/err_field10.decode      |  7 +++++++
>  tests/decode/err_field7.decode       |  7 +++++++
>  tests/decode/err_field8.decode       |  8 ++++++++
>  tests/decode/err_field9.decode       | 14 ++++++++++++++
>  tests/decode/succ_named_field.decode | 19 +++++++++++++++++++
>  6 files changed, 56 insertions(+), 1 deletion(-)
>  create mode 100644 tests/decode/err_field10.decode
>  create mode 100644 tests/decode/err_field7.decode
>  create mode 100644 tests/decode/err_field8.decode
>  create mode 100644 tests/decode/err_field9.decode
>  create mode 100644 tests/decode/succ_named_field.decode
>
> diff --git a/tests/decode/err_field1.decode b/tests/decode/err_field1.decode
> index e07a5a73e0e..85c3f326d07 100644
> --- a/tests/decode/err_field1.decode
> +++ b/tests/decode/err_field1.decode
> @@ -2,4 +2,4 @@
>  # See the COPYING.LIB file in the top-level directory.
>
>  # Diagnose invalid field syntax
> -%field asdf
> +%field 1asdf

I just realized that this specific change needs to go before patch 5:
it's updating an existing test because "asdf" used to be invalid
syntax and now is not. Otherwise bisection will break.

-- PMM
Richard Henderson May 26, 2023, 5:07 p.m. UTC | #3
On 5/24/23 03:26, Peter Maydell wrote:
> On Tue, 23 May 2023 at 13:04, Peter Maydell <peter.maydell@linaro.org> wrote:
>>
>> Add some tests for various cases of named-field use, both ones that
>> should work and ones that should be diagnosed as errors.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>>   tests/decode/err_field1.decode       |  2 +-
>>   tests/decode/err_field10.decode      |  7 +++++++
>>   tests/decode/err_field7.decode       |  7 +++++++
>>   tests/decode/err_field8.decode       |  8 ++++++++
>>   tests/decode/err_field9.decode       | 14 ++++++++++++++
>>   tests/decode/succ_named_field.decode | 19 +++++++++++++++++++
>>   6 files changed, 56 insertions(+), 1 deletion(-)
>>   create mode 100644 tests/decode/err_field10.decode
>>   create mode 100644 tests/decode/err_field7.decode
>>   create mode 100644 tests/decode/err_field8.decode
>>   create mode 100644 tests/decode/err_field9.decode
>>   create mode 100644 tests/decode/succ_named_field.decode
>>
>> diff --git a/tests/decode/err_field1.decode b/tests/decode/err_field1.decode
>> index e07a5a73e0e..85c3f326d07 100644
>> --- a/tests/decode/err_field1.decode
>> +++ b/tests/decode/err_field1.decode
>> @@ -2,4 +2,4 @@
>>   # See the COPYING.LIB file in the top-level directory.
>>
>>   # Diagnose invalid field syntax
>> -%field asdf
>> +%field 1asdf
> 
> I just realized that this specific change needs to go before patch 5:
> it's updating an existing test because "asdf" used to be invalid
> syntax and now is not. Otherwise bisection will break.

Really?  The test still fails here at patch 5:

/home/rth/qemu/bld/../src/tests/decode/err_field1.decode:5: error: invalid field token "asdf"


r~
Peter Maydell May 26, 2023, 7:49 p.m. UTC | #4
On Fri, 26 May 2023 at 18:07, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> On 5/24/23 03:26, Peter Maydell wrote:
> > On Tue, 23 May 2023 at 13:04, Peter Maydell <peter.maydell@linaro.org> wrote:
> >>
> >> Add some tests for various cases of named-field use, both ones that
> >> should work and ones that should be diagnosed as errors.
> >>
> >> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> >> ---
> >>   tests/decode/err_field1.decode       |  2 +-
> >>   tests/decode/err_field10.decode      |  7 +++++++
> >>   tests/decode/err_field7.decode       |  7 +++++++
> >>   tests/decode/err_field8.decode       |  8 ++++++++
> >>   tests/decode/err_field9.decode       | 14 ++++++++++++++
> >>   tests/decode/succ_named_field.decode | 19 +++++++++++++++++++
> >>   6 files changed, 56 insertions(+), 1 deletion(-)
> >>   create mode 100644 tests/decode/err_field10.decode
> >>   create mode 100644 tests/decode/err_field7.decode
> >>   create mode 100644 tests/decode/err_field8.decode
> >>   create mode 100644 tests/decode/err_field9.decode
> >>   create mode 100644 tests/decode/succ_named_field.decode
> >>
> >> diff --git a/tests/decode/err_field1.decode b/tests/decode/err_field1.decode
> >> index e07a5a73e0e..85c3f326d07 100644
> >> --- a/tests/decode/err_field1.decode
> >> +++ b/tests/decode/err_field1.decode
> >> @@ -2,4 +2,4 @@
> >>   # See the COPYING.LIB file in the top-level directory.
> >>
> >>   # Diagnose invalid field syntax
> >> -%field asdf
> >> +%field 1asdf
> >
> > I just realized that this specific change needs to go before patch 5:
> > it's updating an existing test because "asdf" used to be invalid
> > syntax and now is not. Otherwise bisection will break.
>
> Really?  The test still fails here at patch 5:
>
> /home/rth/qemu/bld/../src/tests/decode/err_field1.decode:5: error: invalid field token "asdf"

Oh, right, because there's no trailing size specification
so it doesn't get recognized as a named field.

thanks
-- PMM
diff mbox series

Patch

diff --git a/tests/decode/err_field1.decode b/tests/decode/err_field1.decode
index e07a5a73e0e..85c3f326d07 100644
--- a/tests/decode/err_field1.decode
+++ b/tests/decode/err_field1.decode
@@ -2,4 +2,4 @@ 
 # See the COPYING.LIB file in the top-level directory.
 
 # Diagnose invalid field syntax
-%field	asdf
+%field	1asdf
diff --git a/tests/decode/err_field10.decode b/tests/decode/err_field10.decode
new file mode 100644
index 00000000000..3e672b7459e
--- /dev/null
+++ b/tests/decode/err_field10.decode
@@ -0,0 +1,7 @@ 
+# This work is licensed under the terms of the GNU LGPL, version 2 or later.
+# See the COPYING.LIB file in the top-level directory.
+
+# Diagnose formats which refer to undefined fields
+%field1        field2:3
+@fmt ........ ........ ........ ........ %field1
+insn 00000000 00000000 00000000 00000000 @fmt
diff --git a/tests/decode/err_field7.decode b/tests/decode/err_field7.decode
new file mode 100644
index 00000000000..51fad7cceaf
--- /dev/null
+++ b/tests/decode/err_field7.decode
@@ -0,0 +1,7 @@ 
+# This work is licensed under the terms of the GNU LGPL, version 2 or later.
+# See the COPYING.LIB file in the top-level directory.
+
+# Diagnose fields whose definitions form a loop
+%field1        field2:3
+%field2        field1:4
+insn 00000000 00000000 00000000 00000000 %field1 %field2
diff --git a/tests/decode/err_field8.decode b/tests/decode/err_field8.decode
new file mode 100644
index 00000000000..cc47c08a459
--- /dev/null
+++ b/tests/decode/err_field8.decode
@@ -0,0 +1,8 @@ 
+# This work is licensed under the terms of the GNU LGPL, version 2 or later.
+# See the COPYING.LIB file in the top-level directory.
+
+# Diagnose patterns which refer to undefined fields
+&f1 f1 a
+%field1        field2:3
+@fmt ........ ........ ........ .... a:4 &f1
+insn 00000000 00000000 00000000 0000 .... @fmt f1=%field1
diff --git a/tests/decode/err_field9.decode b/tests/decode/err_field9.decode
new file mode 100644
index 00000000000..e7361d521ba
--- /dev/null
+++ b/tests/decode/err_field9.decode
@@ -0,0 +1,14 @@ 
+# This work is licensed under the terms of the GNU LGPL, version 2 or later.
+# See the COPYING.LIB file in the top-level directory.
+
+# Diagnose fields where the format refers to a field defined in the
+# pattern and the pattern refers to a field defined in the format.
+# This is theoretically not impossible to implement, but is not
+# supported by the script at this time.
+&abcd a b c d
+%refa        a:3
+%refc        c:4
+# Format defines 'c' and sets 'b' to an indirect ref to 'a'
+@fmt ........ ........ ........ c:8 &abcd b=%refa
+# Pattern defines 'a' and sets 'd' to an indirect ref to 'c'
+insn 00000000 00000000 00000000 ........ @fmt d=%refc a=6
diff --git a/tests/decode/succ_named_field.decode b/tests/decode/succ_named_field.decode
new file mode 100644
index 00000000000..e64b3f93568
--- /dev/null
+++ b/tests/decode/succ_named_field.decode
@@ -0,0 +1,19 @@ 
+# This work is licensed under the terms of the GNU LGPL, version 2 or later.
+# See the COPYING.LIB file in the top-level directory.
+
+# field using a named_field
+%imm_sz	8:8 sz:3
+insn 00000000 00000000 ........ 00000000 imm_sz=%imm_sz sz=1
+
+# Ditto, via a format. Here a field in the format
+# references a named field defined in the insn pattern:
+&imm_a imm alpha
+%foo 0:16 alpha:4
+@foo 00000001 ........ ........ ........ &imm_a imm=%foo
+i1   ........ 00000000 ........ ........ @foo alpha=1
+i2   ........ 00000001 ........ ........ @foo alpha=2
+
+# Here the named field is defined in the format and referenced
+# from the insn pattern:
+@bar 00000010 ........ ........ ........ &imm_a alpha=4
+i3   ........ 00000000 ........ ........ @bar imm=%foo