Skip to content

Commit

Permalink
Add tests for shifting by out of range immediate
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
  • Loading branch information
dthaler committed May 9, 2023
1 parent b798975 commit dd0df92
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ set_tests_properties(

add_test(
NAME exclude_test
COMMAND sudo ${PROJECT_BINARY_DIR}/bin/bpf_conformance_runner --debug true --test_file_path ${PROJECT_SOURCE_DIR}/tests/lock_add.data --plugin_path ${PROJECT_BINARY_DIR}/bin/libbpf_plugin --xdp_prolog true --plugin_options "--debug" --exclude_regex lock
COMMAND sudo ${PROJECT_BINARY_DIR}/bin/bpf_conformance_runner --debug true --test_file_path ${PROJECT_SOURCE_DIR}/tests/lock_add.data --plugin_path ${PROJECT_BINARY_DIR}/bin/libbpf_plugin --xdp_prolog true --plugin_options "--debug" --exclude_regex "(lock|imm-)"
)

set_tests_properties(
Expand Down Expand Up @@ -433,4 +433,4 @@ set_tests_properties(
add_test(
NAME back_compat
COMMAND sudo ${PROJECT_BINARY_DIR}/bin/bpf_conformance_runner --test_file_path ${PROJECT_BINARY_DIR}/tests/add.data --plugin_path ${PROJECT_BINARY_DIR}/bin/libbpf_plugin
)
)
10 changes: 10 additions & 0 deletions tests/arsh32-imm-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
mov32 %r0, 0xf8
lsh32 %r0, 28
# %r0 == 0x80000000
arsh32 %r0, 48
exit
-- result
0xffff8000
10 changes: 10 additions & 0 deletions tests/arsh32-imm-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, 0xf8
lsh32 %r0, 28
# %r0 == 0x80000000
arsh32 %r0, -16
exit
-- result
0xffff8000
9 changes: 9 additions & 0 deletions tests/arsh64-imm-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
mov32 %r0, 1
lsh %r0, 63
arsh %r0, 124
exit
-- result
0xfffffffffffffff8
9 changes: 9 additions & 0 deletions tests/arsh64-imm-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
mov32 %r0, 1
lsh %r0, 63
arsh %r0, -4
exit
-- result
0xfffffffffffffff8
8 changes: 8 additions & 0 deletions tests/lsh32-imm-high.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0
-- asm
mov %r0, 0x11
lsh32 %r0, 60
exit
-- result
0x10000000
8 changes: 8 additions & 0 deletions tests/lsh32-imm-neg.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0
-- asm
mov %r0, 0x11
lsh32 %r0, -4
exit
-- result
0x10000000
8 changes: 8 additions & 0 deletions tests/lsh64-imm-high.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0
-- asm
mov %r0, 0x1
lsh %r0, 68
exit
-- result
0x10
8 changes: 8 additions & 0 deletions tests/lsh64-imm-neg.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) Big Switch Networks, Inc
# SPDX-License-Identifier: Apache-2.0
-- asm
mov %r0, 0x1
lsh %r0, -60
exit
-- result
0x10
9 changes: 9 additions & 0 deletions tests/rsh32-imm-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, 0
sub %r0, 1
rsh32 %r0, 40
exit
-- result
0x00ffffff
9 changes: 9 additions & 0 deletions tests/rsh32-imm-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, 0
sub %r0, 1
rsh32 %r0, -24
exit
-- result
0x00ffffff
8 changes: 8 additions & 0 deletions tests/rsh64-imm-high.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) Microsoft Corporation
# SPDX-License-Identifier: Apache-2.0
-- asm
mov %r0, 0x10
rsh %r0, 68
exit
-- result
0x1
8 changes: 8 additions & 0 deletions tests/rsh64-imm-neg.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) Microsoft Corporation
# SPDX-License-Identifier: Apache-2.0
-- asm
mov %r0, 0x10
rsh %r0, -60
exit
-- result
0x1

0 comments on commit dd0df92

Please sign in to comment.