Skip to content
Snippets Groups Projects
Commit ea7bf520 authored by Martin Teichmann's avatar Martin Teichmann
Browse files

add a test

parent 477a8bf1
No related branches found
No related tags found
No related merge requests found
...@@ -389,6 +389,27 @@ class Tests(TestCase): ...@@ -389,6 +389,27 @@ class Tests(TestCase):
Instruction(opcode=O.OR, dst=0, src=0, off=0, imm=32), Instruction(opcode=O.OR, dst=0, src=0, off=0, imm=32),
Instruction(opcode=O.B+O.STX, dst=10, src=0, off=-1, imm=0)]) Instruction(opcode=O.B+O.STX, dst=10, src=0, off=-1, imm=0)])
def test_bits_and_or(self):
class Local(EBPF):
a = LocalVar((5, 1))
e = Local(ProgType.XDP, "GPL")
with e.stmp:
with (e.a != 0) & (e.stmp > 0) | (e.a == 0) & (e.stmp < 0):
e.stmp = 0
self.assertEqual(e.opcodes, [
Instruction(opcode=O.LD+O.B, dst=2, src=10, off=-1, imm=0),
Instruction(opcode=O.JSET, dst=2, src=0, off=1, imm=32),
Instruction(opcode=O.JMP, dst=0, src=0, off=1, imm=0),
Instruction(opcode=O.JSGT, dst=0, src=0, off=3, imm=0),
Instruction(opcode=O.LD+O.B, dst=2, src=10, off=-1, imm=0),
Instruction(opcode=O.JSET, dst=2, src=0, off=2, imm=32),
Instruction(opcode=O.JSGE, dst=0, src=0, off=1, imm=0),
Instruction(opcode=O.MOV+O.LONG, dst=0, src=0, off=0, imm=0),
])
def test_local_subprog(self): def test_local_subprog(self):
class Local(EBPF): class Local(EBPF):
a = LocalVar('I') a = LocalVar('I')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment