Skip to content

Commit

Permalink
Fix test_prog_always_return_42 from erroring in pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
twizmwazin committed Nov 30, 2023
1 parent 5884f37 commit 7211e70
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions tests/test_ebpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@
TEST_PROGRAMS_BASE = Path(__file__).parent.parent / "test_programs" / "ebpf"


def test_prog_always_returns_42(filename: str) -> None:
proj = angr.Project(TEST_PROGRAMS_BASE / filename)
assert isinstance(proj.arch, ArchExtendedBPF)

state = proj.factory.entry_state()
simgr = proj.factory.simgr(state)
simgr.run()
class TestEbpf(unittest.TestCase):
@staticmethod
def _test_prog_always_returns_42(filename: str) -> None:
proj = angr.Project(TEST_PROGRAMS_BASE / filename)
assert isinstance(proj.arch, ArchExtendedBPF)

assert len(simgr.deadended) == 1
assert state.solver.eval_exact(simgr.deadended[0].regs.R0, 1) == [42]
state = proj.factory.entry_state()
simgr = proj.factory.simgr(state)
simgr.run()

assert len(simgr.deadended) == 1
assert state.solver.eval_exact(simgr.deadended[0].regs.R0, 1) == [42]

class TestEbpf(unittest.TestCase):
# pylint:disable=missing-class-docstring,no-self-use
def test_trivial_return(self):
test_prog_always_returns_42("return_42.o")
self._test_prog_always_returns_42("return_42.o")

def test_branched_return(self):
test_prog_always_returns_42("return_if.o")
self._test_prog_always_returns_42("return_if.o")

def test_get_ns(self):
test_prog_always_returns_42("get_ns.o")
self._test_prog_always_returns_42("get_ns.o")

def test_ebpf_lift(self):
proj = angr.Project(TEST_PROGRAMS_BASE / "return_42.o")
Expand Down

0 comments on commit 7211e70

Please sign in to comment.