From a2799c0fbbdf244de9acb731ceeec536f0409ad0 Mon Sep 17 00:00:00 2001 From: Dave Thaler Date: Mon, 22 Jan 2024 09:02:26 -0800 Subject: [PATCH] Add additional corner cases to tests (#187) * Add more tests for comparison of a register with itself Some jump tests did it, others didn't. Signed-off-by: Dave Thaler * Add more addtion and subtraction cases Signed-off-by: Dave Thaler * Add move-to-self Signed-off-by: Dave Thaler * Add tests for OR and AND register with itself Signed-off-by: Dave Thaler --------- Signed-off-by: Dave Thaler --- tests/add.data | 2 ++ tests/add64.data | 10 +++++++--- tests/alu-arith.data | 3 ++- tests/alu-bit.data | 2 ++ tests/alu64-arith.data | 3 ++- tests/alu64-bit.data | 2 ++ tests/jeq-reg.data | 2 ++ tests/jeq32-reg.data | 2 ++ tests/jge-reg.data | 18 ++++++++++++++++++ tests/jge32-reg.data | 2 ++ tests/jne-reg.data | 1 + tests/jne32-reg.data | 3 ++- tests/jset-reg.data | 2 ++ tests/jset32-reg.data | 2 ++ tests/jsge-reg.data | 2 ++ tests/jsge32-reg.data | 2 ++ tests/jsgt-reg.data | 1 + tests/jsgt32-reg.data | 1 + tests/jsle-reg.data | 3 +++ tests/jsle32-reg.data | 3 +++ tests/mov.data | 1 + tests/mov64.data | 9 +++++++++ 22 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 tests/jge-reg.data create mode 100644 tests/mov64.data diff --git a/tests/add.data b/tests/add.data index 06587ac..390b1f4 100644 --- a/tests/add.data +++ b/tests/add.data @@ -5,6 +5,8 @@ mov32 %r0, 0 mov32 %r1, 2 add32 %r0, 1 add32 %r0, %r1 +add32 %r0, %r0 +add32 %r0, -3 exit -- result 0x3 diff --git a/tests/add64.data b/tests/add64.data index 0d49480..06c3a16 100644 --- a/tests/add64.data +++ b/tests/add64.data @@ -1,8 +1,12 @@ # Copyright (c) Big Switch Networks, Inc # SPDX-License-Identifier: Apache-2.0 -- asm -mov %r0, 1 -add %r0, -1 +mov %r0, 0 +mov %r1, 2 +add %r0, 1 +add %r0, %r1 +add %r0, %r0 +add %r0, -3 exit -- result -0 +0x3 diff --git a/tests/alu-arith.data b/tests/alu-arith.data index d2801f4..1b20d13 100644 --- a/tests/alu-arith.data +++ b/tests/alu-arith.data @@ -1,7 +1,8 @@ # Copyright (c) Big Switch Networks, Inc # SPDX-License-Identifier: Apache-2.0 -- asm -mov32 %r0, 0 +mov32 %r0, 10 +sub32 %r0, %r0 mov32 %r1, 1 mov32 %r2, 2 mov32 %r3, 3 diff --git a/tests/alu-bit.data b/tests/alu-bit.data index e1091e1..475f91f 100644 --- a/tests/alu-bit.data +++ b/tests/alu-bit.data @@ -15,12 +15,14 @@ jne %r0, 0, exit or32 %r0, %r5 or32 %r0, 0xa0 +or32 %r0, %r0 # %r0 == 0xa5 jne %r0, 0xa5, exit and32 %r0, 0xa3 mov32 %r9, 0x91 and32 %r0, %r9 +and32 %r0, %r0 # %r0 == 0x81 jne %r0, 0x81, exit diff --git a/tests/alu64-arith.data b/tests/alu64-arith.data index e079eba..7a7a606 100644 --- a/tests/alu64-arith.data +++ b/tests/alu64-arith.data @@ -1,7 +1,8 @@ # Copyright (c) Big Switch Networks, Inc # SPDX-License-Identifier: Apache-2.0 -- asm -mov %r0, 0 +mov %r0, 10 +sub %r0, %r0 mov %r1, 1 mov %r2, 2 mov %r3, 3 diff --git a/tests/alu64-bit.data b/tests/alu64-bit.data index 6a31933..da6d655 100644 --- a/tests/alu64-bit.data +++ b/tests/alu64-bit.data @@ -15,12 +15,14 @@ jne %r0, 0, exit or %r0, %r5 or %r0, 0xa0 +or %r0, %r0 # %r0 == 0xa5 jne %r0, 0xa5, exit and %r0, 0xa3 mov %r9, 0x91 and %r0, %r9 +and %r0, %r0 # %r0 == 0x81 jne %r0, 0x81, exit diff --git a/tests/jeq-reg.data b/tests/jeq-reg.data index ffbf03c..b413715 100644 --- a/tests/jeq-reg.data +++ b/tests/jeq-reg.data @@ -5,6 +5,8 @@ mov32 %r0, 0 mov32 %r1, 0xa mov32 %r2, 0xb jeq %r1, %r2, exit # Not taken +jeq %r1, %r1, +1 # Taken +exit mov32 %r0, 1 mov32 %r1, 0xb diff --git a/tests/jeq32-reg.data b/tests/jeq32-reg.data index 8c1df4a..625cb12 100644 --- a/tests/jeq32-reg.data +++ b/tests/jeq32-reg.data @@ -8,6 +8,8 @@ mov32 %r0, 0 mov32 %r1, 0xa mov32 %r2, 0xb jeq32 %r1, %r2, exit # Not taken +jeq32 %r1, %r1, +1 # Taken +exit mov32 %r0, 1 mov32 %r1, 0xb diff --git a/tests/jge-reg.data b/tests/jge-reg.data new file mode 100644 index 0000000..3a11429 --- /dev/null +++ b/tests/jge-reg.data @@ -0,0 +1,18 @@ +# Copyright (c) Big Switch Networks, Inc +# SPDX-License-Identifier: Apache-2.0 +-- asm +mov32 %r0, 0 +mov32 %r1, 0xa +mov32 %r2, 0x0b +jge %r1, %r2, exit # Not taken +jge %r1, %r1, +1 # Taken +exit + +mov32 %r0, 1 +mov32 %r1, 0xc +jge %r1, %r2, exit # Taken + +mov32 %r0, 2 # Skipped +exit +-- result +0x1 diff --git a/tests/jge32-reg.data b/tests/jge32-reg.data index 3643f14..1f2cf8e 100644 --- a/tests/jge32-reg.data +++ b/tests/jge32-reg.data @@ -8,6 +8,8 @@ mov32 %r0, 0 mov32 %r1, 0xa mov32 %r2, 0xb jge32 %r1, %r2, exit # Not taken +jge32 %r1, %r1, +1 # Taken +exit mov32 %r0, 1 # set %r1 to 0x10000000c diff --git a/tests/jne-reg.data b/tests/jne-reg.data index 7d63c80..88b8486 100644 --- a/tests/jne-reg.data +++ b/tests/jne-reg.data @@ -5,6 +5,7 @@ mov32 %r0, 0 mov32 %r1, 0xb mov32 %r2, 0xb jne %r1, %r2, exit # Not taken +jne %r1, %r1, exit # Not taken mov32 %r0, 1 mov32 %r1, 0xa diff --git a/tests/jne32-reg.data b/tests/jne32-reg.data index fd78d02..4e42670 100644 --- a/tests/jne32-reg.data +++ b/tests/jne32-reg.data @@ -9,7 +9,8 @@ mov32 %r1, 0xb # set %r1 to 0x10000000b or %r1, %r9 mov32 %r2, 0xb -jne32 %r1, %r2, +4 # Not taken +jne32 %r1, %r2, +5 # Not taken +jne32 %r1, %r1, +4 # Not taken mov32 %r0, 1 mov32 %r1, 0xa diff --git a/tests/jset-reg.data b/tests/jset-reg.data index 308177a..8080d19 100644 --- a/tests/jset-reg.data +++ b/tests/jset-reg.data @@ -5,6 +5,8 @@ mov32 %r0, 0 mov32 %r1, 0x7 mov32 %r2, 0x8 jset %r1, %r2, exit # Not taken +jset %r1, %r1, +1 # Taken +exit mov32 %r0, 1 mov32 %r1, 0x9 diff --git a/tests/jset32-reg.data b/tests/jset32-reg.data index 2126744..0780e80 100644 --- a/tests/jset32-reg.data +++ b/tests/jset32-reg.data @@ -10,6 +10,8 @@ mov32 %r1, 0x7 or %r1, %r9 mov32 %r2, 0x8 jset32 %r1, %r2, exit # Not taken +jset32 %r1, %r1, +1 # Taken +exit mov32 %r0, 1 mov32 %r1, 0x9 diff --git a/tests/jsge-reg.data b/tests/jsge-reg.data index f5b3fe4..62a1345 100644 --- a/tests/jsge-reg.data +++ b/tests/jsge-reg.data @@ -7,6 +7,8 @@ mov %r2, 0xffffffff mov32 %r3, 0 jsge %r1, %r2, exit # Not taken jsge %r1, %r3, exit # Not taken +jsge %r1, %r1, +1 # Taken +exit mov32 %r0, 1 mov %r1, %r2 diff --git a/tests/jsge32-reg.data b/tests/jsge32-reg.data index a27c504..659bfb3 100644 --- a/tests/jsge32-reg.data +++ b/tests/jsge32-reg.data @@ -12,6 +12,8 @@ mov %r2, 0xffffffff mov32 %r3, 0 jsge32 %r1, %r2, exit # Not taken jsge32 %r1, %r3, exit # Not taken +jsge32 %r1, %r1, +1 # Taken +exit mov32 %r0, 1 mov %r1, %r2 diff --git a/tests/jsgt-reg.data b/tests/jsgt-reg.data index 315fcd5..37b00dc 100644 --- a/tests/jsgt-reg.data +++ b/tests/jsgt-reg.data @@ -5,6 +5,7 @@ mov32 %r0, 0 mov %r1, 0xfffffffe mov %r2, 0xffffffff jsgt %r1, %r2, exit # Not taken +jsgt %r1, %r1, exit # Not taken mov32 %r0, 1 mov32 %r1, 0 diff --git a/tests/jsgt32-reg.data b/tests/jsgt32-reg.data index 2181d5a..6021706 100644 --- a/tests/jsgt32-reg.data +++ b/tests/jsgt32-reg.data @@ -10,6 +10,7 @@ mov32 %r1, 0xfffffffe or %r1, %r9 mov %r2, 0xffffffff jsgt32 %r1, %r2, exit # Not taken +jsgt32 %r1, %r1, exit # Not taken mov32 %r0, 1 mov32 %r1, 0 diff --git a/tests/jsle-reg.data b/tests/jsle-reg.data index 629fed9..384fa47 100644 --- a/tests/jsle-reg.data +++ b/tests/jsle-reg.data @@ -8,6 +8,9 @@ mov32 %r3, 0 jsle %r1, %r2, exit # Not taken jsle %r1, %r3, +1 # Taken exit +jsle %r1, %r1, +1 # Taken +exit + mov32 %r0, 1 mov %r1, %r2 jsle %r1, %r2, +1 # Taken diff --git a/tests/jsle32-reg.data b/tests/jsle32-reg.data index 6a266ca..f97227a 100644 --- a/tests/jsle32-reg.data +++ b/tests/jsle32-reg.data @@ -13,6 +13,9 @@ mov32 %r3, 0 jsle32 %r1, %r2, exit # Not taken jsle32 %r1, %r3, +1 # Taken exit +jsle32 %r1, %r1, +1 # Taken +exit + mov32 %r0, 1 mov %r1, %r2 jsle32 %r1, %r2, +1 # Taken diff --git a/tests/mov.data b/tests/mov.data index 54358e7..be7037e 100644 --- a/tests/mov.data +++ b/tests/mov.data @@ -3,6 +3,7 @@ -- asm mov32 %r1, 1 mov32 %r0, %r1 +mov32 %r0, %r0 exit -- result 0x1 diff --git a/tests/mov64.data b/tests/mov64.data new file mode 100644 index 0000000..f382f88 --- /dev/null +++ b/tests/mov64.data @@ -0,0 +1,9 @@ +# Copyright (c) Big Switch Networks, Inc +# SPDX-License-Identifier: Apache-2.0 +-- asm +mov %r1, 1 +mov %r0, %r1 +mov %r0, %r0 +exit +-- result +0x1