Skip to content

Commit

Permalink
Add conformance tests for shifting out of range (#125)
Browse files Browse the repository at this point in the history
The Linux verifier rejects shifting by imm out of range
so did not add tests for those cases.

Signed-off-by: Dave Thaler <dthaler@microsoft.com>
  • Loading branch information
dthaler committed May 9, 2023
1 parent e40bcff commit b798975
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 6 deletions.
12 changes: 12 additions & 0 deletions tests/arsh32-reg-high.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0

-- asm
mov32 %r0, 0xf8
mov32 %r1, 48
lsh32 %r0, 28
# %r0 == 0x80000000
arsh32 %r0, %r1
exit
-- result
0xffff8000
12 changes: 12 additions & 0 deletions tests/arsh32-reg-neg.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0

-- asm
mov32 %r0, 0xf8
mov32 %r1, -16
lsh32 %r0, 28
# %r0 == 0x80000000
arsh32 %r0, %r1
exit
-- result
0xffff8000
9 changes: 9 additions & 0 deletions tests/arsh64-imm.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0
-- asm
mov32 %r0, 1
lsh %r0, 63
arsh %r0, 60
exit
-- result
0xfffffffffffffff8
3 changes: 1 addition & 2 deletions tests/arsh64.data → tests/arsh64-reg-high.data
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
-- asm
mov32 %r0, 1
lsh %r0, 63
arsh %r0, 55
mov32 %r1, 5
mov32 %r1, 124
arsh %r0, %r1
exit
-- result
Expand Down
10 changes: 10 additions & 0 deletions tests/arsh64-reg-neg.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0
-- asm
mov32 %r0, 1
lsh %r0, 63
mov32 %r1, -4
arsh %r0, %r1
exit
-- result
0xfffffffffffffff8
10 changes: 10 additions & 0 deletions tests/arsh64-reg.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0
-- asm
mov32 %r0, 1
lsh %r0, 63
mov32 %r1, 60
arsh %r0, %r1
exit
-- result
0xfffffffffffffff8
8 changes: 4 additions & 4 deletions tests/arsh32-high-shift.data → tests/lsh32-reg-high.data
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0
-- asm
mov %r0, 8
lddw %r1, 0x100000001
arsh32 %r0, %r1
mov %r0, 0x11
mov %r7, 60
lsh32 %r0, %r7
exit
-- result
0x4
0x10000000
9 changes: 9 additions & 0 deletions tests/lsh32-reg-neg.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0
-- asm
mov %r0, 0x11
mov %r7, -4
lsh32 %r0, %r7
exit
-- result
0x10000000
9 changes: 9 additions & 0 deletions tests/lsh64-reg-high.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0
-- asm
mov %r0, 0x1
mov %r7, 68
lsh %r0, %r7
exit
-- result
0x10
9 changes: 9 additions & 0 deletions tests/lsh64-reg-neg.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0
-- asm
mov %r0, 0x1
mov %r7, -60
lsh %r0, %r7
exit
-- result
0x10
10 changes: 10 additions & 0 deletions tests/rsh32-reg-high.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0
-- asm
mov %r0, 0
sub %r0, 1
mov %r7, 40
rsh32 %r0, %r7
exit
-- result
0x00ffffff
10 changes: 10 additions & 0 deletions tests/rsh32-reg-neg.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0
-- asm
mov %r0, 0
sub %r0, 1
mov %r7, -24
rsh32 %r0, %r7
exit
-- result
0x00ffffff
9 changes: 9 additions & 0 deletions tests/rsh64-reg-high.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0
-- asm
mov %r0, 0x10
mov %r7, 68
rsh %r0, %r7
exit
-- result
0x1
9 changes: 9 additions & 0 deletions tests/rsh64-reg-neg.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0
-- asm
mov %r0, 0x10
mov %r7, -60
rsh %r0, %r7
exit
-- result
0x1

0 comments on commit b798975

Please sign in to comment.